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) { /* 从串口读取数据*/