2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
23 #include "common/streambuf.h"
25 #define MSP_V2_FRAME_ID 255
34 #define MSP_VERSION_MAGIC_INITIALIZER { 'M', 'M', 'X' }
36 // return positive for ACK, negative on error, zero for no reply
39 MSP_RESULT_ERROR
= -1,
40 MSP_RESULT_NO_REPLY
= 0,
41 MSP_RESULT_CMD_UNKNOWN
= -2, // don't know how to process command, try next handler
45 MSP_DIRECTION_REPLY
= 0,
46 MSP_DIRECTION_REQUEST
= 1
49 typedef struct mspPacket_s
{
57 typedef int mspDescriptor_t
;
60 typedef void (*mspPostProcessFnPtr
)(struct serialPort_s
*port
); // msp post process function, used for gracefully handling reboots, etc.
61 typedef mspResult_e (*mspProcessCommandFnPtr
)(mspDescriptor_t srcDesc
, mspPacket_t
*cmd
, mspPacket_t
*reply
, mspPostProcessFnPtr
*mspPostProcessFn
);
62 typedef void (*mspProcessReplyFnPtr
)(mspPacket_t
*cmd
);
66 mspResult_e
mspFcProcessCommand(mspDescriptor_t srcDesc
, mspPacket_t
*cmd
, mspPacket_t
*reply
, mspPostProcessFnPtr
*mspPostProcessFn
);
67 void mspFcProcessReply(mspPacket_t
*reply
);
69 mspDescriptor_t
mspDescriptorAlloc(void);