diff --git a/RIOT/examples/real_time_app/main.c b/RIOT/examples/real_time_app/main.c index 45289ff..3f68a40 100644 --- a/RIOT/examples/real_time_app/main.c +++ b/RIOT/examples/real_time_app/main.c @@ -80,7 +80,7 @@ #define PWM_FREQ 100 #define PWM_RES 100 -#define DEADLINE 70000 +#define DEADLINE 24000 // addr ipv6 link local node 1: fe80::3734:510e:3317:3402 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) puts("Error creating UDP sock"); return NULL; } + if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) { + puts("Error in synchronization"); + return NULL; + } + offset = sntp_get_offset(); + printf("offset : %i\n",(int)offset); while (1) { sock_udp_ep_t remote; ssize_t res; - + if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), SOCK_NO_TIMEOUT, &remote)) >= 0) { // puts("Received a message"); @@ -203,11 +209,7 @@ void *sock_server_thread(void *arg) /*if (sock_udp_send(&sock, buf, res, &remote) < 0) { puts("Error sending reply"); }*/ - if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) { - puts("Error in synchronization"); - return NULL; - } - offset = sntp_get_offset(); + deadline = xtimer_now_usec() + offset - buf.heure_actuelle; printf("tps de transmission : %i\n",deadline); @@ -233,6 +235,7 @@ void *sock_server_thread(void *arg) //ordre = 1; pwm_set(PWM_DEV(0),1,45); tourne = 1; + timer_run=0; timer_clear(TIMER_DEV(1),0); printf("clear timer\n"); } @@ -352,9 +355,9 @@ static void _init_interface(void) tmp_addr.u8[15] = 0x62; //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762 fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); - 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"); + client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread"); xtimer_usleep(10000); - 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"); + 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"); xtimer_usleep(200); }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x62)){ tmp_addr.u8[14] = 0x37; @@ -376,9 +379,11 @@ static void _init_interface(void) //fibroute dest: dead:beef::3762 via fe80::3634:5110:3473:3762 fib_add_entry(&gnrc_ipv6_fib_table, ifs[0],tmp_addr.u8, IN6ADDRSZ, 0,node2, IN6ADDRSZ, 0, FIB_LIFETIME_NO_EXPIRE); //start_server("1234"); - 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"); + _init_timer(); _init_pwm(); - _init_timer(); + server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread"); + + }else{ puts("new node ?"); } -- libgit2 0.21.2