Commit 05f40afda4b3ee482ddacfc1968762a3ad2d27b0
1 parent
f8d83614
final test sntp
Showing
1 changed file
with
8 additions
and
11 deletions
Show diff stats
RIOT/examples/network_app_rtt_1/main.c
@@ -120,8 +120,8 @@ void *sock_time_server_thread(void *arg) | @@ -120,8 +120,8 @@ void *sock_time_server_thread(void *arg) | ||
120 | if ((res = sock_udp_recv(&sock_ntp,&sntp_packet, sizeof(sntp_packet), SOCK_NO_TIMEOUT, | 120 | if ((res = sock_udp_recv(&sock_ntp,&sntp_packet, sizeof(sntp_packet), SOCK_NO_TIMEOUT, |
121 | &remote)) >= 0) { | 121 | &remote)) >= 0) { |
122 | sntp_packet.receive.seconds=byteorder_htonl( xtimer_now_usec()); | 122 | sntp_packet.receive.seconds=byteorder_htonl( xtimer_now_usec()); |
123 | - sntp_packet.origin.seconds=sntp_packet.transmit.seconds; | ||
124 | - sntp_packet.transmit.seconds=byteorder_htonl( xtimer_now_usec()); | 123 | + sntp_packet.origin.seconds=sntp_packet.transmit.seconds; |
124 | + sntp_packet.transmit.seconds=byteorder_htonl( xtimer_now_usec()); | ||
125 | 125 | ||
126 | if (sock_udp_send(&sock_ntp, &sntp_packet, sizeof(sntp_packet), &remote) < 0) { | 126 | if (sock_udp_send(&sock_ntp, &sntp_packet, sizeof(sntp_packet), &remote) < 0) { |
127 | puts("Error sending reply"); | 127 | puts("Error sending reply"); |
@@ -131,13 +131,10 @@ void *sock_time_server_thread(void *arg) | @@ -131,13 +131,10 @@ void *sock_time_server_thread(void *arg) | ||
131 | return NULL; | 131 | return NULL; |
132 | } | 132 | } |
133 | 133 | ||
134 | -uint32_t end,test; | ||
135 | -//uint32_t time1, time2; | ||
136 | -//char rbuf[MAXLEN], sbuf[MAXLEN], ack[MAXLEN]; | ||
137 | - | ||
138 | -typedef struct tableau { | ||
139 | - uint32_t heure_actuelle; | ||
140 | - char donnees[MAXLEN]; | 134 | + |
135 | +typedef struct list { | ||
136 | + uint32_t send_time; | ||
137 | + char packet[MAXLEN]; | ||
141 | }Data; | 138 | }Data; |
142 | 139 | ||
143 | // calculate the time diff between start and end (in us) | 140 | // calculate the time diff between start and end (in us) |
@@ -198,7 +195,7 @@ void *sock_server_thread(void *arg) | @@ -198,7 +195,7 @@ void *sock_server_thread(void *arg) | ||
198 | { | 195 | { |
199 | puts("Can't receive datagram\n"); | 196 | puts("Can't receive datagram\n"); |
200 | } | 197 | } |
201 | - deadline = xtimer_now_usec() + offset - buf.heure_actuelle; | 198 | + deadline = xtimer_now_usec() + offset - buf.send_time; |
202 | printf("tps de transmission : %i\n",deadline); | 199 | printf("tps de transmission : %i\n",deadline); |
203 | 200 | ||
204 | //puts("Got a UDP datagram\n"); | 201 | //puts("Got a UDP datagram\n"); |
@@ -241,7 +238,7 @@ void *sock_client_thread(void *arg) | @@ -241,7 +238,7 @@ void *sock_client_thread(void *arg) | ||
241 | { | 238 | { |
242 | 239 | ||
243 | 240 | ||
244 | - data.heure_actuelle = xtimer_now_usec(); | 241 | + data.send_time = xtimer_now_usec(); |
245 | //test=xtimer_now_usec(); | 242 | //test=xtimer_now_usec(); |
246 | printf("Heure server: %" PRIu32 "\n",data.heure_actuelle); | 243 | printf("Heure server: %" PRIu32 "\n",data.heure_actuelle); |
247 | if (sock_udp_send(&sock,&data,sizeof(data), &remote) < 0) | 244 | if (sock_udp_send(&sock,&data,sizeof(data), &remote) < 0) |