From 9b76e1fbe8ea4f947383fdbf05ab3db72ba3a8a4 Mon Sep 17 00:00:00 2001 From: murmur Date: Thu, 1 Jun 2023 17:10:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=81=E7=A8=8B=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20=E6=B7=BB=E5=8A=A0=E4=B8=BB=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=87=BD=E6=95=B0=20=E5=BE=85=E5=AE=8C=E5=96=84ttgetinfo=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/_main.c | 98 +++++++++++++++++++ applications/cfg.c | 93 +++++++++++++++--- applications/cfg.h | 10 ++ applications/getinfo.c | 47 +++++---- applications/idle.c | 174 +++++++++++++++++++++++++++++++++ applications/iwdg_sample.c | 6 +- applications/timer.c | 143 +++++++++++++++++++++++++++ applications/ttmsg/ttmsg.c | 5 +- applications/ttmsg/ttmsg.h | 2 + applications/uart_dma_sample.c | 26 +++-- applications/流程.md | 9 ++ applications/软件工作流程.md | 13 ++- rtconfig.h | 2 +- 13 files changed, 574 insertions(+), 54 deletions(-) create mode 100644 applications/_main.c create mode 100644 applications/idle.c create mode 100644 applications/timer.c create mode 100644 applications/流程.md diff --git a/applications/_main.c b/applications/_main.c new file mode 100644 index 0000000..3b52a45 --- /dev/null +++ b/applications/_main.c @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2023-06-01 murmur the first version + */ + + +#include + +#define LOG_TAG "main_scha" +#define LOG_LVL LOG_LVL_DBG +#include +#include +#include +#include + +struct rt_event sw_check;//软件条件 +struct rt_event hw_check;//硬件条件 +#define FILE_IS_OK 1 +#define TIMER_IS_OUT 1<<1 +#define TT_IS_OK 1<<2 + +static maxWaitTime = 4; +static maxRetryCnt = 3; + +static init() +{ + /* 事 件 控 制 块 */ + + rt_err_t result = rt_event_init(&sw_check, "SHcheck", RT_IPC_FLAG_FIFO); + if (result != RT_EOK) + { + LOG_E("init event failed.\n"); + } +} + +/** + * 更新各参数 + */ +static void updatecfg() +{ + maxWaitTime = get_cfg("maxWaitTime"); + maxRetryCnt = get_cfg("maxRetryCnt"); +} + +/** + * 监控TT状态。需求条件1:TT连续5个周期为激活状态且信号强度不低于5。 + */ +void checkTT() +{ + //上电 + pwTT_thread_entry("1"); +// rt_thread_create(name, entry, parameter, stack_size, priority, tick) + getTT(); +// getTTinfo_thread_entry() +} + +void try() +{ + static rt_err_t rst = RT_ERROR; + updatecfg(); + while(1) + { + int e; + rst = rt_event_recv(&sw_check, FILE_IS_OK | TIMER_IS_OUT, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, + RT_WAITING_FOREVER, &e); + if (rst == RT_EOK) + { + //上电 + pwTT_thread_entry("1"); + } + + for (size_t var = 0; var < maxRetryCnt; ++var) + { + rst = rt_event_recv(&sw_check, TT_IS_OK, RT_EVENT_FLAG_CLEAR, rt_tick_from_millisecond(maxWaitTime * 1000), + &e); + if (rst == RT_ETIMEOUT) + { + pwTT_thread_entry("0"); + rt_thread_mdelay(1000); + pwTT_thread_entry("1"); + } + else if (rst == RT_EOK) + { + break; + } + else + { + LOG_E("Unknown error."); + } + } + + } +} diff --git a/applications/cfg.c b/applications/cfg.c index b103301..7a33750 100644 --- a/applications/cfg.c +++ b/applications/cfg.c @@ -69,26 +69,30 @@ int set_cfg(const char *k, const char*v) int get_cfg(const char *k) { - char buf[16]; - int rst = ini_gets("config",k,"000000",buf,16,LJW_CFG_FILE_NAME); - if(strcmp(buf, "000000") == 0) { - // 采用默认值 +// char buf[MAX_KEY_LEN]; +// 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) { LOG_W("no such KEY:%s",k); + return -RT_ERROR; } else { - LOG_I("%s = %s",k,buf); +// LOG_I("%s = %s",k,buf); + LOG_I("%s = %d",k,rst); } return rst; } void get_cfg_all(void) { - char buf[16]; - char kstr[16]; + char buf[MAX_KEY_LEN]; + char kstr[MAX_KEY_LEN]; LOG_I("%23s","---CONFIG---"); - for (size_t k = 0; ini_getkey("config", k, kstr, 16, LJW_CFG_FILE_NAME) > 0; k++) { - int rst = ini_gets("config",kstr,"000000",buf,16,LJW_CFG_FILE_NAME); + for (size_t k = 0; ini_getkey("config", k, kstr, MAX_KEY_LEN, LJW_CFG_FILE_NAME) > 0; k++) { + int rst = ini_gets("config",kstr,"000000",buf,MAX_KEY_LEN,LJW_CFG_FILE_NAME); LOG_I("%16s = %s",kstr,buf); } @@ -112,11 +116,11 @@ void cfg(int argc, char ** argv) static void get_sta_all(void) { - char buf[16]; - char kstr[16]; + char buf[MAX_KEY_LEN]; + char kstr[MAX_KEY_LEN]; LOG_I("%23s","---STATS---"); - for (size_t k = 0; ini_getkey("stats", k, kstr, 16, LJW_CFG_FILE_NAME) > 0; k++) { - int rst = ini_gets("stats",kstr,"000000",buf,16,LJW_CFG_FILE_NAME); + for (size_t k = 0; ini_getkey("stats", k, kstr, MAX_KEY_LEN, LJW_CFG_FILE_NAME) > 0; k++) { + int rst = ini_gets("stats",kstr,"000000",buf,MAX_KEY_LEN,LJW_CFG_FILE_NAME); LOG_I("%16s = %s",kstr,buf); } } @@ -205,5 +209,68 @@ static void clear_sta(void) MSH_CMD_EXPORT_ALIAS(clear_sta,clsSta, 重置系统统计数据) +/** + * 添加文件到待发列表,指定待发包 + * @param f + * @param v + * @return + */ +int setFileToSend(const char *f, int v) +{ + int rst = ini_putl(SECTION_TO_SEND, f, v, LJW_CFG_FILE_NAME); + if (!rst) { + LOG_E("add file to send error."); + } + return rst; +} +/** + * 获取待发送文件列表 + * @param kstr 文件名 + * @param v 对应包,默认为0即全发 + * @return 文件个数 + */ +int getFilesToSend(char (*kstr)[MAX_KEY_LEN], int *v) +{ +// char buf[MAX_KEY_LEN]; +// char kstr[MAX_KEY_LEN]; + size_t len=0; + for (size_t k = 0; ini_getkey(SECTION_TO_SEND, k, kstr[len], MAX_KEY_LEN, LJW_CFG_FILE_NAME) > 0; k++) { + v[len] = ini_getl(SECTION_TO_SEND, kstr[len], -1, LJW_CFG_FILE_NAME); + len +=1; + } + return len; +} +/** + * 清空待发送文件记录 + */ +int clearFileToSend(const char *k) +{ + int rst = ini_puts(SECTION_TO_SEND, k, NULL, LJW_CFG_FILE_NAME); + if (!rst) { + LOG_E("clear file to send error."); + } + return rst; +} + +void gf() +{ + int v[MAX_KEY_LEN]; + char kstr[10][MAX_KEY_LEN]; + size_t cnt = getFilesToSend(kstr, v); + for (size_t var = 0; var < cnt; ++var) { + LOG_I("%s -- %d",kstr[var],v[var]); + } +} +void add(int argc, char **argv) +{ + setFileToSend(argv[1],atoi(argv[2])); + gf(); + clearFileToSend(argv[1]); + gf(); +} + +MSH_CMD_EXPORT(gf, 查看待发送文件列表) +MSH_CMD_EXPORT_ALIAS(add, cf,查看待发送文件列表) + //set_if() #endif diff --git a/applications/cfg.h b/applications/cfg.h index 6a5c891..b13ade7 100644 --- a/applications/cfg.h +++ b/applications/cfg.h @@ -22,6 +22,16 @@ typedef struct #define COMPRESSTYPE 1<<3 #define ENCRYTTYPE 1<<4 + +#define MAX_KEY_LEN 30 +#define SECTION_TO_SEND "tosend" + + + int get_cfg(const char *k); int set_cfg(const char *k, const char*v); int add_val(const char *k); + +int setFileToSend(const char *f, int v); +int getFilesToSend(char (*kstr)[MAX_KEY_LEN], int *v); +int clearFileToSend(const char *k); diff --git a/applications/getinfo.c b/applications/getinfo.c index 4b0a959..8d84ae4 100644 --- a/applications/getinfo.c +++ b/applications/getinfo.c @@ -1,3 +1,7 @@ + + + + #include //#include <../packages/webclient-v2.2.0/inc/webclient.h> #include @@ -16,12 +20,13 @@ #define TT_JH TT_IP "/action/webGetPSState"//激活 #define TT_DW TT_IP "/action/webGetBDGPS"//定位 //http://192.168.0.232:4005/action/webGetSIMState webGetBDGPS +#define MAX_LEN 15 #include #include -#include -#include //用于strtod函数 -#include +//#include +//#include //用于strtod函数 +//#include char *infoH[] = { TT_SIM, TT_XH, TT_RW, TT_JH, TT_DW}; typedef struct @@ -32,7 +37,7 @@ typedef struct typedef struct { - rt_uint8_t sim; // SIM + char sim[MAX_LEN]; // SIM rt_uint8_t xh; // 信号值 rt_uint8_t rw; // 入网 rt_uint8_t jh; // 激活 @@ -40,8 +45,12 @@ typedef struct char *wd; // 纬度 char *ele; // 高度 } TT; + static TT tmp; static TT *TTinfo=&tmp; + +//rt_memset(&tmp,0,sizeof(TT)); +//TTinfo = rt_malloc(sizeof(TT)); /** * @description: 将TT结构体转换为数组 * @param {TT} *TTinfo TT结构体 @@ -89,8 +98,6 @@ static void tt_parse(rt_uint8_t *data) { extern TT *TTinfo; cJSON *root = RT_NULL, *object = RT_NULL, *item = RT_NULL; -// rt_kprintf("%5s%5s%5s%5s%15s%15s%10s\n", TTinfo->sim, TTinfo->xh, TTinfo->rw, -// TTinfo->jh, TTinfo->jd, TTinfo->wd,TTinfo->ele); root = cJSON_Parse((const char *) data); if (!root) @@ -151,9 +158,9 @@ static void tt_parse(rt_uint8_t *data) item = cJSON_GetObjectItem(object, "tdsimstate"); if (item) { - TTinfo->sim = atoi(item->valuestring); +// TTinfo->sim = atoi(item->valuestring); // tmp.sim = item->valuestring; -// strcpy(TTinfo.sim,item->valuestring) + strcpy(TTinfo->sim,item->valuestring); // rt_kprintf("\nSIM:%s \n", TTinfo->sim); cJSON_Delete(root); return RT_EOK; @@ -166,7 +173,7 @@ static void tt_parse(rt_uint8_t *data) /* HTTP client download data by GET request */ static int webclient_get_data(const char *url) { - unsigned char *buffer = RT_NULL; + static unsigned char *buffer = RT_NULL; size_t length = 0; if (webclient_request(url, RT_NULL, RT_NULL, 0, (void **) &buffer, &length) < 0) @@ -198,29 +205,27 @@ void getTTinfo_thread_entry(void* parameter) isize = sizeof(infoH) / sizeof(infoH[0]); rt_kprintf("\n%10s%s\n", " ", "↓---------getTT START.--------↓"); rt_kprintf("%5s%5s%5s%5s%15s%15s%10s\n", "SIM", "xh", "rw", "jh", "N", "E", "ele"); - for (i = 0; i < cfg->cnt; ++i)//按指定次数轮询 + for (i = 0; i < cfg->cnt; ++i) //按指定次数轮询 { - for (var = 0; var < isize; var++)//轮询每个参数 + for (var = 0; var < isize; var++) //轮询每个参数 { - char *url = RT_NULL; + static char *url = RT_NULL; url = web_strdup(*(infoH + var)); if (url == RT_NULL) { LOG_E("no memory for create getTT url buffer.\n"); // return -RT_ENOMEM; } - if(webclient_get_data(url) != RT_EOK) - { - break; - } + if (webclient_get_data(url) != RT_EOK) + { + break; + } web_free(url); rt_thread_mdelay(100); } -// rt_kprintf("%5d++%5d --%5d\n",TTinfo->xh,tmp.xh,TTinfo->sim); -// rt_kprintf("%5d%5d%5d%5d%15s%15s%10s\n", TTinfo.sim, TTinfo.xh, TTinfo.rw, TTinfo.jh, TTinfo.jd, TTinfo.wd,TTinfo.ele); - rt_kprintf("%5d%5d%5d%5d%15s%15s%10s\n", TTinfo->sim, TTinfo->xh, TTinfo->rw, - TTinfo->jh, TTinfo->jd, TTinfo->wd,TTinfo->ele); -if (i != cfg->cnt - 1)//最后一次采集不延时 + rt_kprintf("%5s%5d%5d%5d%15s%15s%10s\n", TTinfo->sim, TTinfo->xh, TTinfo->rw, TTinfo->jh, TTinfo->jd, + TTinfo->wd, TTinfo->ele); + if (i != cfg->cnt - 1) //最后一次采集不延时 { rt_thread_mdelay(cfg->s * 1000); } diff --git a/applications/idle.c b/applications/idle.c new file mode 100644 index 0000000..4771495 --- /dev/null +++ b/applications/idle.c @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 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 +#include +#include + + + +#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)) +// +// { +// +// 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_enter_critical(); +// +// hook_times++; +// +// rt_exit_critical(); + +} + + + +/* 线程入口 */ + +static void thread_entry(void *parameter) + +{ + + int i = 5; + +// while (1) +// +// { + +// rt_kprintf("enter thread1.\n"); +// +// rt_enter_critical(); +// +// hook_times = 0; +// +// rt_exit_critical(); + + + + /* 休眠500ms */ + +// rt_kprintf("thread1 delay 50 OS Tick.\n", hook_times); +// +// rt_thread_mdelay(500); +// +// } + +// rt_kprintf("delete idle hook.\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); + diff --git a/applications/iwdg_sample.c b/applications/iwdg_sample.c index 0448cf9..cb14218 100644 --- a/applications/iwdg_sample.c +++ b/applications/iwdg_sample.c @@ -21,12 +21,12 @@ #define IWDG_DEVICE_NAME "wdt" /* 看门狗设备名称 */ - static rt_device_t wdg_dev; /* 看门狗设备句柄 */ + rt_device_t wdg_dev; /* 看门狗设备句柄 */ static void idle_hook(void) { /* 在空闲线程的回调函数里喂狗 */ - rt_device_control(wdg_dev, RT_DEVICE_CTRL_WDT_KEEPALIVE, NULL); +// rt_device_control(wdg_dev, RT_DEVICE_CTRL_WDT_KEEPALIVE, NULL); // rt_thread_mdelay(500); // rt_kprintf("feed the dog!\n "); } @@ -74,7 +74,7 @@ static int iwdg_sample(int argc, char *argv[]) return -RT_ERROR; } /* 设置空闲线程回调函数 */ - rt_thread_idle_sethook(idle_hook); +// rt_thread_idle_sethook(idle_hook); return ret; } diff --git a/applications/timer.c b/applications/timer.c new file mode 100644 index 0000000..d0fa3de --- /dev/null +++ b/applications/timer.c @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 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 + + + +/* 定时器的控制块 */ + +static rt_timer_t timer1; + +static rt_timer_t timer2; + +static int cnt = 0; + + + +/* 定时器1超时函数 */ + +static void timeout1(void *parameter) + +{ + + rt_kprintf("periodic timer is timeout %d\n", cnt); + + + + /* 运行第10次,停止周期定时器 */ + + if (cnt++ >= 9) + + { + + rt_timer_stop(timer1); + + rt_kprintf("periodic timer was stopped! \n"); + + } + +} + + + +/* 定时器2超时函数 */ + +static void timeout2(void *parameter) + +{ + + rt_kprintf("one shot timer is timeout\n"); + +} + + + +int timer_sample(void) + +{ + + /* 创建定时器1 周期定时器 */ + + timer1 = rt_timer_create("timer1", timeout1, + + RT_NULL, 10, + + RT_TIMER_FLAG_PERIODIC); + + + + /* 启动定时器1 */ + + if (timer1 != RT_NULL) + + rt_timer_start(timer1); + + + + /* 创建定时器2 单次定时器 */ + + timer2 = rt_timer_create("timer2", timeout2, + + RT_NULL, 30, + + RT_TIMER_FLAG_ONE_SHOT); + + + + /* 启动定时器2 */ + + if (timer2 != RT_NULL) + + rt_timer_start(timer2); + + + + return 0; + +} + + + +/* 导出到 msh 命令列表中 */ + +MSH_CMD_EXPORT(timer_sample, timer sample); + diff --git a/applications/ttmsg/ttmsg.c b/applications/ttmsg/ttmsg.c index ab906e2..ee2d21e 100644 --- a/applications/ttmsg/ttmsg.c +++ b/applications/ttmsg/ttmsg.c @@ -502,7 +502,10 @@ static int pmsg(int argc, char **argv) MSH_CMD_EXPORT(pmsg, 打包文件。); - +/** + * 天通上电 + * @param parameter + */ void pwTT_thread_entry(void *parameter) { // LOG_I("--%s--",parameter); diff --git a/applications/ttmsg/ttmsg.h b/applications/ttmsg/ttmsg.h index a33e107..46e511d 100644 --- a/applications/ttmsg/ttmsg.h +++ b/applications/ttmsg/ttmsg.h @@ -100,4 +100,6 @@ rt_uint8_t pack_File(const char *fin, rt_uint8_t flag, const rt_uint8_t (*dout)[ //rt_uint8_t packMsgs(MSG *cfg, rt_uint8_t *din, size_t len, rt_uint8_t w, rt_uint8_t (*dout)[500], rt_uint8_t *arrlen); +void pwTT_thread_entry(void *parameter); + #endif /* APPLICATIONS_TTMSG_TTMSG_H_ */ diff --git a/applications/uart_dma_sample.c b/applications/uart_dma_sample.c index 407eb90..760715f 100644 --- a/applications/uart_dma_sample.c +++ b/applications/uart_dma_sample.c @@ -52,15 +52,17 @@ static rt_err_t uart_input(rt_device_t dev, rt_size_t size) } return result; } - +struct rx_msg msg; +extern struct rt_event update_cfg; +//static char rx_buffer[RT_SERIAL_RB_BUFSZ + 1]; static void serial_thread_entry(void *parameter) { - struct rx_msg msg; +// struct rx_msg msg; rt_err_t result; 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) { @@ -74,12 +76,12 @@ static void serial_thread_entry(void *parameter) // 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"); - } +// 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); if (result == RT_EOK) { @@ -106,7 +108,11 @@ static void serial_thread_entry(void *parameter) /* 打印数据 */ rt_kprintf("%s\n",rx_buffer); } + else { + LOG_D("no data reced."); + } rt_thread_mdelay(100); + } } @@ -149,7 +155,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*1, 25+1, 10); + rt_thread_t thread = rt_thread_create("serial", serial_thread_entry, RT_NULL, 1024*10, 25+1, 10); /* 创建成功则启动线程 */ if (thread != RT_NULL) { diff --git a/applications/流程.md b/applications/流程.md new file mode 100644 index 0000000..02c5287 --- /dev/null +++ b/applications/流程.md @@ -0,0 +1,9 @@ + +# main +1,等待事件,flag为 待发数据大小累计超minSizeToSend的设置值 +或 sendInterval设置值到达 +2,满足后上电 +3,等待事件,flag为 TT连续5个周期为激活状态且信号强度不低于5 +4,读入待发文件 +5,发送 +# ttcheck \ No newline at end of file diff --git a/applications/软件工作流程.md b/applications/软件工作流程.md index da2154a..4acc90b 100644 --- a/applications/软件工作流程.md +++ b/applications/软件工作流程.md @@ -77,14 +77,17 @@ fcfg为配置项,长1字节,为**数据类型**、**压缩方式**、**加 DATA_MODE=(1<<7), ``` # 发送: -与天通设备进行通信,将打包后数据依次送出。 +与TT设备进行通信,将打包后数据依次送出。 ## 发送逻辑 - +先依次检查发送条件,满足条件后开始发送,发送完毕后关闭TT设备 +## 发送条件 ### 软件条件 -待发数据大小累计超minSizeToSend的设置值 -sendInterval设置值到达 +需求条件1:待发数据大小累计超minSizeToSend的设置值 +需求条件2:sendInterval设置值到达 +以上任意条件满足则进入硬件条件检查 ### 硬件条件 -TT连续5个周期为激活状态且信号强度不低于5 +需求条件1:TT连续5个周期为激活状态且信号强度不低于5。 +软件条件满足后TT上电,MaxWaitTime内不达标则断电重启并重试MaxRetryCnt,如仍不成功则等待下次发送 diff --git a/rtconfig.h b/rtconfig.h index 80b35b9..4470269 100644 --- a/rtconfig.h +++ b/rtconfig.h @@ -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*2 +#define IDLE_THREAD_STACK_SIZE 256*4 #define RT_USING_TIMER_SOFT #define RT_TIMER_THREAD_PRIO 4 #define RT_TIMER_THREAD_STACK_SIZE 512