From b386c4b2a53130b182149e092d2445a70138d7d4 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Sat, 28 Dec 2024 17:15:37 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E6=97=B6=E9=97=B4=E4=BF=9D?= =?utf8?q?=E5=AD=98runtimelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/system/src/SystemLogModel.cpp | 2 ++ .../peripheral/utils/custom_save_runtime.c | 34 ++++++++++++++++++- .../peripheral/utils/custom_save_runtime.h | 6 +++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp index 8de463f01..571815998 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp @@ -39,6 +39,8 @@ void report_log(OHOS::SystemLogType type) { OHOS::SystemLogData systemlog; systemlog.timestamp = OHOS::SystemLogModel::GetInstance()->GetCurrentTime(); systemlog.type = type; + uapi_save_runtime_log_Time(); + // 存储日志 OHOS::SystemLogModel::GetInstance()->saveLog(systemlog); diff --git a/code/sdk/drivers/peripheral/utils/custom_save_runtime.c b/code/sdk/drivers/peripheral/utils/custom_save_runtime.c index fbc522e19..4785050e4 100644 --- a/code/sdk/drivers/peripheral/utils/custom_save_runtime.c +++ b/code/sdk/drivers/peripheral/utils/custom_save_runtime.c @@ -50,6 +50,9 @@ #include "unistd.h" +#include "custom_save_runtime.h" + + #define RUNTIME_LOG_SAVE_PATH EXC_TAR_PATH @@ -92,6 +95,35 @@ errcode_t uapi_save_runtime_log(uint16_t cmd) return ERRCODE_SUCC; } +errcode_t uapi_save_runtime_log_Time(void) +{ + int ret; + + custom_cmd_t mail = {0}; + time_t currtime; + time(&currtime); + mail.cmd = RUNTIME_LOG_RTC_TIME; + mail.time= (uint32_t)(currtime); + + PRINT("uapi_save_runtime_log_Time:%d\r\n",mail.time); + + if(custom_running_log_state_stat==0 || g_runtime_log_queue_created==0) + { + PRINT("Error task or queue no ready\r\n"); + return ERRCODE_FAIL; + } + ret = osal_msg_queue_write_copy(g_custom_runtime_log_cmd_queue, (void *)&mail, sizeof(custom_cmd_t), 0); + + if (ret != OSAL_SUCCESS) + { + // PRINT("Error custom_cmd Check MSG 0x%02X send failed! err=0x%x! \r\n", cmd, ret); + return ERRCODE_FAIL; + } + + return ERRCODE_SUCC; + +} + #define RUNTIME_FILE_PATH "%s/%s_runtime_%d.bin" void create_runtime_log_path(char *path,uint16_t max_len,uint8_t count) @@ -148,7 +180,7 @@ static void custom_save_runtime_log_service_task(void const *arg) uint32_t msgsize = (uint32_t)sizeof(custom_cmd_t); custom_running_log_state_stat = true; int code=0; - + while (1) { ret = osal_msg_queue_read_copy(g_custom_runtime_log_cmd_queue, (void *)&mail, &msgsize, diff --git a/code/sdk/drivers/peripheral/utils/custom_save_runtime.h b/code/sdk/drivers/peripheral/utils/custom_save_runtime.h index 6fe865f1d..7f917886e 100644 --- a/code/sdk/drivers/peripheral/utils/custom_save_runtime.h +++ b/code/sdk/drivers/peripheral/utils/custom_save_runtime.h @@ -238,15 +238,19 @@ extern "C" RUNTIME_LOG_BLE_CONNECT_UPDATE =0x1400,//ble连接参数 - + RUNTIME_LOG_RTC_TIME =0x1500, //时间记录 //电压变化 RUNTIME_LOG_BAT_VOL_LOW = 0xe000, //3V RUNTIME_LOG_BAT_VOL_HIGH =0xf000, //4V + + } runtime_log_cmd_Id; errcode_t uapi_save_runtime_log(uint16_t cmd); + errcode_t uapi_save_runtime_log_Time(void); + errcode_t uapi_runtime_log_service_init(void); #ifdef __cplusplus -- 2.17.1