Commit e9f5f19a authored by 李冠华's avatar 李冠华

feat:增加多次无请求未收到响应时,清理一下UARTRxBuf.Rx_Buffer功能

parent e6477b48
......@@ -16,6 +16,7 @@ uint8_t StopFlag = 0U;
uint32_t RS485TXBenCiXieRuNum = 0u;
uint32_t RS485TXTotalExecutionNum = 0u;
uint8_t RerequestCount = 0U;
uint8_t UARTRxBufClean = 0u;
static void NVS_Test_BenCiXieRuNum(void);
static void NVS_Test_Rerequest(void);
......@@ -37,6 +38,7 @@ void NVS_Test_Init(void)
RS485TXBenCiXieRuNum = 0u;
RS485TXTotalExecutionNum = 0u;
RerequestCount = 0U;
UARTRxBufClean = 0U;
}
void NVS_Test_Service(void)
......@@ -66,6 +68,7 @@ void NVS_Test_Service(void)
{
huifudelayCount = 0u;
UARTRxBufClean = 0U;
if (TotalExecutionNum != 0U)
{
if(JieShouDaoValue != LastNum)
......@@ -112,6 +115,15 @@ void NVS_Test_Service(void)
{
if (huifudelayCount > 400u)
{
if (UARTRxBufClean < 3u)
{
UARTRxBufClean ++;
}
else
{
RS485_UARTRxBuf_Clean();
UARTRxBufClean = 0U;
}
/*超过了8s没有回复,请求重发*/
NVS_Test_Rerequest();
huifudelayCount = 0;
......
......@@ -7,6 +7,7 @@
#include "Check_Ctrl.h"
#include "Barcode_Scanner.h"
#include "Task.h"
#include "RS485_Protocol_User.h"
#define DUAN_DIAN_STATE 1 /*0--只控制13.5V电,1--控制所有电*/
......
......@@ -218,7 +218,15 @@ void RS485_UART_Put(Protocol_uint16_t Data)
//return;
}
void RS485_UARTRxBuf_Clean(void)
{
for (uint16_t i = 0u; i < UART_RX_MAX_DEPTH; i ++)
{
UARTRxBuf.Rx_Buffer[i] = 0U;
}
UARTRxBuf.read_pos = 0U;
UARTRxBuf.write_pos = 0U;
}
......
......@@ -6,4 +6,6 @@
void RS485_Protocol_KL30_Wakeup_Init(void);
void RS485_RS485_Protocol_Send_Service(void); // 10ms任务调用
void RS485_UART_Put(Protocol_uint16_t Data);
extern void RS485_UARTRxBuf_Clean(void);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment