Hey all,
I'm trying to build some riot sample code (on native platform):
http://riot-os.org/files/01.Introduction.pdf
on page 11 the swtimer is used, but it seems that it's not in riot anymore?
I have only found a vtimer, but it lags some needed functions...
best,
Christian
Hi Christian,
yes swtimer is removed, there also exist a resolved github issue for the swtimer.
However what functions do you need, which are not provided?
I do not see anything which was provided by the swtimer which is not possible anymore.
Reagrds,
Milan
Hi Milan,
also exist a resolved github issue for the
swtimer.
I see...
However what functions do you need, which are not provided?
I do not see anything which was provided by the swtimer which is not
possible anymore.
I'm just digging around. I try understand riot and try to build some
"setTimeout"-like code.
I have this code: http://pastebin.com/J7FyEXWA
but
/home/c/git/RIOT-OS/projects/hello-world-timer/bin/hello-world.a(main.o):
In function `main':
main.c:(.text+0x7d): undefined reference to `timex_set'
main.c:(.text+0xb9): undefined reference to `vtimer_set_wakeup'
collect2: Fehler: ld gab 1 als Ende-Status zurück
make: *** [all] Fehler 1
Christian
/home/c/git/RIOT-OS/projects/hello-world-timer/bin/hello-world.a(main.o):
In function `main':
main.c:(.text+0x7d): undefined reference to `timex_set'
main.c:(.text+0xb9): undefined reference to `vtimer_set_wakeup'
collect2: Fehler: ld gab 1 als Ende-Status zurück
make: *** [all] Fehler 1
ok, I added USEMODULE += vtimer to the makefile and now i have a .elf file 
but I don't have the expected behavior, I want some code called periodically.
but I get this:
$ ./bin/hello-world.elf
RIOT native cpu initialized.
RIOT native interrupts/signals initialized.
LED_GREEN_OFF
LED_RED_ON
RIOT native board initialized.
RIOT native hardware initialization complete.
kernel_init(): This is RIOT!
Scheduler...[OK]
kernel_init(): jumping into first task...
LED_RED_ON
LED_GREEN_OFF
LED_GREEN_TOGGLE
LED_RED_TOGGLE
Das Signal SIGNALRM empfangen (Der Wecker klingelt)
Christian
Hi Christian,
/home/c/git/RIOT-OS/projects/hello-world-timer/bin/hello-world.a(main.o):
In function `main':
main.c:(.text+0x7d): undefined reference to `timex_set'
main.c:(.text+0xb9): undefined reference to `vtimer_set_wakeup'
collect2: Fehler: ld gab 1 als Ende-Status zurück
make: *** [all] Fehler 1
ok, I added USEMODULE += vtimer to the makefile and now i have a .elf file 
yes, when ld complains mostly not everything you need was build.
but I don't have the expected behavior, I want some code called periodically.
but I get this:
$ ./bin/hello-world.elf
RIOT native cpu initialized.
RIOT native interrupts/signals initialized.
LED_GREEN_OFF
LED_RED_ON
RIOT native board initialized.
RIOT native hardware initialization complete.
kernel_init(): This is RIOT!
Scheduler...[OK]
kernel_init(): jumping into first task...
LED_RED_ON
LED_GREEN_OFF
LED_GREEN_TOGGLE
LED_RED_TOGGLE
Das Signal SIGNALRM empfangen (Der Wecker klingelt)
At first please add either the autoinit module or init the timer manual.
To only call the code in function blinker every second remove line 29 to 32 and change blinker to:
while(1) {
LED_GREEN_TOGGLE();
LED_RED_TOGGLE();
vtimer_usleep(SEC);
}
To have something more close to your original implementation you could also delete the thread_create and use the vtimer to call the function blinker like this:
t1.action = (void*) blinker;
t1.absolute = t_time;
t1.arg = null;
vtimer_set(&t1);
But this will call blinker only once, if you want to recall it you have to set a new timer in blinker or else may set already 5 timer in your main.
Don't be confused about t1.absolute, vtimer_now() will be added in vtimer_set.
You will stay in vtimer callback during your function call, so for bigger actions I would suggest to create a new thread instead of calling a function direct.
Regards,
Milan