
The MultiWii Serial Protocol (MSP) is the de-facto standard to interact with a MultiWii flight controller (FC). Its implementation contains a list of the most common operations one would expect from a remote control/telemetry point of view. Developers can add custom functionality if required, being cautious about typos and errors in the information available as the project and the wiki are in constant development.
These notes are the foundation of the Android RC app developed to control the S-QUAD quadcopter. A clean Java implementation of the MSP protocol is available on GitHub.
History
MSP has been used by the MultiWii configurator (a Processing application) since the beginning with the first draft of the protocol eventually defined in 2012. The MSP wiki page is the main source of information and contains a brief description of the structure of a MSP request
MSP request
The definition of “request” is quite loose in fact three types of messages can be identified:
- command – is an incoming (into FC) message without implicit outgoing response from the controller
- request – is an incoming message with implicit outgoing response (e.g. a telemetry request sent in by a remote station)
- response – is the outgoing message resulting from an incoming request
The figure shows the different parts constituting a MSP message (see wiki)
Header (preamble and flow)
Header is 3 bytes long. A MSP message can be identified by a 2-byte preamble, the sequence of char “$M”. A 3rd byte containing the message direction completes the header. Data flow toward the MultiWii is identified with “<” while data from the MultiWii with “>” (the incoming flow is composed of commands and requests while the outgoing flow contains responses)
Info (data length and message type)
The 4th byte is the size and contains the length of the payload (number of bytes of the payload field only). Size is zero for a MSP request.
The 5th byte is the type of MSP message. Value 1xx identify requests while 2xx identify commands.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
public static final int MSP_IDENT =100, MSP_STATUS =101, MSP_RAW_IMU =102, MSP_SERVO =103, MSP_MOTOR =104, MSP_RC =105, MSP_RAW_GPS =106, MSP_COMP_GPS =107, MSP_ATTITUDE =108, MSP_ALTITUDE =109, MSP_ANALOG =110, MSP_RC_TUNING =111, MSP_PID =112, MSP_BOX =113, MSP_MISC =114, MSP_MOTOR_PINS =115, MSP_BOXNAMES =116, MSP_PIDNAMES =117, MSP_SERVO_CONF =120, MSP_SET_RAW_RC =200, MSP_SET_RAW_GPS =201, MSP_SET_PID =202, MSP_SET_BOX =203, MSP_SET_RC_TUNING =204, MSP_ACC_CALIBRATION =205, MSP_MAG_CALIBRATION =206, MSP_SET_MISC =207, MSP_RESET_CONF =208, MSP_SELECT_SETTING =210, MSP_SET_HEAD =211, // Not used MSP_SET_SERVO_CONF =212, MSP_SET_MOTOR =214, MSP_BIND =241, MSP_EEPROM_WRITE =250, MSP_DEBUGMSG =253, MSP_DEBUG =254 ; |
Payload
See the wiki for details
Checksum
The checksum is computed as the XOR of size, type and payload bytes. The checksum of a request (no payload) equals the type.
Other resources
Arduino MSP TX and RX at https://code.google.com/p/mwii-msp-tx/ and the original thread on the MultiWii forum http://www.multiwii.com/forum/viewtopic.php?f=8&t=3473
Thanks for your work.
Regards
Mehmet