From 1a14d5b1932342c2d426d8c419448e45b14a0d5d Mon Sep 17 00:00:00 2001 From: "CSSC-WORK\\murmur" Date: Mon, 15 Jan 2024 18:27:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=BA5s=E4=B8=80=E5=8F=91?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E5=AF=B9232=E6=8E=A5=E6=94=B6=E6=96=AD?= =?UTF-8?q?=E5=B8=A7=E6=95=B0=E6=8D=AE=E7=9A=84=E5=A4=84=E7=90=86=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AF=B9=E4=B8=8D=E7=AC=A6=E5=90=88=E5=B8=A7?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=95=B0=E6=8D=AE=E7=9A=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=8C=E6=94=B9=E4=B8=BA=E9=80=8F=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/alarmer.c | 1 + applications/core.c | 4 ++-- applications/func/func.c | 1 + applications/uart_3S.c | 19 ++++++++++++++++++- 4 files changed, 22 insertions(+), 3 deletions(-) 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); }