增加时间保存runtimelog 1581/1 1581/head
authorhcj <1224667075@qq.com>
Sat, 28 Dec 2024 09:15:37 +0000 (17:15 +0800)
committerhcj <1224667075@qq.com>
Sat, 28 Dec 2024 09:15:37 +0000 (17:15 +0800)
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemLogModel.cpp
code/sdk/drivers/peripheral/utils/custom_save_runtime.c
code/sdk/drivers/peripheral/utils/custom_save_runtime.h

index 8de463f..5718159 100644 (file)
@@ -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);
index fbc522e..4785050 100644 (file)
@@ -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,
index 6fe865f..7f91788 100644 (file)
@@ -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