diff --git a/.config b/.config index d41f21f..381723f 100644 --- a/.config +++ b/.config @@ -32,18 +32,7 @@ CONFIG_RT_KSERVICE_USING_STDLIB=y # CONFIG_RT_KPRINTF_USING_LONGLONG is not set # end of kservice optimization -CONFIG_RT_DEBUG=y -CONFIG_RT_DEBUG_COLOR=y -# CONFIG_RT_DEBUG_INIT_CONFIG is not set -# CONFIG_RT_DEBUG_THREAD_CONFIG is not set -# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set -# CONFIG_RT_DEBUG_IPC_CONFIG is not set -# CONFIG_RT_DEBUG_TIMER_CONFIG is not set -# CONFIG_RT_DEBUG_IRQ_CONFIG is not set -# CONFIG_RT_DEBUG_MEM_CONFIG is not set -# CONFIG_RT_DEBUG_SLAB_CONFIG is not set -# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set -# CONFIG_RT_DEBUG_MODULE_CONFIG is not set +# CONFIG_RT_DEBUG is not set # # Inter-Thread communication @@ -183,9 +172,9 @@ CONFIG_RT_USING_RTC=y CONFIG_RT_USING_ALARM=y # CONFIG_RT_USING_SOFT_RTC is not set CONFIG_RT_USING_SDIO=y -CONFIG_RT_SDIO_STACK_SIZE=512 +CONFIG_RT_SDIO_STACK_SIZE=5120 CONFIG_RT_SDIO_THREAD_PRIORITY=15 -CONFIG_RT_MMCSD_STACK_SIZE=1024 +CONFIG_RT_MMCSD_STACK_SIZE=10240 CONFIG_RT_MMCSD_THREAD_PREORITY=22 CONFIG_RT_MMCSD_MAX_PARTITION=16 # CONFIG_RT_SDIO_DEBUG is not set @@ -342,7 +331,7 @@ CONFIG_ULOG_USING_ASYNC_OUTPUT=y CONFIG_ULOG_ASYNC_OUTPUT_BUF_SIZE=2048 CONFIG_ULOG_ASYNC_OUTPUT_BY_THREAD=y CONFIG_ULOG_ASYNC_OUTPUT_THREAD_STACK=2048 -CONFIG_ULOG_ASYNC_OUTPUT_THREAD_PRIORITY=30 +CONFIG_ULOG_ASYNC_OUTPUT_THREAD_PRIORITY=29 # # log format @@ -587,7 +576,27 @@ CONFIG_PKG_CJSON_VER="v1.7.15" # # tools packages # -# CONFIG_PKG_USING_CMBACKTRACE is not set +CONFIG_PKG_USING_CMBACKTRACE=y +# CONFIG_PKG_CMBACKTRACE_PLATFORM_M0_M0PLUS is not set +# CONFIG_PKG_CMBACKTRACE_PLATFORM_M3 is not set +CONFIG_PKG_CMBACKTRACE_PLATFORM_M4=y +# CONFIG_PKG_CMBACKTRACE_PLATFORM_M7 is not set +# CONFIG_PKG_CMBACKTRACE_PLATFORM_M33 is not set +# CONFIG_PKG_CMBACKTRACE_PLATFORM_NOT_SELECTED is not set +CONFIG_PKG_CMBACKTRACE_DUMP_STACK=y +CONFIG_PKG_CMBACKTRACE_PRINT_ENGLISH=y +# CONFIG_PKG_CMBACKTRACE_PRINT_CHINESE is not set +# CONFIG_PKG_CMBACKTRACE_PRINT_CHINESE_UTF8 is not set +# CONFIG_CMB_USING_FAL_FLASH_LOG is not set +CONFIG_PKG_CMBACKTRACE_PATH="/packages/tools/CmBacktrace" +CONFIG_PKG_USING_CMBACKTRACE_V10401=y +# CONFIG_PKG_USING_CMBACKTRACE_V10400 is not set +# CONFIG_PKG_USING_CMBACKTRACE_V10300 is not set +# CONFIG_PKG_USING_CMBACKTRACE_V10202 is not set +# CONFIG_PKG_USING_CMBACKTRACE_V10200 is not set +# CONFIG_PKG_USING_CMBACKTRACE_LATEST_VERSION is not set +CONFIG_PKG_CMBACKTRACE_VER="v1.4.1" +CONFIG_PKG_CMBACKTRACE_VER_NUM=0x10401 # CONFIG_PKG_USING_EASYFLASH is not set # CONFIG_PKG_USING_EASYLOGGER is not set # CONFIG_PKG_USING_SYSTEMVIEW is not set diff --git a/applications/TODO.md b/applications/TODO.md index b925bbf..35c7f66 100644 --- a/applications/TODO.md +++ b/applications/TODO.md @@ -1,2 +1,4 @@ setCommWindow 概率性崩溃,疑似与写入配置有关 -setCommWindow 崩溃,疑似传参不对 \ No newline at end of file +setCommWindow 崩溃,疑似传参不对 + +写入log到文件采用独立线程,避免错误 \ No newline at end of file diff --git a/applications/func/func.c b/applications/func/func.c index 08833a6..80bcc26 100644 --- a/applications/func/func.c +++ b/applications/func/func.c @@ -26,7 +26,8 @@ void selfTest(void); * @return 1-发送的数据,0-接收的数据,其它为发送失败的数据 */ int trDataTolog(uint8_t *din, size_t len, uint8_t isTx) -{return; +{ +// return RT_EOK; char fn[60] = "\n"; initDataLogPath(fn); @@ -250,6 +251,7 @@ RT_WEAK int upSend(uint8_t *din, size_t len) */ void selfTest(void) { + return; LOG_I("FUNC = selftest"); rt_uint8_t rst[200]={0x5A, 0xA5, ADDR_ANJI, ADDR_TT, _CMD_SELF_TEST>>8, _CMD_SELF_TEST & 0xff}; int p = 6; @@ -1054,7 +1056,7 @@ void chkACK(uint8_t *msg, size_t size) LOG_W("INVALID DATA."); } } - +#ifdef TR_USE_THREAD /** * @brief 解析TT数据,TT收到的指令必是单指令,解析容易。 * @@ -1149,6 +1151,74 @@ void parseTTData(uint8_t *din, size_t len) } } +#else + +/** + * @brief 解析TT数据,TT收到的指令必是单指令,解析容易。 + * + * @param din + * @param len + */ +void parseTTData(uint8_t *din, size_t len) +{ +/** +* +---------------------+-----------+-----------+-----------+-----------+---------+---------------------+------------+ +* | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | +* +---------------------+-----------+-----------+-----------+-----------+---------+---------------------+------------+ +* | fstart[4] | fnum[2] | bak[2] | ftype[2] | fdlen[2] | fcrc[1] | ftccid[4] | rawData[N] | +* | 0x88,0xAA,0xBB,0x88 | 0x00,0x01 | 0x00,0x00 | 0x70,0x21 | 0x00,0xAA | 0x00 | 0x27,0x22,0x22,0x22 | | +* +---------------------+-----------+-----------+-----------+-----------+---------+---------------------+------------+ +*/ + uint8_t head[]={0x88,0xAA,0xBB,0x88, 0xFF,0xFF, 0x00,0x00, 0x70,0x21, 0x00,0xaa, 0x00, 0x27,0x22,0x22,0x22 }; + //fstart[4] fnum[2]  bak[2]  ftype[2]  fdlen[2]  fcrc[1] ftccid[4] + uint8_t index[10]; + size_t n=isInByte(din, len, head, 4, index);//仅判断帧头,因ACK不一样 + uint8_t ndin[200]; + if (!n) { + LOG_W("TTData中无匹配帧"); + return; + } + for (size_t i = 0; i < n; i++) + { + //按帧头分割 + int cnt=(i+11) { + LOG_HEX("frame",16,ndin,cnt); + } + + + //判断是否为ACK + if ((ndin[10]<<8) | ndin[11] == 0x03) {//数据长度只有3 + chkACK(ndin, cnt); + } + //数据 + else + { + resetTM();//非ACK信号才能触发延时逻辑 + uint8_t rst = memcmp(ndin,head,10);//只比较到ftype + if (rst) + { + LOG_W("帧头不匹配"); + return; + } + + uint8_t id[30]=""; + LOG_I("data info: id=\"%s\", cur/all=[%d/%d]",bytes2str(ndin+17,7,10,"_",id),ndin[25],ndin[26]); + if (ndin[24] >> 7) // fcfg=数据类型。解析TT收到的数据时仅需解析“命令”,“数据”传输是单向的。 + { + LOG_W("浮标端仅接受指令,暂不支持数据。"); + return; + } + uint8_t rawData[200]; + uint8_t rawDataLen=cnt-27; + memcpy(rawData, ndin + 27, rawDataLen); + parse3SData(rawData,rawDataLen); + } + } + +} +#endif /** * get file size in byte * @param file file name whith fullpath @@ -1196,7 +1266,7 @@ int cacheDataToFile(uint8_t *din, size_t len) { LOG_I("FUNC = cache to upsend"); int rst = -RT_ERROR; - +//return RT_EOK; char f[60]=""; getLstCacheFileName(f); @@ -1247,6 +1317,7 @@ void d_cacheData() cacheDataToFile(demo, len); } +//#define TR_USE_THREAD #ifdef TR_USE_THREAD void parseRS232_thread_entry(void *parameter) { diff --git a/applications/log2file.c b/applications/log2file.c index cb25b7b..3b394e8 100644 --- a/applications/log2file.c +++ b/applications/log2file.c @@ -35,8 +35,8 @@ typedef enum }ulog_file_be_name; #define ROOT_PATH "/sd/syslog" //设置保存路径 -#define FILE_SIZE 512 * 1024 //设置单个文件大小 -#define BUFF_SIZE 512 //设备缓存区大小 +#define FILE_SIZE 10*1024 //设置单个文件大小 +#define BUFF_SIZE 10*1024 //设备缓存区大小 static struct ulog_backend sys_log_backend; static struct ulog_file_be sys_log_file; @@ -69,4 +69,4 @@ void sys_log_file_backend_init(void) ulog_file_backend_enable(file_be); //必须使能才能有效 } MSH_CMD_EXPORT(sys_log_file_backend_init,log2file); -INIT_COMPONENT_EXPORT(sys_log_file_backend_init); +//INIT_COMPONENT_EXPORT(sys_log_file_backend_init); diff --git a/drivers/stm32f4xx_hal_conf.h b/drivers/stm32f4xx_hal_conf.h index 14bbc2e..c26e6a2 100644 --- a/drivers/stm32f4xx_hal_conf.h +++ b/drivers/stm32f4xx_hal_conf.h @@ -61,7 +61,7 @@ /* #define HAL_NAND_MODULE_ENABLED */ /* #define HAL_NOR_MODULE_ENABLED */ /* #define HAL_PCCARD_MODULE_ENABLED */ -/* #define HAL_SRAM_MODULE_ENABLED */ + #define HAL_SRAM_MODULE_ENABLED /* #define HAL_SDRAM_MODULE_ENABLED */ /* #define HAL_HASH_MODULE_ENABLED */ /* #define HAL_I2C_MODULE_ENABLED */ diff --git a/packages/pkgs.json b/packages/pkgs.json index deecd34..b5dca95 100644 --- a/packages/pkgs.json +++ b/packages/pkgs.json @@ -9,6 +9,11 @@ "ver": "v1.7.15", "name": "CJSON" }, + { + "path": "/packages/tools/CmBacktrace", + "ver": "v1.4.1", + "name": "CMBACKTRACE" + }, { "path": "/packages/system/syswatch", "ver": "latest", diff --git a/rtconfig.h b/rtconfig.h index 229164b..d14105c 100644 --- a/rtconfig.h +++ b/rtconfig.h @@ -24,8 +24,6 @@ #define RT_KSERVICE_USING_STDLIB /* end of kservice optimization */ -#define RT_DEBUG -#define RT_DEBUG_COLOR /* Inter-Thread communication */ @@ -114,9 +112,9 @@ #define RT_USING_RTC #define RT_USING_ALARM #define RT_USING_SDIO -#define RT_SDIO_STACK_SIZE 512 +#define RT_SDIO_STACK_SIZE 5120 #define RT_SDIO_THREAD_PRIORITY 15 -#define RT_MMCSD_STACK_SIZE 1024 +#define RT_MMCSD_STACK_SIZE 10240 #define RT_MMCSD_THREAD_PREORITY 22 #define RT_MMCSD_MAX_PARTITION 16 #define RT_USING_SPI @@ -209,7 +207,7 @@ #define ULOG_ASYNC_OUTPUT_BUF_SIZE 2048 #define ULOG_ASYNC_OUTPUT_BY_THREAD #define ULOG_ASYNC_OUTPUT_THREAD_STACK 2048 -#define ULOG_ASYNC_OUTPUT_THREAD_PRIORITY 30 +#define ULOG_ASYNC_OUTPUT_THREAD_PRIORITY 29 /* log format */ @@ -283,6 +281,12 @@ /* tools packages */ +#define PKG_USING_CMBACKTRACE +#define PKG_CMBACKTRACE_PLATFORM_M4 +#define PKG_CMBACKTRACE_DUMP_STACK +#define PKG_CMBACKTRACE_PRINT_ENGLISH +#define PKG_USING_CMBACKTRACE_V10401 +#define PKG_CMBACKTRACE_VER_NUM 0x10401 /* end of tools packages */ /* system packages */ @@ -309,7 +313,7 @@ #define SYSWATCH_EXCEPT_CONFIRM_TMO 15 #define SYSWATCH_EXCEPT_RESUME_DLY 15 #define SYSWATCH_THREAD_PRIO 0 -#define SYSWATCH_THREAD_STK_SIZE 1024*2 +#define SYSWATCH_THREAD_STK_SIZE 1024 #define SYSWATCH_THREAD_NAME "syswatch" #define SYSWATCH_WDT_NAME "wdt" #define SYSWATCH_WDT_TIMEOUT 5