更新为5s一发
添加对232接收断帧数据的处理 更新对不符合帧格式数据的处理方式,改为透传
This commit is contained in:
parent
dad783ca47
commit
1a14d5b193
@ -115,6 +115,7 @@ void updatelog_callback(rt_alarm_t alarm, time_t timestamp)
|
||||
rstCnt = 0;
|
||||
if (isIdle())
|
||||
{
|
||||
LOG_W("--------------------reboot in 1 sec.--------------------");
|
||||
rt_hw_cpu_reset(); //reboot
|
||||
}
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ static void upSendFile_thread_entry(void *parameter)
|
||||
issendall=0;
|
||||
// break;
|
||||
}
|
||||
rt_thread_mdelay(3000);//发送间隔,目前服务器未处理,暂设为3s避免粘包
|
||||
rt_thread_mdelay(5000);//发送间隔,目前服务器未处理,暂设为3s避免粘包
|
||||
}
|
||||
}
|
||||
if (issendall) {
|
||||
@ -629,7 +629,7 @@ static void chkAndSendFile_thread_entry()
|
||||
if (isTTok)
|
||||
{
|
||||
isTTok=0;
|
||||
rt_thread_mdelay(3000);
|
||||
rt_thread_mdelay(15000);
|
||||
getAndSendFile();
|
||||
flag=1;
|
||||
break;
|
||||
|
@ -1418,6 +1418,7 @@ void parseTTData(uint8_t *din, size_t len)
|
||||
if (rst)
|
||||
{
|
||||
LOG_W("帧头不匹配");
|
||||
parse3SData(din,len);//由于串口收数据会出现断帧的情况,这里统一改为不处理,异常数据直接透传
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,7 @@ static void serial_thread_entry(void *parameter)
|
||||
size_t rx_length=0;//单次收到的数据长度
|
||||
static char rx_buffer[RT_SERIAL_RB_BUFSZ + 1];
|
||||
memset(rx_buffer,0,RT_SERIAL_RB_BUFSZ + 1);//清空rx_buffer
|
||||
static uint8_t p=0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
@ -101,12 +102,28 @@ static void serial_thread_entry(void *parameter)
|
||||
if (result == RT_EOK)
|
||||
{
|
||||
/* 从串口读取数据*/
|
||||
rx_length = rt_device_read(msg.dev, 0, rx_buffer, msg.size);
|
||||
rx_length = rt_device_read(msg.dev, 0, rx_buffer+p, msg.size);
|
||||
if (!rx_length) {
|
||||
// LOG_W("read from RS232 error,should be %d Bytes",msg.size);
|
||||
continue;
|
||||
}
|
||||
LOG_I("%d Bytes received from RS232",rx_length);
|
||||
|
||||
//对于断帧数据的处理
|
||||
if (rx_buffer[p+rx_length-1] != 0xed) {
|
||||
p=p+rx_length;
|
||||
if (p > 120*5) {//不死等
|
||||
rx_length = p + rx_length;
|
||||
p=0;
|
||||
parseRS232(rx_buffer, rx_length);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
rx_length = p + rx_length;
|
||||
p=0;
|
||||
}
|
||||
|
||||
// LOG_HEX("232rx:",16,rx_buffer,rx_length);//print what received.
|
||||
parseRS232(rx_buffer, rx_length);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user