添加看门狗

This commit is contained in:
murmur 2023-06-02 14:37:58 +08:00
parent e35670b6a9
commit de294e2c59
11 changed files with 82 additions and 105 deletions

22
.config
View File

@ -81,7 +81,7 @@ CONFIG_RT_USING_DEVICE=y
# CONFIG_RT_USING_INTERRUPT_INFO is not set
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=256
CONFIG_RT_CONSOLE_DEVICE_NAME="uart3"
CONFIG_RT_CONSOLE_DEVICE_NAME="uart1"
# end of Kernel Device Object
CONFIG_RT_VER_NUM=0x40101
@ -695,7 +695,25 @@ CONFIG_PKG_CMBACKTRACE_VER_NUM=0x10401
# CONFIG_PKG_USING_THREAD_POOL is not set
# CONFIG_PKG_USING_ROBOTS is not set
# CONFIG_PKG_USING_EV is not set
# CONFIG_PKG_USING_SYSWATCH is not set
CONFIG_PKG_USING_SYSWATCH=y
CONFIG_PKG_SYSWATCH_PATH="/packages/system/syswatch"
# CONFIG_SYSWATCH_USING_TEST is not set
# CONFIG_SYSWATCH_EXCEPT_RESOLVE_MODE_0 is not set
# CONFIG_SYSWATCH_EXCEPT_RESOLVE_MODE_1 is not set
CONFIG_SYSWATCH_EXCEPT_RESOLVE_MODE_2=y
CONFIG_SYSWATCH_EXCEPT_RESOLVE_MODE=2
CONFIG_SYSWATCH_EXCEPT_TIMEOUT=60
CONFIG_SYSWATCH_EXCEPT_CONFIRM_TMO=15
CONFIG_SYSWATCH_EXCEPT_RESUME_DLY=15
CONFIG_SYSWATCH_THREAD_PRIO=0
CONFIG_SYSWATCH_THREAD_STK_SIZE=512
CONFIG_SYSWATCH_THREAD_NAME="syswatch"
CONFIG_SYSWATCH_WDT_NAME="wdt"
CONFIG_SYSWATCH_WDT_TIMEOUT=5
CONFIG_PKG_USING_SYSWATCH_LATEST_VERSION=y
# CONFIG_PKG_USING_SYSWATCH_V101 is not set
# CONFIG_PKG_USING_SYSWATCH_V100 is not set
CONFIG_PKG_SYSWATCH_VER="latest"
# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set
# CONFIG_PKG_USING_PLCCORE is not set
# CONFIG_PKG_USING_RAMDISK is not set

View File

