]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - apps/tidep0084.git/blob - components/api/inc/mt_msg_dbg.h
Updated TI Linux Sensor To Cloud to the latest TI 15.4-Stack v2.4, now with CC13x2...
[apps/tidep0084.git] / components / api / inc / mt_msg_dbg.h
1 /******************************************************************************
2  @file mt_msg_dbg.h
4  @brief TIMAC 2.0 mt msg - debug decoder header
6  Group: WCS LPC
7  $Target Devices: Linux: AM335x, Embedded Devices: CC1310, CC1350, CC1352$
9  ******************************************************************************
10  $License: BSD3 2016 $
11   
12    Copyright (c) 2015, Texas Instruments Incorporated
13    All rights reserved.
14   
15    Redistribution and use in source and binary forms, with or without
16    modification, are permitted provided that the following conditions
17    are met:
18   
19    *  Redistributions of source code must retain the above copyright
20       notice, this list of conditions and the following disclaimer.
21   
22    *  Redistributions in binary form must reproduce the above copyright
23       notice, this list of conditions and the following disclaimer in the
24       documentation and/or other materials provided with the distribution.
25   
26    *  Neither the name of Texas Instruments Incorporated nor the names of
27       its contributors may be used to endorse or promote products derived
28       from this software without specific prior written permission.
29   
30    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33    PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37    OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  ******************************************************************************
42  $Release Name: TI-15.4Stack Linux x64 SDK$
43  $Release Date: Sept 27, 2017 (2.04.00.13)$
44  *****************************************************************************/
46 #if !defined( MT_MSG_DBG_H )
47 #define MT_MSG_DBG_H
49 /* forward declarations */
50 struct mt_msg_dbg_field;
51 struct mt_msg_dbg;
53 /*! contains 'pseudo-globals' when decoding/printing message content */
54 struct mt_msg_dbg_info {
55     /*! the message being printed */
56     struct mt_msg *m_pMsg;
58     /*! The debug info for the message */
59     struct mt_msg_dbg *m_pDbg;
61     /*! What interface is this message associated with? */
62     struct mt_msg_interface *m_pIface;
64     /*! What field number is this? */
65     int    m_field_num;
67     /*! Where in the io buffer is the start of the payload */
68     int    m_idx_start;
70     /*! Where in playload are we decoding right now? */
71     int    m_idx_cursor;
73     /*! Where is the end of the payload */
74     int    m_idx_end;
76     /*! What is the field we are printing? */
77     struct mt_msg_dbg_field *m_pCurField;
78 };
80 #define FIELDTYPE_END   0
81 #define FIELDTYPE_U8    1
82 #define FIELDTYPE_U16   2
83 #define FIELDTYPE_U32   3
84 #define FIELDTYPE_MAXBYTES(n)  (10000 + (n))
85 #define IS_FIELDTYPE_MAXBYTES(X)  (((X) >= 10000) && ((X) <= 19999))
86 #define FIELDTYPE_BYTES_N(n)   (20000 + (n))
87 #define IS_FIELDTYPE_BYTES_N(X)  (((X) >= 20000) && ((X) <= 29999))
89 /*! A field within a message */
90 struct mt_msg_dbg_field {
91     /*! the field type, ie: FIELDTYPE_U8 */
92     int m_fieldtype;
94     /*! name to print for this field */
95     const char *m_name;
97     /*! If this field has a special case handler */
98     void(*handler)(struct mt_msg_dbg_info *pW);
100     /*! Next field */
101     struct mt_msg_dbg_field *m_pNext;
102 };
105 /*! Debug information about a message */
106 struct mt_msg_dbg {
107     /*! The command in the message */
108     int m_cmd0;
109     /*! The second command byte in the message */
110     int m_cmd1;
112     /*! What to print for debug purposes */
113     const char *m_pktName;
115     /*! List of fields in the message */
116     struct mt_msg_dbg_field *m_pFields;
118     /*! Next message in list of all msg debug detail */
119     struct mt_msg_dbg *m_pNext;
120 };
123 /*!
124  * @brief Load a message debug file, return linked list of messages
125  * @param filename - filename to load
126  * @return NULL on error, otherwise a null terminated linked list of debug info.
127  */
128 struct mt_msg_dbg *MT_MSG_dbg_load(const char *filename);
130 /*!
131  * @brief Free memory associated with a list of messages
132  * @param pMsgs - list of message debug info to free
133  */
134 void MT_MSG_dbg_free(struct mt_msg_dbg *pMsgs);
136 /*!
137  * @brief Decode & print detail about specified message.
138  *
139  * @param pMsg - msg to print.
140  * @param pIface - interface associated with this message.
141  * @param pDbg - list of all known message debug information to search.
142  *
143  * If (pDbg == NULL) nothing is printed.
144  */
145 void MT_MSG_dbg_decode(struct mt_msg *pMsg,
146                         struct mt_msg_interface *pIface,
147                         struct mt_msg_dbg *pDbg);
149 /*!
150  * Linked list of all known message debug information.
151  */
152 extern struct mt_msg_dbg *ALL_MT_MSG_DBG;
154 #endif
156 /*
157  *  ========================================
158  *  Texas Instruments Micro Controller Style
159  *  ========================================
160  *  Local Variables:
161  *  mode: c
162  *  c-file-style: "bsd"
163  *  tab-width: 4
164  *  c-basic-offset: 4
165  *  indent-tabs-mode: nil
166  *  End:
167  *  vim:set  filetype=c tabstop=4 shiftwidth=4 expandtab=true
168  */