MAVLink 2.0

MAVLink协议:

MavLink协议目前网上可以找到的中文版资料只有1.0的。现在开发使用的固件版本号是1.7.3.串口抓的的包全部与1.0版本都不一致。爬到官方去看了下。有2.0的包结构。

uint8_t magic;              ///< protocol magic marker
uint8_t len;                ///< Length of payload
uint8_t incompat_flags;     ///< flags that must be understood
uint8_t compat_flags;       ///< flags that can be ignored if not understood
uint8_t seq;                ///< Sequence of packet
uint8_t sysid;              ///< ID of message sender system/aircraft
uint8_t compid;             ///< ID of the message sender component
uint8_t msgid 0:7;          ///< first 8 bits of the ID of the message
uint8_t msgid 8:15;         ///< middle 8 bits of the ID of the message
uint8_t msgid 16:23;        ///< last 8 bits of the ID of the message
uint8_t target_sysid;       ///< Optional field for point-to-point messages, used for payload else
uint8_t target_compid;      ///< Optional field for point-to-point messages, used for payload else
uint8_t payload[max 253];   ///< A maximum of 253 payload bytes
uint16_t checksum;          ///< X.25 CRC
uint8_t signature[13];      ///< Signature which allows ensuring that the link is tamper-proof

包结构大致如下:

部分 长度 内容
n1 STX 1B 帧头部分,2.0版本为 0xFD
n2 LEN 1B PLAYLOAD数据长度
n3 1B incompat_flags
n4 1B compat_flags
n5 SEQ 1B 消息帧序号
n6 SYS 1B 消息系统编号
n7 COMP 1B 罗盘编号
n8 MSG 3B msgid,消息标号,MavlinkMessage
n9 1B target_sysid可选
n10 1B target_compid可选
n11 PLAYLOAD 2B 消息内容
n12 2B CRC校验
n13 1B 签名

2.0包的总长为10+n+3(+2),其中括号的2为可选内容。抓包未发现。

抓包获得来自飞控的Msgind如下。

0,36,74,105,30,31,32,140,1,147,65,70,141,230,241,111,83,69,24

這些都是飞控无请求时主动发送过来的数据。

根据msgid:

HEX DEC TYPE
00 0 HEARTBEAT
01 1 SYS_STATUS
18 24 GPS_RAW_INT
1E 30 ATTITUDE
1F 31 ATTITUDE_QUATERNION
20 32 LOCAL_POSITION_NED
24 36 SERVO_OUTPUT_RAW
41 65 RC_CHANNELS
45 69 MANUAL_CONTROL
46 70 RC_CHANNELS_OVERRIDE
4A 74 VFR_HUD
53 83 ATTITUDE_TARGET
69 105 HIGHRES_IMU
6F 111 TIMESYNC
8C 140 ACTUATOR_CONTROL_TARGET
8D 141 ALTITUDE
93 147 BATTERY_STATUS
E6 230 ESTIMATOR_STATUS
E7 231 WIND_COV
F1 241 VIBRATION
F5 245 EXTENDED_SYS_STATE

你可能感兴趣的:(MAVLink 2.0)