解决校验位错误重复回复数据帧BUG

This commit is contained in:
王绪洁 2025-02-14 16:32:59 +08:00
parent adbd7818d0
commit bdd3979064
2 changed files with 40 additions and 37 deletions

View File

@ -156,6 +156,8 @@ static err_t tcpecho_recv_control(void *arg, struct tcp_pcb *tpcb, struct pbuf *
communication_exception(tcp_tx_data, tcp_rx_data, CHECK_ERROR); communication_exception(tcp_tx_data, tcp_rx_data, CHECK_ERROR);
tcp_write(tpcb, tcp_tx_data, tx_data_len, 1); tcp_write(tpcb, tcp_tx_data, tx_data_len, 1);
} }
else
{
memcpy(communication_data.data, tcp_rx_data + 5, tcp_rx_data[4]); memcpy(communication_data.data, tcp_rx_data + 5, tcp_rx_data[4]);
if (tcp_rx_data[3] == 0x00) // 读模拟量指令 if (tcp_rx_data[3] == 0x00) // 读模拟量指令
{ {
@ -196,6 +198,7 @@ static err_t tcpecho_recv_control(void *arg, struct tcp_pcb *tpcb, struct pbuf *
communication_exception(tcp_tx_data, tcp_rx_data, COMMAND_ERROR); communication_exception(tcp_tx_data, tcp_rx_data, COMMAND_ERROR);
tcp_write(tpcb, tcp_tx_data, tx_data_len, 1); tcp_write(tpcb, tcp_tx_data, tx_data_len, 1);
} }
}
/*2. 判断所要执行的操作 读或写指令*/ /*2. 判断所要执行的操作 读或写指令*/
/*3. 对要发送的数据进行校验,组包,返回数据*/ /*3. 对要发送的数据进行校验,组包,返回数据*/