From 1bdd5222478c87e1ee06cf75607df06edadba05c Mon Sep 17 00:00:00 2001 From: payton Date: Fri, 19 Jan 2024 18:37:05 +0800 Subject: [PATCH] =?UTF-8?q?1.linux=E4=B8=8Blog=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/cardv/SrcCode/System/SysMain.c | 16 ++-- .../source/cardv/SrcCode/System/SysStrg_Exe.c | 75 ++++++++++++++++++- .../source/cardv/SrcCode/System/main.c | 2 + 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/code/application/source/cardv/SrcCode/System/SysMain.c b/code/application/source/cardv/SrcCode/System/SysMain.c index be96d70eb..edc6cd185 100644 --- a/code/application/source/cardv/SrcCode/System/SysMain.c +++ b/code/application/source/cardv/SrcCode/System/SysMain.c @@ -858,14 +858,14 @@ exit: stMessageBuf.cmdId = CMD_POWEROFF; sf_com_message_send_to_app(&stMessageBuf); #if (LOGFILE_FUNC==ENABLE) - UIMenuStoreInfo *puiPara = sf_ui_para_get(); - if (puiPara->DebugMode) - { - DBG_DUMP("LogFile_Close ...\n"); - LogFile_Close(); - system("rm -rf /mnt/sd/LOG/*dummy*");//Clear intermediate files. - system("sync"); - } + // UIMenuStoreInfo *puiPara = sf_ui_para_get(); + // if (puiPara->DebugMode) + // { + // DBG_DUMP("LogFile_Close ...\n"); + // LogFile_Close(); + // system("rm -rf /mnt/sd/LOG/*dummy*");//Clear intermediate files. + // system("sync"); + // } #endif #else sf_mcu_reg_set(SF_MCU_POWEROFF,paramArray[0]); diff --git a/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c b/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c index 89d2e2de7..b07c8deee 100644 --- a/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c +++ b/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c @@ -75,6 +75,7 @@ #include #include #include "sf_sd_common.h" +#include "sf_mcu.h" #endif #if (LOGFILE_FUNC==ENABLE) #include "LogFile.h" @@ -327,6 +328,75 @@ _ALIGNED(64) static CHAR gLogFile_Buff2[LOGFILE_BUFFER_SIZE]= {0}; static UINT32 gLogFile_Buff2_Size = sizeof(gLogFile_Buff2); #endif #endif +void sf_log_confgs(void) +{ + #if (LOGFILE_FUNC==ENABLE) + UIMenuStoreInfo *puiPara = sf_ui_para_get(); + DBG_WRN("sf_log_confgs s\n"); + if(((puiPara->DebugMode) || (puiPara->AutoLogSwitch)) && (!sf_is_usb_flag()) && (SxTimer_GetFuncActive(SX_TIMER_DET_SYSTEM_ERROR_ID) == 0)) + { + { + LOGFILE_OPEN logOpenParm = {0}; + LOGFILE_CFG cfg = {0}; + UINT32 maxFileNum = 32; + UINT32 maxFileSize = 0x100000; // 1MB + CHAR rootDir[LOGFILE_ROOT_DIR_MAX_LEN + 1] = "A:\\LOG\\"; + CHAR sysErrRootDir[LOGFILE_ROOT_DIR_MAX_LEN + 1] = "A:\\SYS\\"; + if(puiPara->DebugMode){ + cfg.ConType = LOGFILE_CON_MEM | LOGFILE_CON_UART; + } + else { + cfg.ConType = LOGFILE_CON_MEM; + } + logfile_init_dma_buff(); + cfg.TimeType = LOGFILE_TIME_TYPE_DATETIME; + cfg.LogBuffAddr = (UINT32)gLogFile_Buff; + cfg.LogBuffSize = gLogFile_Buff_Size; + maxFileSize = gLogFile_Buff_Size; + DBG_WRN("LogFile_Config\n"); + LogFile_Config(&cfg); + + logOpenParm.maxFileNum = maxFileNum; + logOpenParm.maxFileSize = maxFileSize; + logOpenParm.isPreAllocAllFiles = FALSE; + logOpenParm.isSaveLastTimeSysErrLog = FALSE; + logOpenParm.lastTimeSysErrLogBuffAddr = 0; + logOpenParm.lastTimeSysErrLogBuffSize = 0; + logOpenParm.isZeroFile = TRUE; + strncpy(logOpenParm.rootDir, rootDir, LOGFILE_ROOT_DIR_MAX_LEN); + strncpy(logOpenParm.sysErrRootDir, sysErrRootDir, LOGFILE_ROOT_DIR_MAX_LEN); + + DBG_WRN("LogFile_Open\n"); + LogFile_Open(&logOpenParm); + + //start scan + SxTimer_SetFuncActive(SX_TIMER_DET_SYSTEM_ERROR_ID, TRUE); + } + } + #endif +} + +void sf_log_sava(void) +{ + #if (LOGFILE_FUNC==ENABLE) + UIMenuStoreInfo *puiPara = sf_ui_para_get(); + struct tm current_time2 = {0}; + char tmp[64] = {'\0'}; + if(((puiPara->DebugMode) || (puiPara->AutoLogSwitch)) && (!sf_is_usb_flag())) + { + DBG_DUMP("LogFile_Close ...\n"); + current_time2 = hwclock_get_time(TIME_ID_CURRENT); + snprintf(tmp, sizeof(tmp), "A:\\LOG\\%lu%02lu%02lu%02lu%02lu%02lu_%d.log", current_time2.tm_year, current_time2.tm_mon, current_time2.tm_mday, current_time2.tm_hour, current_time2.tm_min, current_time2.tm_sec,sf_get_power_on_mode()); + // + LogFile_Suspend(); + LogFile_DumpToFile(tmp); + LogFile_Close(); + DBG_DUMP("LogFile:%s\n",tmp); + system("rm -rf /mnt/sd/LOG/*dummy*");//Clear intermediate files. + system("sync"); + } + #endif +} void System_OnStrgInit_FS(void) { @@ -399,6 +469,7 @@ void System_OnStrgInit_FS(void) #if (LOGFILE_FUNC==ENABLE) { + #if 0 LOGFILE_CFG cfg = {0}; #if 0 // only store system error log @@ -423,6 +494,8 @@ void System_OnStrgInit_FS(void) cfg.LogBuffSize2 = gLogFile_Buff2_Size; #endif LogFile_Config(&cfg); + #endif + sf_log_confgs(); } #endif @@ -1227,7 +1300,7 @@ INT32 System_OnStrgAttach(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) } #endif -#if (LOGFILE_FUNC==ENABLE) +#if 0//(LOGFILE_FUNC==ENABLE) #if HUNTING_CAMERA_MCU == ENABLE UIMenuStoreInfo *puiPara = sf_ui_para_get(); diff --git a/code/application/source/cardv/SrcCode/System/main.c b/code/application/source/cardv/SrcCode/System/main.c index 0c7c274ce..15bc67ad9 100755 --- a/code/application/source/cardv/SrcCode/System/main.c +++ b/code/application/source/cardv/SrcCode/System/main.c @@ -57,6 +57,7 @@ extern bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); extern bool pointer_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); extern void lvglTimer(void); +extern void sf_log_sava(void); /****************************************************** * static variables *******************************************************/ @@ -490,6 +491,7 @@ int NvtMain(void) #endif System_WaitForPowerOffStart(); // Wait for shutdown cmd + sf_log_sava(); nvt_user_uninit(); nvt_hdal_uninit();