[Client] Rename packet variables

This commit is contained in:
Matteo Cypriani 2010-08-03 12:13:09 +02:00
parent dcdab12c27
commit ac6998d798
1 changed files with 22 additions and 22 deletions

View File

@ -68,8 +68,8 @@ BOOL is_calibration_request = FALSE ;
int sockfd ; // Sending socket descriptor int sockfd ; // Sending socket descriptor
struct sockaddr_in server ; // Server info struct sockaddr_in server ; // Server info
char *buf = NULL ; // Packet to send char *packet = NULL ; // Packet to send
int buf_size ; // Packet size int packet_size ; // Packet size
@ -283,8 +283,8 @@ inline void create_socket()
/* Creates the packet to send. */ /* Creates the packet to send. */
void make_packet() void make_packet()
{ {
int buf_offset ; // Index used to create the packet int offset ; // Index used to create the packet
int buf_size ; // Packet size int size ; // Packet size
struct timeval request_time ; struct timeval request_time ;
gettimeofday(&request_time, NULL) ; gettimeofday(&request_time, NULL) ;
@ -293,33 +293,33 @@ void make_packet()
{ {
printf("Calibration time: %llu\n", timeval_to_ms(request_time)) ; printf("Calibration time: %llu\n", timeval_to_ms(request_time)) ;
buf_offset = 0 ; offset = 0 ;
buf_size = size =
sizeof(char) * 2 + sizeof(struct timeval) + sizeof(float) * 3 ; sizeof(char) * 2 + sizeof(struct timeval) + sizeof(float) * 3 ;
buf = malloc(buf_size) ; packet = malloc(size) ;
buf[buf_offset++] = PACKET_TYPE_CALIBRATION ; // Packet type packet[offset++] = PACKET_TYPE_CALIBRATION ; // Packet type
memcpy(&buf[buf_offset], &request_time, sizeof(request_time)) ; memcpy(&packet[offset], &request_time, sizeof(request_time)) ;
buf_offset += sizeof(request_time) ; offset += sizeof(request_time) ;
buf[buf_offset++] = options.direction ; // Direction packet[offset++] = options.direction ; // Direction
#ifdef DEBUG #ifdef DEBUG
printf("Direction = %d, X = %f, Y = %f, Z = %f\n", printf("Direction = %d, X = %f, Y = %f, Z = %f\n",
buf[buf_offset - 1], options.x, options.y, options.z) ; packet[offset - 1], options.x, options.y, options.z) ;
#endif // DEBUG #endif // DEBUG
memcpy(&buf[buf_offset], &options.x, sizeof(float)) ; memcpy(&packet[offset], &options.x, sizeof(float)) ;
buf_offset += sizeof(float) ; offset += sizeof(float) ;
memcpy(&buf[buf_offset], &options.y, sizeof(float)) ; memcpy(&packet[offset], &options.y, sizeof(float)) ;
buf_offset += sizeof(float) ; offset += sizeof(float) ;
memcpy(&buf[buf_offset], &options.z, sizeof(float)) ; memcpy(&packet[offset], &options.z, sizeof(float)) ;
} }
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)) ;
buf_size = sizeof(char) + sizeof(struct timeval) ; size = sizeof(char) + sizeof(struct timeval) ;
buf = malloc(buf_size) ; packet = malloc(size) ;
buf[0] = PACKET_TYPE_NORMAL ; // Packet type packet[0] = PACKET_TYPE_NORMAL ; // Packet type
memcpy(&buf[1], &request_time, sizeof(request_time)) ; memcpy(&packet[1], &request_time, sizeof(request_time)) ;
} }
} }
@ -327,7 +327,7 @@ void make_packet()
inline void send_request() inline void send_request()
{ {
owlps_send_request(sockfd, &server, buf, buf_size, owlps_send_request(sockfd, &server, packet, packet_size,
options.nb_pkt, options.delay) ; options.nb_pkt, options.delay) ;
} }