From b8048ab60d50b05f620230797b4da2205d8c6a67 Mon Sep 17 00:00:00 2001 From: "CSSC-WORK\\murmur" Date: Fri, 1 Sep 2023 11:38:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20manual=20window=20?= =?UTF-8?q?=E9=A1=B9=EF=BC=8C=E6=84=8F=E5=A4=96=E9=87=8D=E5=90=AF=E5=90=8E?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------------- 报位置会死机,待排查 --- .config | 8 +++--- applications/cfg/cfg.c | 6 ++--- applications/core.c | 2 +- applications/func/func.c | 53 +++++++++++++++++++++++++++++++++++----- applications/log2file.c | 3 +-- rtconfig.h | 8 +++--- 6 files changed, 60 insertions(+), 20 deletions(-) diff --git a/.config b/.config index 381723f..a9a2a80 100644 --- a/.config +++ b/.config @@ -3,7 +3,7 @@ # # RT-Thread Kernel # -CONFIG_RT_NAME_MAX=8 +CONFIG_RT_NAME_MAX=30 # CONFIG_RT_USING_ARCH_DATA_TYPE is not set # CONFIG_RT_USING_SMP is not set CONFIG_RT_ALIGN_SIZE=4 @@ -20,7 +20,7 @@ CONFIG_RT_IDLE_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=512 CONFIG_RT_USING_TIMER_SOFT=y CONFIG_RT_TIMER_THREAD_PRIO=4 -CONFIG_RT_TIMER_THREAD_STACK_SIZE=512 +CONFIG_RT_TIMER_THREAD_STACK_SIZE=1024 # # kservice optimization @@ -328,9 +328,9 @@ CONFIG_ULOG_USING_ISR_LOG=y CONFIG_ULOG_ASSERT_ENABLE=y CONFIG_ULOG_LINE_BUF_SIZE=256 CONFIG_ULOG_USING_ASYNC_OUTPUT=y -CONFIG_ULOG_ASYNC_OUTPUT_BUF_SIZE=2048 +CONFIG_ULOG_ASYNC_OUTPUT_BUF_SIZE=10240 CONFIG_ULOG_ASYNC_OUTPUT_BY_THREAD=y -CONFIG_ULOG_ASYNC_OUTPUT_THREAD_STACK=2048 +CONFIG_ULOG_ASYNC_OUTPUT_THREAD_STACK=10240 CONFIG_ULOG_ASYNC_OUTPUT_THREAD_PRIORITY=29 # diff --git a/applications/cfg/cfg.c b/applications/cfg/cfg.c index 2a6c02b..2afc858 100644 --- a/applications/cfg/cfg.c +++ b/applications/cfg/cfg.c @@ -118,11 +118,11 @@ int get_cfg(const char *k) // int rst = ini_gets("config",k,"000000",buf,MAX_KEY_LEN,LJW_CFG_FILE_NAME); // if(strcmp(buf, "000000") == 0) { // // 采用默认值 - int rst = ini_getl("config", k, -1, LJW_CFG_FILE_NAME); - if (rst == -1) { + int rst = ini_getl("config", k, -3.14, LJW_CFG_FILE_NAME); + if (rst == -3.14) { LOG_W("no such KEY:%s",k); // clearLock(); - return -RT_ERROR; +// return -RT_ERROR; } else { // LOG_I("%s = %s",k,buf); diff --git a/applications/core.c b/applications/core.c index cdd0ecc..9d53dff 100644 --- a/applications/core.c +++ b/applications/core.c @@ -222,7 +222,7 @@ void sysInit(void) { sysSemInit(); // sysEventInit(); - if (isInWindowZone()) {//开机检查是否在开窗区间内,是则给TT开机 + if (isInWindowZone() || isManualWindow()) {//开机检查是否在开窗区间内,是则给TT开机 initTT(); setWindowMode(); } diff --git a/applications/func/func.c b/applications/func/func.c index 1ab6755..8b7b658 100644 --- a/applications/func/func.c +++ b/applications/func/func.c @@ -246,7 +246,7 @@ int upSend(uint8_t *din, size_t len) // return -RT_ERROR; // } /* 创建 serial 线程 */ - rt_thread_t thread = rt_thread_create("upSend", upSend_thread_entry, (void *) &msg, 1024 * 5, 27-1, 10); + rt_thread_t thread = rt_thread_create("upSend", upSend_thread_entry, (void *) &msg, 1024 * 5, 26, 10); /* 创建成功则启动线程 */ if (thread != RT_NULL) { @@ -375,15 +375,54 @@ void d_sw(void) } +/** + * 存储手动开窗状态,便于意外重启后恢复状态 + * @param isManualWindow 负数代表无,0代表手动开窗不自动关,整数代表自动关窗超时时间 + */ +void setManualWindow(uint8_t isManualWindow) +{ + set_cfg("isMaWin", isManualWindow); +} + + +void closeWindow(void); +/** + * 是否手动开窗状态 + * @return 1-手动开窗模式,0-无 + */ +int isManualWindow(void) +{ + int rst = get_cfg("isMaWin"); + if (rst < 0) {//none + return 0; + } + if (rst == 0) {//manual open without auto close + return 1; + } + //设置定时器,定时器到则关窗 + /* 创建定时器,单次定时器 */ + rt_timer_t timer1; + timer1 = rt_timer_create("window", closeWindow, + RT_NULL, rt_tick_from_millisecond(rst*60*1000), + RT_TIMER_FLAG_ONE_SHOT); + /* 启动定时器 */ + if (timer1 != RT_NULL) + { + rt_timer_start(timer1); + LOG_D("手动开窗完成,%d分钟后自动关窗。",rst); + } + return 1; +} + /** * 手动控制开窗 * @param t 开窗时长,单位分钟,时间到则自动关窗。t=0时需要手动关窗。 */ void openWindow(int t) { - + //保存记录 + setManualWindow(t); //开启TT -// pwTT_thread_entry("1");//开机 initTT(); setWindowMode(); //手动开窗优先级最高,自动开窗其次,高优先级会屏蔽低优先级 @@ -396,7 +435,7 @@ void openWindow(int t) //设置定时器,定时器到则关窗 /* 创建定时器,单次定时器 */ rt_timer_t timer1; - timer1 = rt_timer_create("window", deInitTT(), + timer1 = rt_timer_create("window", closeWindow, RT_NULL, rt_tick_from_millisecond(t*60*1000), RT_TIMER_FLAG_ONE_SHOT); /* 启动定时器 */ @@ -411,9 +450,11 @@ void openWindow(int t) /** * 手动关窗 */ -void closeWindow() +void closeWindow(void) { -// pwTT_thread_entry("0");//关 机 + setManualWindow(-1); +// 恢复RTC + startAlarm(); deInitTT(); LOG_D("手动关窗完成。"); } diff --git a/applications/log2file.c b/applications/log2file.c index ffb062c..500be32 100644 --- a/applications/log2file.c +++ b/applications/log2file.c @@ -36,7 +36,7 @@ typedef enum #define ROOT_PATH ROOT_PATH_DEBUG //设置保存路径 #define FILE_SIZE 10*1024 //设置单个文件大小 -#define BUFF_SIZE 1*1024 //设备缓存区大小 +#define BUFF_SIZE 10*1024 //设备缓存区大小 static struct ulog_backend sys_log_backend; static struct ulog_file_be sys_log_file; @@ -55,7 +55,6 @@ static struct _log_file table[] = * @retval None. * @note None. */ - void sys_log_file_backend_init(void) { static struct ulog_file_be *file_be = &sys_log_file; diff --git a/rtconfig.h b/rtconfig.h index 1183a60..c449ac1 100644 --- a/rtconfig.h +++ b/rtconfig.h @@ -18,7 +18,7 @@ #define IDLE_THREAD_STACK_SIZE 512 #define RT_USING_TIMER_SOFT #define RT_TIMER_THREAD_PRIO 4 -#define RT_TIMER_THREAD_STACK_SIZE 512*2 +#define RT_TIMER_THREAD_STACK_SIZE 1024 /* kservice optimization */ @@ -114,7 +114,7 @@ #define RT_USING_SDIO #define RT_SDIO_STACK_SIZE 5120 #define RT_SDIO_THREAD_PRIORITY 15 -#define RT_MMCSD_STACK_SIZE 10240 +#define RT_MMCSD_STACK_SIZE 1024 #define RT_MMCSD_THREAD_PREORITY 22 #define RT_MMCSD_MAX_PARTITION 16 #define RT_USING_SPI @@ -204,9 +204,9 @@ #define ULOG_ASSERT_ENABLE #define ULOG_LINE_BUF_SIZE 256 #define ULOG_USING_ASYNC_OUTPUT -#define ULOG_ASYNC_OUTPUT_BUF_SIZE 2048 +#define ULOG_ASYNC_OUTPUT_BUF_SIZE 10240 #define ULOG_ASYNC_OUTPUT_BY_THREAD -#define ULOG_ASYNC_OUTPUT_THREAD_STACK 2048 +#define ULOG_ASYNC_OUTPUT_THREAD_STACK 10240 #define ULOG_ASYNC_OUTPUT_THREAD_PRIORITY 29 /* log format */