添加每2小时在idle状态下重启的功能

This commit is contained in:
CSSC-WORK\murmur 2024-01-07 20:21:31 +08:00
parent d27ad95916
commit 5d67920a44
3 changed files with 33 additions and 4 deletions

View File

@ -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()

View File

@ -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;

View File

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