PX4 Firmware
PX4 Autopilot Software http://px4.io
messages.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2016 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written 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
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 #pragma once
35 
36 enum class ULogMessageType : uint8_t {
37  FORMAT = 'F',
38  DATA = 'D',
39  INFO = 'I',
40  INFO_MULTIPLE = 'M',
41  PARAMETER = 'P',
42  ADD_LOGGED_MSG = 'A',
43  REMOVE_LOGGED_MSG = 'R',
44  SYNC = 'S',
45  DROPOUT = 'O',
46  LOGGING = 'L',
47  LOGGING_TAGGED = 'C',
48  FLAG_BITS = 'B',
49 };
50 
51 
52 /* declare message data structs with byte alignment (no padding) */
53 #pragma pack(push, 1)
54 
55 /** first bytes of the file */
57  uint8_t magic[8];
58  uint64_t timestamp;
59 };
60 
61 #define ULOG_MSG_HEADER_LEN 3 //accounts for msg_size and msg_type
63  uint16_t msg_size;
64  uint8_t msg_type;
65 };
66 
68  uint16_t msg_size; //size of message - ULOG_MSG_HEADER_LEN
69  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::FORMAT);
70 
71  char format[1500];
72 };
73 
75  uint16_t msg_size; //size of message - ULOG_MSG_HEADER_LEN
76  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::ADD_LOGGED_MSG);
77 
78  uint8_t multi_id;
79  uint16_t msg_id;
80  char message_name[255];
81 };
82 
84  uint16_t msg_size; //size of message - ULOG_MSG_HEADER_LEN
85  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::REMOVE_LOGGED_MSG);
86 
87  uint16_t msg_id;
88 };
89 
91  uint16_t msg_size; //size of message - ULOG_MSG_HEADER_LEN
92  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::SYNC);
93 
94  uint8_t sync_magic[8];
95 };
96 
98  uint16_t msg_size = sizeof(uint16_t); //size of message - ULOG_MSG_HEADER_LEN
99  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::DROPOUT);
100 
101  uint16_t duration; //in ms
102 };
103 
105  uint16_t msg_size; //size of message - ULOG_MSG_HEADER_LEN
106  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::DATA);
107 
108  uint16_t msg_id;
109 };
110 
112  uint16_t msg_size; //size of message - ULOG_MSG_HEADER_LEN
113  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::INFO);
114 
115  uint8_t key_len;
116  char key[255];
117 };
118 
120  uint16_t msg_size; //size of message - ULOG_MSG_HEADER_LEN
121  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::INFO_MULTIPLE);
122 
123  uint8_t is_continued; ///< can be used for arrays: set to 1, if this message is part of the previous with the same key
124  uint8_t key_len;
125  char key[255];
126 };
127 
129  uint16_t msg_size; //size of message - ULOG_MSG_HEADER_LEN
130  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::LOGGING);
131 
132  uint8_t log_level; //same levels as in the linux kernel
133  uint64_t timestamp;
134  char message[128]; //defines the maximum length of a logged message string
135 };
136 
138  uint16_t msg_size; //size of message - ULOG_MSG_HEADER_LEN
139  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::LOGGING_TAGGED);
140 
141  uint8_t log_level; //same levels as in the linux kernel
142  uint16_t tag;
143  uint64_t timestamp;
144  char message[128]; //defines the maximum length of a logged message string
145 };
146 
148  uint16_t msg_size;
149  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::PARAMETER);
150 
151  uint8_t key_len;
152  char key[255];
153 };
154 
155 
156 #define ULOG_INCOMPAT_FLAG0_DATA_APPENDED_MASK (1<<0)
157 
159  uint16_t msg_size;
160  uint8_t msg_type = static_cast<uint8_t>(ULogMessageType::FLAG_BITS);
161 
162  uint8_t compat_flags[8];
163  uint8_t incompat_flags[8]; ///< @see ULOG_INCOMPAT_FLAG_*
164  uint64_t appended_offsets[3]; ///< file offset(s) for appended data if ULOG_INCOMPAT_FLAG0_DATA_APPENDED_MASK is set
165 };
166 
167 #pragma pack(pop)
uint64_t timestamp
Definition: messages.h:58
uint8_t is_continued
can be used for arrays: set to 1, if this message is part of the previous with the same key ...
Definition: messages.h:123
first bytes of the file
Definition: messages.h:56
uint16_t msg_size
Definition: messages.h:91
ULogMessageType
Definition: messages.h:36