|
|
@ -49,6 +49,24 @@ static void active_report_data_structer_update(void) |
|
|
|
encoder_read_with_encoder(DRIVEN_ENCODER_GEAR, &active_report_data_structer.encoder_2_count); |
|
|
|
} |
|
|
|
|
|
|
|
static void udp_client_recv_data_dump(int recv_datalen) |
|
|
|
{ |
|
|
|
for (size_t i = 0; i < recv_datalen; i++) |
|
|
|
{ |
|
|
|
printf("%d ", s_receBuf[i]); |
|
|
|
} |
|
|
|
printf("\r\n"); |
|
|
|
} |
|
|
|
|
|
|
|
static void udp_client_create_basic_response(basic_report_data_t *rxcmd, int recv_datalen) |
|
|
|
{ |
|
|
|
/* 因为发送和接收是一致的,所以不需要二次校验,直接把接收的数据发送即可 */ |
|
|
|
if (sendto(sock_Client, rxcmd, sizeof(basic_report_data_t), 0, (struct sockaddr *)&addr_server, sizeof(struct sockaddr_in)) == SOCKET_ERROR) |
|
|
|
{ |
|
|
|
printf("send basic_response error\r\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void config_server(struct sockaddr_in *addr_server) |
|
|
|
{ |
|
|
|
addr_server->sin_family = SERVER_FAMILY; |
|
|
@ -121,15 +139,6 @@ void udp_client_init(void) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static void udp_client_recv_data_dump(int recv_datalen) |
|
|
|
{ |
|
|
|
for (size_t i = 0; i < recv_datalen; i++) |
|
|
|
{ |
|
|
|
printf("%d ", s_receBuf[i]); |
|
|
|
} |
|
|
|
printf("\r\n"); |
|
|
|
} |
|
|
|
|
|
|
|
void udp_client_recv(void) |
|
|
|
{ |
|
|
|
int recv_datalen = recvfrom(sock_Client, s_receBuf, sizeof(s_receBuf), 0, (struct sockaddr *)&sock, &sock_len); |
|
|
@ -168,8 +177,8 @@ void udp_client_parse(int recv_datalen) |
|
|
|
if ((rxcmd->data == 0) || (rxcmd->data == 1)) |
|
|
|
{ |
|
|
|
udp_client_active_flag = rxcmd->data; |
|
|
|
printf("set ok,udp_client_active_flag:%d\r\n",udp_client_active_flag); |
|
|
|
} |
|
|
|
udp_client_create_basic_response(rxcmd, recv_datalen); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|