Created
January 21, 2014 16:36
-
-
Save OlegHahm/8543409 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/test_vtimer_msg/main.c b/test_vtimer_msg/../../RIOT/tests/test_vtimer_msg/main.c | |
index 837c9c2..ef327bb 100644 | |
--- a/test_vtimer_msg/main.c | |
+++ b/test_vtimer_msg/../../RIOT/tests/test_vtimer_msg/main.c | |
@@ -1,10 +1,12 @@ | |
#include <stdio.h> | |
+#include <time.h> | |
#include "vtimer.h" | |
#include "thread.h" | |
#include "msg.h" | |
char timer_stack[KERNEL_CONF_STACKSIZE_PRINTF]; | |
+char timer_stack_local[KERNEL_CONF_STACKSIZE_PRINTF]; | |
struct timer_msg { | |
vtimer_t timer; | |
@@ -32,7 +34,7 @@ void timer_thread(void) | |
msg_receive(&m); | |
struct timer_msg* tmsg = (struct timer_msg*) m.content.ptr; | |
vtimer_now(&now); | |
- printf("now=%" PRIu32 ":%" PRIu32 " -> every %" PRIu32 ".%" PRIu32 "s: %s\n", | |
+ printf("now=%" PRIu32 ":%" PRIu32 " -> every %u.%us: %s\n", | |
now.seconds, | |
now.microseconds, | |
tmsg->interval.seconds, | |
@@ -47,6 +49,20 @@ void timer_thread(void) | |
} | |
} | |
+void timer_thread_local(void) | |
+{ | |
+ printf("This is thread %d\n", thread_getpid()); | |
+ | |
+ while (1) { | |
+ msg_t m; | |
+ msg_receive(&m); | |
+ | |
+ struct tm t; | |
+ vtimer_get_localtime(&t); | |
+ printf("sec=%d min=%d hour=%d\n", t.tm_sec, t.tm_min, t.tm_hour); | |
+ } | |
+} | |
+ | |
int main(void) { | |
msg_t m; | |
int pid = thread_create( | |
@@ -64,4 +80,18 @@ int main(void) { | |
puts("sending 2nd msg"); | |
m.content.ptr = (char*) &msg_b; | |
msg_send(&m, pid, false); | |
+ | |
+ int pid2 = thread_create( | |
+ timer_stack_local, | |
+ sizeof timer_stack_local, | |
+ PRIORITY_MAIN-1, | |
+ CREATE_STACKTEST, | |
+ timer_thread_local, | |
+ "timer local"); | |
+ | |
+ timex_t sleep = timex_set(1, 0); | |
+ while (1) { | |
+ vtimer_sleep(sleep); | |
+ msg_send(&m, pid2, 0); | |
+ } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment