WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
log_file_common.h
浏览该文件的文档.
1/*
2 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved.
3 * Description: offline log file saved to the storage
4 */
5
6#ifndef LOG_FILE_COMMON_H
7#define LOG_FILE_COMMON_H
8
9#include <stdint.h>
10#include "errcode.h"
11#include "log_file.h"
12#include "soc_osal.h"
13
14#define MAX_FILE_PATH_LEN 128
15#define MAX_SUFFIX_LEN 8
16#define RECORD_HEAD_MAGIC 0x4B3C
17#ifndef LOGFILE_SAVE_TASK_SIZE
18#define LOGFILE_SAVE_TASK_SIZE 0x800
19#endif
20#define LOGFILE_SAVE_EVENT_MASK 0x7
21#define LOGFILE_TIMER_PERIOD 10000
22#define MAX_MUTIFILE_NAME_NUM 9999
23#define MAX_MUTIFILE_NUM 100
24#define FILE_HEAD_START_FLAG 0xaabbccdd
25#define CLOSE_SLEEP_PERIOD 10
26#define THREAD_PRIORITY_NUM 24
27
28typedef struct {
29 uint16_t magic;
30 uint16_t len; /* 记录头 + 数据的总长度 */
31 uint8_t type; /* 类型 */
32 uint8_t rev; /* 是否有效 */
33#if CONFIG_DFX_SUPPORT_FILE_SYSTEM == DFX_NO
34 uint16_t index;
35#endif
36 uint16_t crc; /* CRC16 校验 */
37 signed char data[0];
38} store_record_info_t; /* 每条记录的头 */
39
40typedef struct {
43 uint32_t cache_size;
44 uint32_t threshold_size; /* 门限,cache剩余空间小于门限时,触发保存 */
45 signed char data[0]; /* 存储record */
47
48typedef struct {
49 uint32_t oldest_file_idx; /* 多文件存储时,最早的文件序列 */
50 uint32_t cur_file_idx; /* 多文件存储时,当前打开的文件序列 */
51 uint32_t file_count; /* 多文件存储时,当前文件个数 */
53
54typedef struct {
59 int32_t fd; /* 当前打开的文件句柄 */
60 int32_t idx_fd; /* 索引文件的文件句柄 */
61 uint32_t last_save_time; /* 此文件上次写的时间 */
62#if CONFIG_DFX_SUPPORT_FILE_SYSTEM == DFX_NO
63 uint32_t index; /* 当前flash中最新的标识数字 */
64 uint32_t flash_cur_pos; /* 当前文件写入位置 */
65#endif
70
71typedef struct {
72 osal_timer timer_handle; /* 缓存延后写入文件的定时器 */
73 osal_task *task_handle;; /* 负责文件写入的线程 */
74 osal_event event; /* 线程空闲时等待事件 */
75 osal_mutex file_write_mutex; /* 文件写入的互斥锁 */
78
80
82
84
85#endif /* LOG_FILE_COMMON_H */
store_service_t
Definition log_file.h:22
@ STORE_MAX
Definition log_file.h:26
void logfile_init_file_head(store_file_info_t *file_info)
Definition log_file.c:42
store_file_manage_t * logfile_get_manage(void)
Definition log_file.c:26
bool logfile_check_record_head_valid(store_record_info_t *record_header)
Definition log_file.c:31
Definition osal_event.h:28
Definition osal_mutex.h:20
Definition osal_task.h:49
Definition osal_timer.h:18
Definition log_file_common.h:40
uint32_t cache_read_pos
Definition log_file_common.h:42
uint32_t cache_write_pos
Definition log_file_common.h:41
uint32_t threshold_size
Definition log_file_common.h:44
uint32_t cache_size
Definition log_file_common.h:43
Definition log_file.h:49
Definition log_file.h:33
Definition log_file_common.h:54
bool finish_flag
Definition log_file_common.h:68
int32_t idx_fd
Definition log_file_common.h:60
store_service_t type
Definition log_file_common.h:57
bool run_flag
Definition log_file_common.h:67
store_file_cfg_t file_cfg
Definition log_file_common.h:56
int32_t fd
Definition log_file_common.h:59
store_muti_file_idx_t muti_file_idx
Definition log_file_common.h:58
uint32_t index
Definition log_file_common.h:63
uint32_t flash_cur_pos
Definition log_file_common.h:64
store_file_head_t file_head
Definition log_file_common.h:55
uint32_t last_save_time
Definition log_file_common.h:61
store_cache_t * cache
Definition log_file_common.h:66
Definition log_file_common.h:71
osal_mutex file_write_mutex
Definition log_file_common.h:75
osal_timer timer_handle
Definition log_file_common.h:72
osal_event event
Definition log_file_common.h:74
osal_task * task_handle
Definition log_file_common.h:73
Definition log_file_common.h:48
uint32_t cur_file_idx
Definition log_file_common.h:50
uint32_t oldest_file_idx
Definition log_file_common.h:49
uint32_t file_count
Definition log_file_common.h:51
Definition log_file_common.h:28
uint16_t len
Definition log_file_common.h:30
uint16_t crc
Definition log_file_common.h:36
uint8_t type
Definition log_file_common.h:31
uint8_t rev
Definition log_file_common.h:32
uint16_t magic
Definition log_file_common.h:29
uint16_t index
Definition log_file_common.h:34
Definition hal_uart_v151_regs_def.h:38