diff --git a/applications/alarmer.c b/applications/alarmer.c index a9bde00..1b4aa92 100644 --- a/applications/alarmer.c +++ b/applications/alarmer.c @@ -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 } } diff --git a/applications/core.c b/applications/core.c index 5e4d98a..baf00f1 100644 --- a/applications/core.c +++ b/applications/core.c @@ -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; diff --git a/applications/func/func.c b/applications/func/func.c index 987c005..cc8fe02 100644 --- a/applications/func/func.c +++ b/applications/func/func.c @@ -1418,6 +1418,7 @@ void parseTTData(uint8_t *din, size_t len) if (rst) { LOG_W("帧头不匹配"); + parse3SData(din,len);//由于串口收数据会出现断帧的情况,这里统一改为不处理,异常数据直接透传 return; } diff --git a/applications/uart_3S.c b/applications/uart_3S.c index 89d2418..440178d 100644 --- a/applications/uart_3S.c +++ b/applications/uart_3S.c @@ -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); }