Commit 59fd08c7a942714ae5b0294219846f6b4ad9f31f

Authored by root
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,7 +80,7 @@
80 80
81 #define PWM_FREQ 100 81 #define PWM_FREQ 100
82 #define PWM_RES 100 82 #define PWM_RES 100
83 -#define DEADLINE 70000 83 +#define DEADLINE 24000
84 84
85 // addr ipv6 link local node 1: fe80::3734:510e:3317:3402 85 // addr ipv6 link local node 1: fe80::3734:510e:3317:3402
86 uint8_t node1[16]={0xfe,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x34,0x51,0x0e,0x33,0x17,0x34,0x02}; 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,11 +191,17 @@ void *sock_server_thread(void *arg)
191 puts("Error creating UDP sock"); 191 puts("Error creating UDP sock");
192 return NULL; 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 while (1) { 201 while (1) {
196 sock_udp_ep_t remote; 202 sock_udp_ep_t remote;
197 ssize_t res; 203 ssize_t res;
198 - 204 +
199 if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), SOCK_NO_TIMEOUT, 205 if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), SOCK_NO_TIMEOUT,
200 &remote)) >= 0) { 206 &remote)) >= 0) {
201 // puts("Received a message"); 207 // puts("Received a message");
@@ -203,11 +209,7 @@ void *sock_server_thread(void *arg) @@ -203,11 +209,7 @@ void *sock_server_thread(void *arg)
203 /*if (sock_udp_send(&sock, buf, res, &remote) < 0) { 209 /*if (sock_udp_send(&sock, buf, res, &remote) < 0) {
204 puts("Error sending reply"); 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 deadline = xtimer_now_usec() + offset - buf.heure_actuelle; 213 deadline = xtimer_now_usec() + offset - buf.heure_actuelle;
212 printf("tps de transmission : %i\n",deadline); 214 printf("tps de transmission : %i\n",deadline);
213 215
@@ -233,6 +235,7 @@ void *sock_server_thread(void *arg) @@ -233,6 +235,7 @@ void *sock_server_thread(void *arg)
233 //ordre = 1; 235 //ordre = 1;
234 pwm_set(PWM_DEV(0),1,45); 236 pwm_set(PWM_DEV(0),1,45);
235 tourne = 1; 237 tourne = 1;
  238 + timer_run=0;
236 timer_clear(TIMER_DEV(1),0); 239 timer_clear(TIMER_DEV(1),0);
237 printf("clear timer\n"); 240 printf("clear timer\n");
238 } 241 }
@@ -352,9 +355,9 @@ static void _init_interface(void) @@ -352,9 +355,9 @@ static void _init_interface(void)
352 tmp_addr.u8[15] = 0x62; 355 tmp_addr.u8[15] = 0x62;
353 //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762 356 //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762
354 fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); 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 xtimer_usleep(10000); 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 xtimer_usleep(200); 361 xtimer_usleep(200);
359 }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x62)){ 362 }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x62)){
360 tmp_addr.u8[14] = 0x37; 363 tmp_addr.u8[14] = 0x37;
@@ -376,9 +379,11 @@ static void _init_interface(void) @@ -376,9 +379,11 @@ static void _init_interface(void)
376 //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762 379 //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762
377 fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); 380 fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE);
378 //start_server("1234"); 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 _init_pwm(); 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 }else{ 387 }else{
383 puts("new node ?"); 388 puts("new node ?");
384 } 389 }