🐞fix: fix to keep msg len
保证包长度不超过255
This commit is contained in:
@@ -9,18 +9,18 @@ typedef struct __mavlink_v2_extension_t {
|
||||
uint16_t message_type; /*< A code that identifies the software component that understands this message (analogous to USB device classes or mime type strings). If this code is less than 32768, it is considered a 'registered' protocol extension and the corresponding entry should be added to https://github.com/mavlink/mavlink/definition_files/extension_message_ids.xml. Software creators can register blocks of message IDs as needed (useful for GCS specific metadata, etc...). Message_types greater than 32767 are considered local experiments and should not be checked in to any widely distributed codebase.*/
|
||||
uint8_t target_network; /*< Network ID (0 for broadcast)*/
|
||||
uint8_t target_component; /*< Component ID (0 for broadcast)*/
|
||||
uint8_t payload[249]; /*< Variable length payload. The length must be encoded in the payload as part of the message_type protocol, e.g. by including the length as payload data, or by terminating the payload data with a non-zero marker. This is required in order to reconstruct zero-terminated payloads that are (or otherwise would be) trimmed by MAVLink 2 empty-byte truncation. The entire content of the payload block is opaque unless you understand the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the MAVLink specification.*/
|
||||
uint8_t payload[248]; /*< Variable length payload. The length must be encoded in the payload as part of the message_type protocol, e.g. by including the length as payload data, or by terminating the payload data with a non-zero marker. This is required in order to reconstruct zero-terminated payloads that are (or otherwise would be) trimmed by MAVLink 2 empty-byte truncation. The entire content of the payload block is opaque unless you understand the encoding message_type. The particular encoding used can be extension specific and might not always be documented as part of the MAVLink specification.*/
|
||||
} mavlink_v2_extension_t;
|
||||
|
||||
#define MAVLINK_MSG_ID_V2_EXTENSION_LEN 255
|
||||
#define MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN 255
|
||||
#define MAVLINK_MSG_ID_248_LEN 255
|
||||
#define MAVLINK_MSG_ID_248_MIN_LEN 255
|
||||
#define MAVLINK_MSG_ID_V2_EXTENSION_LEN 254
|
||||
#define MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN 254
|
||||
#define MAVLINK_MSG_ID_248_LEN 254
|
||||
#define MAVLINK_MSG_ID_248_MIN_LEN 254
|
||||
|
||||
#define MAVLINK_MSG_ID_V2_EXTENSION_CRC 254
|
||||
#define MAVLINK_MSG_ID_248_CRC 254
|
||||
#define MAVLINK_MSG_ID_V2_EXTENSION_CRC 102
|
||||
#define MAVLINK_MSG_ID_248_CRC 102
|
||||
|
||||
#define MAVLINK_MSG_V2_EXTENSION_FIELD_PAYLOAD_LEN 249
|
||||
#define MAVLINK_MSG_V2_EXTENSION_FIELD_PAYLOAD_LEN 248
|
||||
|
||||
#if MAVLINK_COMMAND_24BIT
|
||||
#define MAVLINK_MESSAGE_INFO_V2_EXTENSION { \
|
||||
@@ -31,7 +31,7 @@ typedef struct __mavlink_v2_extension_t {
|
||||
{ "target_system", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_v2_extension_t, target_system) }, \
|
||||
{ "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_v2_extension_t, target_component) }, \
|
||||
{ "message_type", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_v2_extension_t, message_type) }, \
|
||||
{ "payload", NULL, MAVLINK_TYPE_UINT8_T, 249, 6, offsetof(mavlink_v2_extension_t, payload) }, \
|
||||
{ "payload", NULL, MAVLINK_TYPE_UINT8_T, 248, 6, offsetof(mavlink_v2_extension_t, payload) }, \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
@@ -42,7 +42,7 @@ typedef struct __mavlink_v2_extension_t {
|
||||
{ "target_system", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_v2_extension_t, target_system) }, \
|
||||
{ "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_v2_extension_t, target_component) }, \
|
||||
{ "message_type", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_v2_extension_t, message_type) }, \
|
||||
{ "payload", NULL, MAVLINK_TYPE_UINT8_T, 249, 6, offsetof(mavlink_v2_extension_t, payload) }, \
|
||||
{ "payload", NULL, MAVLINK_TYPE_UINT8_T, 248, 6, offsetof(mavlink_v2_extension_t, payload) }, \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
@@ -69,7 +69,7 @@ static inline uint16_t mavlink_msg_v2_extension_pack(uint16_t system_id, uint8_t
|
||||
_mav_put_uint16_t(buf, 2, message_type);
|
||||
_mav_put_uint8_t(buf, 4, target_network);
|
||||
_mav_put_uint8_t(buf, 5, target_component);
|
||||
_mav_put_uint8_t_array(buf, 6, payload, 249);
|
||||
_mav_put_uint8_t_array(buf, 6, payload, 248);
|
||||
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
|
||||
#else
|
||||
mavlink_v2_extension_t packet;
|
||||
@@ -77,7 +77,7 @@ static inline uint16_t mavlink_msg_v2_extension_pack(uint16_t system_id, uint8_t
|
||||
packet.message_type = message_type;
|
||||
packet.target_network = target_network;
|
||||
packet.target_component = target_component;
|
||||
mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*249);
|
||||
mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*248);
|
||||
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
|
||||
#endif
|
||||
|
||||
@@ -108,7 +108,7 @@ static inline uint16_t mavlink_msg_v2_extension_pack_chan(uint16_t system_id, ui
|
||||
_mav_put_uint16_t(buf, 2, message_type);
|
||||
_mav_put_uint8_t(buf, 4, target_network);
|
||||
_mav_put_uint8_t(buf, 5, target_component);
|
||||
_mav_put_uint8_t_array(buf, 6, payload, 249);
|
||||
_mav_put_uint8_t_array(buf, 6, payload, 248);
|
||||
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
|
||||
#else
|
||||
mavlink_v2_extension_t packet;
|
||||
@@ -116,7 +116,7 @@ static inline uint16_t mavlink_msg_v2_extension_pack_chan(uint16_t system_id, ui
|
||||
packet.message_type = message_type;
|
||||
packet.target_network = target_network;
|
||||
packet.target_component = target_component;
|
||||
mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*249);
|
||||
mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*248);
|
||||
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_V2_EXTENSION_LEN);
|
||||
#endif
|
||||
|
||||
@@ -171,7 +171,7 @@ static inline void mavlink_msg_v2_extension_send(mavlink_channel_t chan, uint8_t
|
||||
_mav_put_uint16_t(buf, 2, message_type);
|
||||
_mav_put_uint8_t(buf, 4, target_network);
|
||||
_mav_put_uint8_t(buf, 5, target_component);
|
||||
_mav_put_uint8_t_array(buf, 6, payload, 249);
|
||||
_mav_put_uint8_t_array(buf, 6, payload, 248);
|
||||
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, buf, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC);
|
||||
#else
|
||||
mavlink_v2_extension_t packet;
|
||||
@@ -179,7 +179,7 @@ static inline void mavlink_msg_v2_extension_send(mavlink_channel_t chan, uint8_t
|
||||
packet.message_type = message_type;
|
||||
packet.target_network = target_network;
|
||||
packet.target_component = target_component;
|
||||
mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*249);
|
||||
mav_array_memcpy(packet.payload, payload, sizeof(uint8_t)*248);
|
||||
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, (const char *)&packet, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC);
|
||||
#endif
|
||||
}
|
||||
@@ -214,7 +214,7 @@ static inline void mavlink_msg_v2_extension_send_buf(mavlink_message_t *msgbuf,
|
||||
_mav_put_uint16_t(buf, 2, message_type);
|
||||
_mav_put_uint8_t(buf, 4, target_network);
|
||||
_mav_put_uint8_t(buf, 5, target_component);
|
||||
_mav_put_uint8_t_array(buf, 6, payload, 249);
|
||||
_mav_put_uint8_t_array(buf, 6, payload, 248);
|
||||
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, buf, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC);
|
||||
#else
|
||||
mavlink_v2_extension_t *packet = (mavlink_v2_extension_t *)msgbuf;
|
||||
@@ -222,7 +222,7 @@ static inline void mavlink_msg_v2_extension_send_buf(mavlink_message_t *msgbuf,
|
||||
packet->message_type = message_type;
|
||||
packet->target_network = target_network;
|
||||
packet->target_component = target_component;
|
||||
mav_array_memcpy(packet->payload, payload, sizeof(uint8_t)*249);
|
||||
mav_array_memcpy(packet->payload, payload, sizeof(uint8_t)*248);
|
||||
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_V2_EXTENSION, (const char *)packet, MAVLINK_MSG_ID_V2_EXTENSION_MIN_LEN, MAVLINK_MSG_ID_V2_EXTENSION_LEN, MAVLINK_MSG_ID_V2_EXTENSION_CRC);
|
||||
#endif
|
||||
}
|
||||
@@ -280,7 +280,7 @@ static inline uint16_t mavlink_msg_v2_extension_get_message_type(const mavlink_m
|
||||
*/
|
||||
static inline uint16_t mavlink_msg_v2_extension_get_payload(const mavlink_message_t* msg, uint8_t *payload)
|
||||
{
|
||||
return _MAV_RETURN_uint8_t_array(msg, payload, 249, 6);
|
||||
return _MAV_RETURN_uint8_t_array(msg, payload, 248, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user