From 5d67920a44907a9f56a4d8f93dd48f7cebe1f1de Mon Sep 17 00:00:00 2001 From: "CSSC-WORK\\murmur" Date: Sun, 7 Jan 2024 20:21:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=AF=8F2=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E5=9C=A8idle=E7=8A=B6=E6=80=81=E4=B8=8B=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/alarmer.c | 15 ++++++++++++++- applications/core.c | 11 +++++++++++ applications/uart_3S.c | 11 ++++++++--- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/applications/alarmer.c b/applications/alarmer.c index 7308797..a9bde00 100644 --- a/applications/alarmer.c +++ b/applications/alarmer.c @@ -100,6 +100,8 @@ void poTT2_callback(rt_alarm_t alarm, time_t timestamp) // timerIsReady(); // initTT(); } + +static uint8_t rstCnt=0; /** * 定时更新debug文件名 * @param alarm @@ -107,7 +109,18 @@ void poTT2_callback(rt_alarm_t alarm, time_t timestamp) */ void updatelog_callback(rt_alarm_t alarm, time_t timestamp) { - updateDebuglogName(); + //idle且TT未开启状态下主动重启 + if (++rstCnt >= 2)//每N小时一检 + { + rstCnt = 0; + if (isIdle()) + { + rt_hw_cpu_reset(); //reboot + } + } + else { + updateDebuglogName(); + } } void addDefaultAlarm() diff --git a/applications/core.c b/applications/core.c index 593e67b..b6bfca5 100644 --- a/applications/core.c +++ b/applications/core.c @@ -41,6 +41,17 @@ static rt_thread_t deinitThread=RT_NULL; static rt_timer_t tmrToPNTT=RT_NULL; static uint8_t isWindowMode=0;//RTC引起TT开机 static uint8_t isFileMode=0;//file is ok + +//是否为idle状态。idle状态下TT未开启,232无数据 +uint8_t isIdle(void) +{ + if (!isTCPok() && !isEthUP() &&!isFileMode && !isWindowMode && !isManualWindow() && !is232Busy()) { + return 1; + } + else { + return 0; + } +} uint8_t isInFileMode(void) { return isFileMode; diff --git a/applications/uart_3S.c b/applications/uart_3S.c index abd2c98..89d2418 100644 --- a/applications/uart_3S.c +++ b/applications/uart_3S.c @@ -78,21 +78,26 @@ static rt_err_t uart_input(rt_device_t dev, rt_size_t size) struct rx_msg msg; //extern struct rt_event update_cfg; //extern int time2Str(char *str); - +static uint8_t is232parsing=0; +uint8_t is232Busy(void) +{ + return rx_mq.entry | is232parsing; +} static void serial_thread_entry(void *parameter) { // struct rx_msg msg; rt_err_t result; 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 while (1) { rt_memset(&msg, 0, sizeof(msg)); /* 从消息队列中读取消息*/ - + is232parsing=0; result = rt_mq_recv(&rx_mq, &msg, sizeof(msg), RT_WAITING_FOREVER); - + is232parsing=1; if (result == RT_EOK) { /* 从串口读取数据*/