Commit 59fd08c7a942714ae5b0294219846f6b4ad9f31f
1 parent
e873cff7
application real-time OK : resolution du bug
Showing
1 changed file
with
16 additions
and
11 deletions
Show diff stats
RIOT/examples/real_time_app/main.c
... | ... | @@ -80,7 +80,7 @@ |
80 | 80 | |
81 | 81 | #define PWM_FREQ 100 |
82 | 82 | #define PWM_RES 100 |
83 | -#define DEADLINE 70000 | |
83 | +#define DEADLINE 24000 | |
84 | 84 | |
85 | 85 | // addr ipv6 link local node 1: fe80::3734:510e:3317:3402 |
86 | 86 | uint8_t node1[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x34,0x51,0x0e,0x33,0x17,0x34,0x02}; |
... | ... | @@ -191,11 +191,17 @@ void *sock_server_thread(void *arg) |
191 | 191 | puts("Error creating UDP sock"); |
192 | 192 | return NULL; |
193 | 193 | } |
194 | + if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) { | |
195 | + puts("Error in synchronization"); | |
196 | + return NULL; | |
197 | + } | |
198 | + offset = sntp_get_offset(); | |
199 | + printf("offset : %i\n",(int)offset); | |
194 | 200 | |
195 | 201 | while (1) { |
196 | 202 | sock_udp_ep_t remote; |
197 | 203 | ssize_t res; |
198 | - | |
204 | + | |
199 | 205 | if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), SOCK_NO_TIMEOUT, |
200 | 206 | &remote)) >= 0) { |
201 | 207 | // puts("Received a message"); |
... | ... | @@ -203,11 +209,7 @@ void *sock_server_thread(void *arg) |
203 | 209 | /*if (sock_udp_send(&sock, buf, res, &remote) < 0) { |
204 | 210 | puts("Error sending reply"); |
205 | 211 | }*/ |
206 | - if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) { | |
207 | - puts("Error in synchronization"); | |
208 | - return NULL; | |
209 | - } | |
210 | - offset = sntp_get_offset(); | |
212 | + | |
211 | 213 | deadline = xtimer_now_usec() + offset - buf.heure_actuelle; |
212 | 214 | printf("tps de transmission : %i\n",deadline); |
213 | 215 | |
... | ... | @@ -233,6 +235,7 @@ void *sock_server_thread(void *arg) |
233 | 235 | //ordre = 1; |
234 | 236 | pwm_set(PWM_DEV(0),1,45); |
235 | 237 | tourne = 1; |
238 | + timer_run=0; | |
236 | 239 | timer_clear(TIMER_DEV(1),0); |
237 | 240 | printf("clear timer\n"); |
238 | 241 | } |
... | ... | @@ -352,9 +355,9 @@ static void _init_interface(void) |
352 | 355 | tmp_addr.u8[15] = 0x62; |
353 | 356 | //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762 |
354 | 357 | fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); |
355 | - client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_WOUT_YIELD |THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread"); | |
358 | + client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread"); | |
356 | 359 | xtimer_usleep(10000); |
357 | - time_server=thread_create(sock_time_server_stack,sizeof(sock_time_server_stack),8, THREAD_CREATE_WOUT_YIELD |THREAD_CREATE_STACKTEST,sock_time_server_thread,NULL,"sock_time_server_thread"); | |
360 | + time_server=thread_create(sock_time_server_stack,sizeof(sock_time_server_stack),6,THREAD_CREATE_STACKTEST,sock_time_server_thread,NULL,"sock_time_server_thread"); | |
358 | 361 | xtimer_usleep(200); |
359 | 362 | }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x62)){ |
360 | 363 | tmp_addr.u8[14] = 0x37; |
... | ... | @@ -376,9 +379,11 @@ static void _init_interface(void) |
376 | 379 | //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762 |
377 | 380 | fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); |
378 | 381 | //start_server("1234"); |
379 | - server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_WOUT_YIELD |THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread"); | |
382 | + _init_timer(); | |
380 | 383 | _init_pwm(); |
381 | - _init_timer(); | |
384 | + server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread"); | |
385 | + | |
386 | + | |
382 | 387 | }else{ |
383 | 388 | puts("new node ?"); |
384 | 389 | } | ... | ... |