NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
msp_protocol.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Ninjaflight is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Ninjaflight is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
53 #pragma once
54 
55 /* Protocol numbers used both by the wire format, config system, and
56  field setters.
57 */
58 
59 #define MSP_PROTOCOL_VERSION 0
60 
61 #define API_VERSION_MAJOR 1 // increment when major changes are made
62 #define API_VERSION_MINOR 19 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR
63 
64 #define API_VERSION_LENGTH 2
65 
66 #define MULTIWII_IDENTIFIER "MWII";
67 #define CLEANFLIGHT_IDENTIFIER "CLFL"
68 #define BASEFLIGHT_IDENTIFIER "BAFL";
69 
70 
71 #define FLIGHT_CONTROLLER_IDENTIFIER_LENGTH 4
72 #define FLIGHT_CONTROLLER_VERSION_LENGTH 3
73 #define FLIGHT_CONTROLLER_VERSION_MASK 0xFFF
74 
75 #define BOARD_IDENTIFIER_LENGTH 4 // 4 UPPER CASE alpha numeric characters that identify the board being used.
76 #define BOARD_HARDWARE_REVISION_LENGTH 2
77 
78 // These are baseflight specific flags but they are useless now since MW 2.3 uses the upper 4 bits for the navigation version.
79 #define CAP_PLATFORM_32BIT ((uint32_t)1 << 31)
80 #define CAP_BASEFLIGHT_CONFIG ((uint32_t)1 << 30)
81 
82 // MW 2.3 stores NAVI_VERSION in the top 4 bits of the capability mask.
83 #define CAP_NAVI_VERSION_BIT_4_MSB ((uint32_t)1 << 31)
84 #define CAP_NAVI_VERSION_BIT_3 ((uint32_t)1 << 30)
85 #define CAP_NAVI_VERSION_BIT_2 ((uint32_t)1 << 29)
86 #define CAP_NAVI_VERSION_BIT_1_LSB ((uint32_t)1 << 28)
87 
88 #define CAP_DYNBALANCE ((uint32_t)1 << 2)
89 #define CAP_FLAPS ((uint32_t)1 << 3)
90 #define CAP_NAVCAP ((uint32_t)1 << 4)
91 #define CAP_EXTAUX ((uint32_t)1 << 5)
92 
93 #define MSP_API_VERSION 1 //out message
94 #define MSP_FC_VARIANT 2 //out message
95 #define MSP_FC_VERSION 3 //out message
96 #define MSP_BOARD_INFO 4 //out message
97 #define MSP_BUILD_INFO 5 //out message
98 
99 //
100 // MSP commands for Ninjaflight original features
101 //
102 #define MSP_MODE_RANGES 34 //out message Returns all mode ranges
103 #define MSP_SET_MODE_RANGE 35 //in message Sets a single mode range
104 
105 #define MSP_FEATURE 36
106 #define MSP_SET_FEATURE 37
107 
108 #define MSP_BOARD_ALIGNMENT 38
109 #define MSP_SET_BOARD_ALIGNMENT 39
110 
111 #define MSP_CURRENT_METER_CONFIG 40
112 #define MSP_SET_CURRENT_METER_CONFIG 41
113 
114 #define MSP_MIXER 42
115 #define MSP_SET_MIXER 43
116 
117 #define MSP_RX_CONFIG 44
118 #define MSP_SET_RX_CONFIG 45
119 
120 #define MSP_LED_COLORS 46
121 #define MSP_SET_LED_COLORS 47
122 
123 #define MSP_LED_STRIP_CONFIG 48
124 #define MSP_SET_LED_STRIP_CONFIG 49
125 
126 #define MSP_RSSI_CONFIG 50
127 #define MSP_SET_RSSI_CONFIG 51
128 
129 #define MSP_ADJUSTMENT_RANGES 52
130 #define MSP_SET_ADJUSTMENT_RANGE 53
131 
132 // private - only to be used by the configurator, the commands are likely to change
133 #define MSP_CF_SERIAL_CONFIG 54
134 #define MSP_SET_CF_SERIAL_CONFIG 55
135 
136 #define MSP_VOLTAGE_METER_CONFIG 56
137 #define MSP_SET_VOLTAGE_METER_CONFIG 57
138 
139 #define MSP_SONAR_ALTITUDE 58 //out message get sonar altitude [cm]
140 
141 #define MSP_PID_CONTROLLER 59
142 #define MSP_SET_PID_CONTROLLER 60
143 
144 #define MSP_ARMING_CONFIG 61 //out message Returns auto_disarm_delay and disarm_kill_switch parameters
145 #define MSP_SET_ARMING_CONFIG 62 //in message Sets auto_disarm_delay and disarm_kill_switch parameters
146 
147 #define MSP_DATAFLASH_SUMMARY 70 //out message - get description of dataflash chip
148 #define MSP_DATAFLASH_READ 71 //out message - get content of dataflash chip
149 #define MSP_DATAFLASH_ERASE 72 //in message - erase dataflash chip
150 
151 #define MSP_LOOP_TIME 73 //out message Returns FC cycle time i.e looptime parameter
152 #define MSP_SET_LOOP_TIME 74 //in message Sets FC cycle time i.e looptime parameter
153 
154 #define MSP_FAILSAFE_CONFIG 75 //out message Returns FC Fail-Safe settings
155 #define MSP_SET_FAILSAFE_CONFIG 76 //in message Sets FC Fail-Safe settings
156 
157 #define MSP_RXFAIL_CONFIG 77 //out message Returns RXFAIL settings
158 #define MSP_SET_RXFAIL_CONFIG 78 //in message Sets RXFAIL settings
159 
160 #define MSP_SDCARD_SUMMARY 79 //out message Get the state of the SD card
161 
162 #define MSP_BLACKBOX_CONFIG 80 //out message Get blackbox settings
163 #define MSP_SET_BLACKBOX_CONFIG 81 //in message Set blackbox settings
164 
165 #define MSP_TRANSPONDER_CONFIG 82 //out message Get transponder settings
166 #define MSP_SET_TRANSPONDER_CONFIG 83 //in message Set transponder settings
167 
168 #define MSP_LED_STRIP_MODECOLOR 86 //out message Get LED strip mode_color settings
169 #define MSP_SET_LED_STRIP_MODECOLOR 87 //in message Set LED strip mode_color settings
170 
171 //
172 // Baseflight MSP commands (if enabled they exist in Ninjaflight)
173 //
174 #define MSP_RX_MAP 64 //out message get channel map (also returns number of channels total)
175 #define MSP_SET_RX_MAP 65 //in message set rx map, numchannels to set comes from MSP_RX_MAP
176 
177 // FIXME - Provided for backwards compatibility with configurator code until configurator is updated.
178 // DEPRECATED - DO NOT USE "MSP_BF_CONFIG" and MSP_SET_BF_CONFIG. In Ninjaflight, isolated commands already exist and should be used instead.
179 #define MSP_BF_CONFIG 66 //out message baseflight-specific settings that aren't covered elsewhere
180 #define MSP_SET_BF_CONFIG 67 //in message baseflight-specific settings save
181 
182 #define MSP_REBOOT 68 //in message reboot settings
183 
184 // DEPRECATED - Use MSP_BUILD_INFO instead
185 #define MSP_BF_BUILD_INFO 69 //out message build date as well as some space for future expansion
186 
187 //
188 // Multwii original MSP commands
189 //
190 
191 // DEPRECATED - See MSP_API_VERSION and MSP_MIXER
192 #define MSP_IDENT 100 //out message mixerMode + multiwii version + protocol version + capability variable
193 
194 
195 #define MSP_STATUS 101 //out message cycletime & errors_count & sensor present & box activation & current setting number
196 #define MSP_RAW_IMU 102 //out message 9 DOF
197 #define MSP_SERVO 103 //out message servos
198 #define MSP_MOTOR 104 //out message motors
199 #define MSP_RC 105 //out message rc channels and more
200 #define MSP_RAW_GPS 106 //out message fix, numsat, lat, lon, alt, speed, ground course
201 #define MSP_COMP_GPS 107 //out message distance home, direction home
202 #define MSP_ATTITUDE 108 //out message 2 angles 1 heading
203 #define MSP_ALTITUDE 109 //out message altitude, variometer
204 #define MSP_ANALOG 110 //out message vbat, powermetersum, rssi if available on RX
205 #define MSP_RC_TUNING 111 //out message rc rate, rc expo, rollpitch rate, yaw rate, dyn throttle PID
206 #define MSP_PID 112 //out message P I D coeff (9 are used currently)
207 #define MSP_BOX 113 //out message BOX setup (number is dependant of your setup)
208 #define MSP_MISC 114 //out message powermeter trig
209 #define MSP_MOTOR_PINS 115 //out message which pins are in use for motors & servos, for GUI
210 #define MSP_BOXNAMES 116 //out message the aux switch names
211 #define MSP_PIDNAMES 117 //out message the PID names
212 #define MSP_WP 118 //out message get a WP, WP# is in the payload, returns (WP#, lat, lon, alt, flags) WP#0-home, WP#16-poshold
213 #define MSP_BOXIDS 119 //out message get the permanent IDs associated to BOXes
214 #define MSP_SERVO_CONFIGURATIONS 120 //out message All servo configurations.
215 #define MSP_NAV_STATUS 121 //out message Returns navigation status
216 #define MSP_NAV_CONFIG 122 //out message Returns navigation parameters
217 #define MSP_3D 124 //out message Settings needed for reversible ESCs
218 #define MSP_RC_DEADBAND 125 //out message deadbands for yaw alt pitch roll
219 #define MSP_SENSOR_ALIGNMENT 126 //out message orientation of acc,gyro,mag
220 
221 #define MSP_SET_RAW_RC 200 //in message 8 rc chan
222 #define MSP_SET_RAW_GPS 201 //in message fix, numsat, lat, lon, alt, speed
223 #define MSP_SET_PID 202 //in message P I D coeff (9 are used currently)
224 #define MSP_SET_BOX 203 //in message BOX setup (number is dependant of your setup)
225 #define MSP_SET_RC_TUNING 204 //in message rc rate, rc expo, rollpitch rate, yaw rate, dyn throttle PID, yaw expo
226 #define MSP_ACC_CALIBRATION 205 //in message no param
227 #define MSP_MAG_CALIBRATION 206 //in message no param
228 #define MSP_SET_MISC 207 //in message powermeter trig + 8 free for future use
229 #define MSP_RESET_CONF 208 //in message no param
230 #define MSP_SET_WP 209 //in message sets a given WP (WP#,lat, lon, alt, flags)
231 #define MSP_SELECT_SETTING 210 //in message Select Setting Number (0-2)
232 #define MSP_SET_HEAD 211 //in message define a new heading hold direction
233 #define MSP_SET_SERVO_CONFIGURATION 212 //in message Servo settings
234 #define MSP_SET_MOTOR 214 //in message PropBalance function
235 #define MSP_SET_NAV_CONFIG 215 //in message Sets nav config parameters - write to the eeprom
236 #define MSP_SET_3D 217 //in message Settings needed for reversible ESCs
237 #define MSP_SET_RC_DEADBAND 218 //in message deadbands for yaw alt pitch roll
238 #define MSP_SET_RESET_CURR_PID 219 //in message resetting the current pid profile to defaults
239 #define MSP_SET_SENSOR_ALIGNMENT 220 //in message set the orientation of the acc,gyro,mag
240 
241 // #define MSP_BIND 240 //in message no param
242 // #define MSP_ALARMS 242
243 
244 #define MSP_EEPROM_WRITE 250 //in message no param
245 
246 #define MSP_DEBUGMSG 253 //out message debug string buffer
247 #define MSP_DEBUG 254 //out message debug1,debug2,debug3,debug4
248 
249 // Additional commands that are not compatible with MultiWii
250 #define MSP_STATUS_EX 150 //out message cycletime, errors_count, CPU load, sensor present etc
251 #define MSP_UID 160 //out message Unique device ID
252 #define MSP_GPSSVINFO 164 //out message get Signal Strength (only U-Blox)
253 #define MSP_ACC_TRIM 240 //out message get acc angle trim values
254 #define MSP_SET_ACC_TRIM 239 //in message set acc angle trim values
255 #define MSP_SERVO_MIX_RULES 241 //out message Returns servo mixer configuration
256 #define MSP_SET_SERVO_MIX_RULE 242 //in message Sets servo mixer configuration
257 #define MSP_SET_4WAY_IF 245 //in message Sets 4way interface