@ -27,7 +27,7 @@ struct rt_event hw_check;//硬件条件
static int maxTTWaitTime = 4;
static int maxTTRetryCnt = 3;
static init()
static initEvent(void)
{
/* 事 件 控 制 块 */
@ -37,6 +37,7 @@ static init()
LOG_E("init event failed.\n");
}
}
INIT_COMPONENT_EXPORT(initEvent);
/**
*
@ -46,6 +47,18 @@ static void updatecfg()
maxTTWaitTime = get_cfg("maxTTWaitTime");
maxTTRetryCnt = get_cfg("maxTTRetryCnt");
}
extern struct rt_event update_cfg;
void t3(void)
{
int32_t e;
int rst = rt_event_recv(&update_cfg, CFGCHANGEED, RT_EVENT_FLAG_OR , RT_WAITING_FOREVER, &e);
if (rst == RT_EOK) {
// update_cfg();
LOG_I("ggxb");
}
}
//INIT_COMPONENT_EXPORT(t3);
/**
* TT状态1TT连续5个周期为激活状态且信号强度不低于5

View File

@ -57,8 +57,8 @@ int set_cfg(const char *k, const char*v)
rt_err_t result;
// rt_event_send(&update_cfg, CFGCHANGEED|COMPRESSTYPE);
// rt_event_send(&update_cfg, CFGCHANGEED|MAXSIZEPERFILE);
rt_event_send(&update_cfg, CFGCHANGEED|COMPRESSTYPE);
rt_event_send(&update_cfg, CFGCHANGEED|MAXSIZEPERFILE);
}
else {

View File

@ -36,6 +36,10 @@
//#include <dfs_posix.h>
#include <dfs_file.h>
#define LOG_TAG "comc"
#define LOG_LVL LOG_LVL_DBG
#include <ulog.h>
#include "fastlz.h"
#define malloc rt_malloc
@ -114,6 +118,7 @@ int fastlz_compress_file(const char *fin, const char *fout)
cmprs_size = fastlz_compress_level(FASTLZ_COMPRESS_LEVEL, buffer, block_size, (char *) cmprs_buffer);
if (cmprs_size < 0)
{
LOG_E("error.");
ret = -1;
goto _exit;
}

View File

@ -8,69 +8,37 @@
* 2023-06-01 murmur the first version
*/
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-08-24 yangjie the first version
*/
/*
*
*
* 线
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <rthw.h>
#define THREAD_PRIORITY 20
#define THREAD_STACK_SIZE 1024
#define THREAD_TIMESLICE 5
/* 指向线程控制块的指针 */
static rt_thread_t tid = RT_NULL;
/* 空闲函数钩子函数执行次数 */
volatile static int hook_times = 0;
int t=0;
extern rt_device_t wdg_dev; /* 看门狗设备句柄 */
/* 空闲任务钩子函数 */
static void idle_hook()
{
// if (0 == (hook_times % 10000))
//
// {
@ -78,32 +46,21 @@ static void idle_hook()
// rt_kprintf("enter idle hook %d times.\n", hook_times);
//
// }
rt_thread_mdelay(1000);
rt_device_control(wdg_dev, RT_DEVICE_CTRL_WDT_GET_TIMEOUT, &t);
rt_kprintf("---%d\n", t);
// rt_thread_mdelay(1000);
// rt_enter_critical();
//
// hook_times++;
//
// rt_exit_critical();
}
/* 线程入口 */
static void thread_entry(void *parameter)
{
int i = 5;
// while (1)
while (i--)
//
// {
{
// rt_kprintf("enter thread1.\n");
//
// rt_enter_critical();
@ -112,63 +69,34 @@ static void thread_entry(void *parameter)
//
// rt_exit_critical();
/* 休眠500ms */
// rt_kprintf("thread1 delay 50 OS Tick.\n", hook_times);
//
// rt_thread_mdelay(500);
rt_thread_mdelay(500);
//
// }
}
// rt_kprintf("delete idle hook.\n");
/* 删除空闲钩子函数 */
// rt_thread_idle_delhook(idle_hook);
// rt_kprintf("thread1 finish.\n");
rt_thread_idle_delhook(idle_hook);
rt_kprintf("thread1 finish.\n");
}
int idle_hook_sample(void)
{
/* 设置空闲线程钩子 */
rt_thread_idle_sethook(idle_hook);
/* 创建线程 */
tid = rt_thread_create("thread1",
thread_entry, RT_NULL,
THREAD_STACK_SIZE,
THREAD_PRIORITY, THREAD_TIMESLICE);
if (tid != RT_NULL)
rt_thread_startup(tid);
return 0;
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT(idle_hook_sample, idle hook sample);

View File

@ -45,7 +45,7 @@ void pfdemo(void)
}
extern rt_device_t wdg_dev;
int main(void)
{

View File

@ -62,27 +62,21 @@ static void serial_thread_entry(void *parameter)
rt_uint32_t rx_length;
static char rx_buffer[RT_SERIAL_RB_BUFSZ + 1];
// extern struct rt_messagequeue update_cfg;
// extern struct rt_event update_cfg;
extern struct rt_event update_cfg;
// CFG_MSG cfg;
while (1)
{
// rt_memset(&cfg, 0, sizeof(cfg));
rt_memset(&msg, 0, sizeof(msg));
/* 从消息队列中读取消息*/
// rt_err_t result = rt_mq_recv(&update_cfg, &cfg, sizeof(cfg), RT_WAITING_NO);
//
// if (result == RT_EOK)
// {
// LOG_I("updatecfg:%10s -->%s", cfg.key, cfg.value);
// }
// rt_uint32_t e;
// rt_err_t result = rt_event_recv(&update_cfg, CFGCHANGEED|MAXSIZEPERFILE, RT_EVENT_FLAG_OR|RT_EVENT_FLAG_CLEAR, RT_WAITING_NO, &e);
// if (result == RT_EOK)
// {
// LOG_I("updatecfg");
// }
result = rt_mq_recv(&rx_mq, &msg, sizeof(msg), RT_WAITING_FOREVER);
rt_uint32_t e;
rt_err_t result = rt_event_recv(&update_cfg, CFGCHANGEED|MAXSIZEPERFILE, RT_EVENT_FLAG_OR|RT_EVENT_FLAG_CLEAR, RT_WAITING_NO, &e);
if (result == RT_EOK)
{
LOG_I("updatecfg");
}
result = rt_mq_recv(&rx_mq, &msg, sizeof(msg), RT_WAITING_NO);
if (result == RT_EOK)
{
/* 从串口读取数据*/
@ -109,7 +103,7 @@ static void serial_thread_entry(void *parameter)
rt_kprintf("%s\n",rx_buffer);
}
else {
LOG_D("no data reced.");
// LOG_D("no data reced.");
}
rt_thread_mdelay(100);
@ -155,7 +149,7 @@ static int uart_dma_sample(int argc, char *argv[])
rt_device_write(serial, 0, str, (sizeof(str) - 1));
/* 创建 serial 线程 */
rt_thread_t thread = rt_thread_create("serial", serial_thread_entry, RT_NULL, 1024*10, 25+1, 10);
rt_thread_t thread = rt_thread_create("serial", serial_thread_entry, RT_NULL, 1024*1, 25+1, 10);
/* 创建成功则启动线程 */
if (thread != RT_NULL)
{

View File

@ -10,6 +10,8 @@
#ifndef APPLICATIONS_USRCFG_H_
#define APPLICATIONS_USRCFG_H_
#define WORK_BOARD
#define FILE_IS_OK 1
#define TIMER_IS_OUT 1<<1
#define TT_IS_OK 1<<2

View File

@ -13,7 +13,7 @@
#include <stm32f4xx.h>
#include <drv_common.h>
#include <usrcfg.h>
#ifdef __cplusplus
extern "C"

View File

@ -14,6 +14,11 @@
"ver": "v1.4.1",
"name": "CMBACKTRACE"
},
{
"path": "/packages/system/syswatch",
"ver": "latest",
"name": "SYSWATCH"
},
{
"path": "/packages/system/minIni",
"ver": "v1.2.0",

View File

@ -15,7 +15,7 @@
#define RT_HOOK_USING_FUNC_PTR
#define RT_USING_IDLE_HOOK
#define RT_IDLE_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 256*4
#define IDLE_THREAD_STACK_SIZE 256
#define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512
@ -62,7 +62,7 @@
#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
#define RT_MAIN_THREAD_STACK_SIZE 2048*2
#define RT_MAIN_THREAD_PRIORITY 10
#define RT_USING_MSH
#define RT_USING_FINSH
@ -294,6 +294,18 @@
/* Micrium: Micrium software products porting for RT-Thread */
/* end of Micrium: Micrium software products porting for RT-Thread */
#define PKG_USING_SYSWATCH
#define SYSWATCH_EXCEPT_RESOLVE_MODE_2
#define SYSWATCH_EXCEPT_RESOLVE_MODE 2
#define SYSWATCH_EXCEPT_TIMEOUT 60
#define SYSWATCH_EXCEPT_CONFIRM_TMO 15
#define SYSWATCH_EXCEPT_RESUME_DLY 15
#define SYSWATCH_THREAD_PRIO 0
#define SYSWATCH_THREAD_STK_SIZE 512*2
#define SYSWATCH_THREAD_NAME "syswatch"
#define SYSWATCH_WDT_NAME "wdt"
#define SYSWATCH_WDT_TIMEOUT 5
#define PKG_USING_SYSWATCH_LATEST_VERSION
#define PKG_USING_MININI
#define PKG_USING_MININI_V120
/* end of system packages */
@ -370,7 +382,7 @@
/* end of RT-Thread online packages */
/* samples: kernel and components samples */
#define WORK_BOARD
/* end of samples: kernel and components samples */
#define RT_STUDIO_BUILT_IN