撤销重发机制以及验证seq机制
This commit is contained in:
@@ -153,7 +153,7 @@ int resend_recv_data(resend_device_t *resend_device, int timeout)
|
|||||||
{
|
{
|
||||||
if(!resend_decode(resend_device, data[ret - ret_later - 1]))
|
if(!resend_decode(resend_device, data[ret - ret_later - 1]))
|
||||||
{
|
{
|
||||||
printf("tx_req %d rx_req %d retry_cnt %d cmd %d\r\n", resend_device->tx_frame.seq, resend_device->rx_frame.seq, resend_device->rx_frame.retry_cnt, resend_device->rx_frame.cmd);
|
// printf("tx_req %d rx_req %d retry_cnt %d cmd %d\r\n", resend_device->tx_frame.seq, resend_device->rx_frame.seq, resend_device->rx_frame.retry_cnt, resend_device->rx_frame.cmd);
|
||||||
|
|
||||||
if(seq_lat == resend_device->rx_frame.seq){
|
if(seq_lat == resend_device->rx_frame.seq){
|
||||||
resend_device->status.resend_flag = 1;
|
resend_device->status.resend_flag = 1;
|
||||||
@@ -221,12 +221,14 @@ int resend_send_data(resend_device_t *resend_device, uint8_t cmd, void* data, ui
|
|||||||
os_thread_sleep(1);
|
os_thread_sleep(1);
|
||||||
}
|
}
|
||||||
// 超过允许的等待次数
|
// 超过允许的等待次数
|
||||||
if(resend_device->tx_frame.retry_cnt > RESEND_MAX_RETRY_CNT)
|
if(resend_device->tx_frame.retry_cnt > RESEND_MAX_RETRY_CNT && resend_device->status.ack_flag)
|
||||||
{
|
{
|
||||||
printf("timeout cnt max\n");
|
printf("timeout cnt max\n");
|
||||||
resend_device->tx_frame.retry_cnt = 0;
|
resend_device->tx_frame.retry_cnt = 0;
|
||||||
resend_device->status.ack_flag = 0;
|
resend_device->status.ack_flag = 0;
|
||||||
return -1;
|
return -1;
|
||||||
|
} else if(!resend_device->status.ack_flag){
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,14 +256,14 @@ int resend_parse_data(resend_device_t *resend_device)
|
|||||||
case RESEND_CMD_SET_PARAM:
|
case RESEND_CMD_SET_PARAM:
|
||||||
break;
|
break;
|
||||||
case RESEND_CMD_DATA_ACK:
|
case RESEND_CMD_DATA_ACK:
|
||||||
for (size_t i = 0; i < resend_device->rx_frame.len; i++)
|
|
||||||
{
|
|
||||||
printf("%02X ", resend_device->rx_frame.payload[i]);
|
|
||||||
}
|
|
||||||
printf("\r\n");
|
|
||||||
resend_send_cmd(resend_device, RESEND_CMD_ACK, 0);
|
resend_send_cmd(resend_device, RESEND_CMD_ACK, 0);
|
||||||
break;
|
break;
|
||||||
|
case RESEND_CMD_OTA_GET_PARAM:
|
||||||
|
//针对OTA的应答
|
||||||
|
resend_device->status.ack_flag = 0;
|
||||||
|
break;
|
||||||
case RESEND_CMD_OTA_START:
|
case RESEND_CMD_OTA_START:
|
||||||
|
resend_device->handle_flag = RESEND_CMD_OTA_GET_PARAM;
|
||||||
break;
|
break;
|
||||||
case RESEND_CMD_OTA_DATA:
|
case RESEND_CMD_OTA_DATA:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#define RESEND_HEADER_0 0xFD
|
#define RESEND_HEADER_0 0xFD
|
||||||
#define RESEND_HEADER_1 0xFE
|
#define RESEND_HEADER_1 0xFE
|
||||||
|
|
||||||
#define RESEND_MAX_RETRY_CNT 5
|
#define RESEND_MAX_RETRY_CNT 0
|
||||||
// 命令类型
|
// 命令类型
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@@ -34,6 +34,7 @@ typedef enum
|
|||||||
|
|
||||||
RESEND_CMD_DATA_ACK = 0x06,
|
RESEND_CMD_DATA_ACK = 0x06,
|
||||||
|
|
||||||
|
RESEND_CMD_OTA_GET_PARAM = 0x010,
|
||||||
RESEND_CMD_OTA_START = 0x011,
|
RESEND_CMD_OTA_START = 0x011,
|
||||||
RESEND_CMD_OTA_DATA = 0x012,
|
RESEND_CMD_OTA_DATA = 0x012,
|
||||||
RESEND_CMD_OTA_END = 0x013
|
RESEND_CMD_OTA_END = 0x013
|
||||||
|
|||||||
Reference in New Issue
Block a user