[Client] Fix initialisation of packet_size
+Fix print_usage()
This commit is contained in:
parent
56c831ffab
commit
c31d753e00
|
@ -284,7 +284,6 @@ inline void create_socket()
|
||||||
void make_packet()
|
void make_packet()
|
||||||
{
|
{
|
||||||
int offset ; // Index used to create the packet
|
int offset ; // Index used to create the packet
|
||||||
int size ; // Packet size
|
|
||||||
struct timeval request_time ;
|
struct timeval request_time ;
|
||||||
|
|
||||||
gettimeofday(&request_time, NULL) ;
|
gettimeofday(&request_time, NULL) ;
|
||||||
|
@ -294,9 +293,9 @@ void make_packet()
|
||||||
printf("Calibration time: %llu\n", timeval_to_ms(request_time)) ;
|
printf("Calibration time: %llu\n", timeval_to_ms(request_time)) ;
|
||||||
|
|
||||||
offset = 0 ;
|
offset = 0 ;
|
||||||
size =
|
packet_size =
|
||||||
sizeof(char) * 2 + sizeof(struct timeval) + sizeof(float) * 3 ;
|
sizeof(char) * 2 + sizeof(struct timeval) + sizeof(float) * 3 ;
|
||||||
packet = malloc(size) ;
|
packet = malloc(packet_size) ;
|
||||||
|
|
||||||
packet[offset++] = PACKET_TYPE_CALIBRATION ; // Packet type
|
packet[offset++] = PACKET_TYPE_CALIBRATION ; // Packet type
|
||||||
memcpy(&packet[offset], &request_time, sizeof(request_time)) ;
|
memcpy(&packet[offset], &request_time, sizeof(request_time)) ;
|
||||||
|
@ -316,8 +315,8 @@ void make_packet()
|
||||||
else // Standard packet
|
else // Standard packet
|
||||||
{
|
{
|
||||||
printf("Request time: %llu\n", timeval_to_ms(request_time)) ;
|
printf("Request time: %llu\n", timeval_to_ms(request_time)) ;
|
||||||
size = sizeof(char) + sizeof(struct timeval) ;
|
packet_size = sizeof(char) + sizeof(struct timeval) ;
|
||||||
packet = malloc(size) ;
|
packet = malloc(packet_size) ;
|
||||||
packet[0] = PACKET_TYPE_NORMAL ; // Packet type
|
packet[0] = PACKET_TYPE_NORMAL ; // Packet type
|
||||||
memcpy(&packet[1], &request_time, sizeof(request_time)) ;
|
memcpy(&packet[1], &request_time, sizeof(request_time)) ;
|
||||||
}
|
}
|
||||||
|
@ -356,8 +355,8 @@ void print_usage()
|
||||||
"\t%s -d dest_ip [-p dest_port] [-i iface] [-t delay]"
|
"\t%s -d dest_ip [-p dest_port] [-i iface] [-t delay]"
|
||||||
" [-n nb_packets] [-l [port]]\n"
|
" [-n nb_packets] [-l [port]]\n"
|
||||||
"Calibration request:\n"
|
"Calibration request:\n"
|
||||||
"\t%s -d dest_ip [-i iface] [-t delay] [-n nb_packets]"
|
"\t%s -d dest_ip [-p dest_port] [-i iface] [-t delay]"
|
||||||
" direction x y z\n"
|
" [-n nb_packets] direction x y z\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
"\t-h\t\tPrint this help.\n"
|
"\t-h\t\tPrint this help.\n"
|
||||||
|
|
Loading…
Reference in New Issue