更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
trace_tlv.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 * of conditions and the following disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _TRACE_TLV_H
33#define _TRACE_TLV_H
34
35#include "los_typedef.h"
36
37#ifdef __cplusplus
38#if __cplusplus
39extern "C" {
40#endif /* __cplusplus */
41#endif /* __cplusplus */
42
43#define TRACE_TLV_MSG_HEAD 0xFF
44#define TRACE_TLV_TYPE_NULL 0xFF
45
46/// TLV协议 消息头 https://blog.csdn.net/Shallwen_Deng/article/details/88930288
47typedef struct {
48 UINT8 magicNum; ///< 魔法数字
49 UINT8 msgType; ///< 消息类型
50 UINT16 len; ///< 消息长度
51 UINT16 crc; ///< CRC校验
53/// TLV协议 消息体
54typedef struct {
55 UINT8 type; ///< 类型
56 UINT8 len; ///< 长度
57 UINT8 value[];///< 内容
59/// TLV表,主要用于TLV的解码阶段
60typedef struct {
64} TlvTable;
65
66/**
67 * @ingroup los_trace
68 * @brief Encode trace raw data.
69 *
70 * @par Description:
71 * This API is used to encode trace raw data to tlv data.
72 * @attention
73 * <ul>
74 * <li>Encade trace data</li>
75 * </ul>
76 *
77 * @param type [IN] Type #UINT8. The type stands for different struct of src data.
78 * @param src [IN] Type #UINT8 *. The raw trace data.
79 * @param table [IN] Type #const TlvTable *. The tlv table descript elemOffset and elemSize.
80 * @param dest [OUT] Type #UINT8 *. The tlv data.
81 * @param destLen [IN] Type #UINT8 *. The tlv buf max len.
82
83 * @retval #0 convert failed.
84 * @retval #UINT32 convert success bytes.
85 *
86 * @par Dependency:
87 * <ul><li>trace_tlv.h: the header file that contains the API declaration.</li></ul>
88 * @see OsTraceDataEncode
89 */
90extern UINT32 OsTraceDataEncode(UINT8 type, const TlvTable *table, UINT8 *src, UINT8 *dest, INT32 destLen);
91
92#ifdef __cplusplus
93#if __cplusplus
94}
95#endif /* __cplusplus */
96#endif /* __cplusplus */
97
98#endif /* _TRACE_TLV_H */
UINT32 OsTraceDataEncode(UINT8 type, const TlvTable *table, UINT8 *src, UINT8 *dest, INT32 destLen)
Encode trace raw data.
Definition: trace_tlv.c:115
unsigned short UINT16
Definition: los_typedef.h:56
signed int INT32
Definition: los_typedef.h:60
unsigned char UINT8
Definition: los_typedef.h:55
unsigned int UINT32
Definition: los_typedef.h:57
TLV表,主要用于TLV的解码阶段
Definition: trace_tlv.h:60
UINT8 tag
Definition: trace_tlv.h:61
UINT8 elemOffset
Definition: trace_tlv.h:62
UINT8 elemSize
Definition: trace_tlv.h:63
TLV协议 消息体
Definition: trace_tlv.h:54
UINT8 len
长度
Definition: trace_tlv.h:56
UINT8 type
类型
Definition: trace_tlv.h:55
TLV协议 消息头 https://blog.csdn.net/Shallwen_Deng/article/details/88930288
Definition: trace_tlv.h:47
UINT8 magicNum
魔法数字
Definition: trace_tlv.h:48
UINT16 len
消息长度
Definition: trace_tlv.h:50
UINT16 crc
CRC校验
Definition: trace_tlv.h:51
UINT8 msgType
消息类型
Definition: trace_tlv.h:49