obbey C89 comment style
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#ifndef MAVLINK_VERSION_H
|
||||
#define MAVLINK_VERSION_H
|
||||
|
||||
#define MAVLINK_BUILD_DATE "Fri May 04 2018"
|
||||
#define MAVLINK_BUILD_DATE "Sun May 06 2018"
|
||||
#define MAVLINK_WIRE_PROTOCOL_VERSION "2.0"
|
||||
#define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ namespace mavlink {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Visual Studio versions before 2010 don't have stdint.h, so we just error out.
|
||||
/* Visual Studio versions before 2010 don't have stdint.h, so we just error out.*/
|
||||
#if (defined _MSC_VER) && (_MSC_VER < 1600)
|
||||
#error "The C-MAVLink implementation requires Visual Studio 2010 or greater"
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
#ifndef MAVLINK_VERSION_H
|
||||
#define MAVLINK_VERSION_H
|
||||
|
||||
#define MAVLINK_BUILD_DATE "Fri May 04 2018"
|
||||
#define MAVLINK_BUILD_DATE "Sun May 06 2018"
|
||||
#define MAVLINK_WIRE_PROTOCOL_VERSION "2.0"
|
||||
#define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
#ifndef MAVLINK_VERSION_H
|
||||
#define MAVLINK_VERSION_H
|
||||
|
||||
#define MAVLINK_BUILD_DATE "Fri May 04 2018"
|
||||
#define MAVLINK_BUILD_DATE "Sun May 06 2018"
|
||||
#define MAVLINK_WIRE_PROTOCOL_VERSION "2.0"
|
||||
#define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255
|
||||
|
||||
|
||||
@@ -215,4 +215,4 @@ MAVLINK_HELPER void mavlink_euler_to_dcm(float roll, float pitch, float yaw, flo
|
||||
dcm[2][2] = cosPhi * cosThe;
|
||||
}
|
||||
|
||||
#endif // MAVLINK_NO_CONVERSION_HELPERS
|
||||
#endif /* MAVLINK_NO_CONVERSION_HELPERS */
|
||||
|
||||
+1
-1
@@ -66,6 +66,6 @@ MAVLINK_HELPER const mavlink_message_info_t *mavlink_get_message_info_by_name(co
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif // MAVLINK_USE_MESSAGE_INFO
|
||||
#endif /* MAVLINK_USE_MESSAGE_INFO */
|
||||
|
||||
|
||||
|
||||
+77
-77
@@ -23,8 +23,8 @@ namespace mavlink {
|
||||
MAVLINK_HELPER mavlink_status_t* mavlink_get_channel_status(uint8_t chan)
|
||||
{
|
||||
#ifdef MAVLINK_EXTERNAL_RX_STATUS
|
||||
// No m_mavlink_status array defined in function,
|
||||
// has to be defined externally
|
||||
/* No m_mavlink_status array defined in function, */
|
||||
/* has to be defined externally */
|
||||
#else
|
||||
static mavlink_status_t m_mavlink_status[MAVLINK_COMM_NUM_BUFFERS];
|
||||
#endif
|
||||
@@ -40,14 +40,14 @@ MAVLINK_HELPER mavlink_message_t* mavlink_get_channel_buffer(uint8_t chan)
|
||||
{
|
||||
|
||||
#ifdef MAVLINK_EXTERNAL_RX_BUFFER
|
||||
// No m_mavlink_buffer array defined in function,
|
||||
// has to be defined externally
|
||||
/* No m_mavlink_buffer array defined in function, */
|
||||
/* has to be defined externally */
|
||||
#else
|
||||
static mavlink_message_t m_mavlink_buffer[MAVLINK_COMM_NUM_BUFFERS];
|
||||
#endif
|
||||
return &m_mavlink_buffer[chan];
|
||||
}
|
||||
#endif // MAVLINK_GET_CHANNEL_BUFFER
|
||||
#endif /* MAVLINK_GET_CHANNEL_BUFFER */
|
||||
|
||||
/**
|
||||
* @brief Reset the status of a channel.
|
||||
@@ -137,7 +137,7 @@ MAVLINK_HELPER bool mavlink_signature_check(mavlink_signing_t *signing,
|
||||
return false;
|
||||
}
|
||||
|
||||
// now check timestamp
|
||||
/* now check timestamp */
|
||||
link_id = psig[0];
|
||||
tstamp.t64 = 0;
|
||||
memcpy(tstamp.t8, psig+1, 6);
|
||||
@@ -146,7 +146,7 @@ MAVLINK_HELPER bool mavlink_signature_check(mavlink_signing_t *signing,
|
||||
return false;
|
||||
}
|
||||
|
||||
// find stream
|
||||
/* find stream */
|
||||
for (i=0; i<signing_streams->num_signing_streams; i++) {
|
||||
if (msg->sysid == signing_streams->stream[i].sysid &&
|
||||
msg->compid == signing_streams->stream[i].compid &&
|
||||
@@ -156,14 +156,14 @@ MAVLINK_HELPER bool mavlink_signature_check(mavlink_signing_t *signing,
|
||||
}
|
||||
if (i == signing_streams->num_signing_streams) {
|
||||
if (signing_streams->num_signing_streams >= MAVLINK_MAX_SIGNING_STREAMS) {
|
||||
// over max number of streams
|
||||
/* over max number of streams */
|
||||
return false;
|
||||
}
|
||||
// new stream. Only accept if timestamp is not more than 1 minute old
|
||||
/* new stream. Only accept if timestamp is not more than 1 minute old */
|
||||
if (tstamp.t64 + 6000*1000UL < signing->timestamp) {
|
||||
return false;
|
||||
}
|
||||
// add new stream
|
||||
/* add new stream */
|
||||
signing_streams->stream[i].sysid = msg->sysid;
|
||||
signing_streams->stream[i].compid = msg->compid;
|
||||
signing_streams->stream[i].link_id = link_id;
|
||||
@@ -172,15 +172,15 @@ MAVLINK_HELPER bool mavlink_signature_check(mavlink_signing_t *signing,
|
||||
last_tstamp.t64 = 0;
|
||||
memcpy(last_tstamp.t8, signing_streams->stream[i].timestamp_bytes, 6);
|
||||
if (tstamp.t64 <= last_tstamp.t64) {
|
||||
// repeating old timestamp
|
||||
/* repeating old timestamp */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// remember last timestamp
|
||||
/* remember last timestamp */
|
||||
memcpy(signing_streams->stream[i].timestamp_bytes, psig+1, 6);
|
||||
|
||||
// our next timestamp must be at least this timestamp
|
||||
/* our next timestamp must be at least this timestamp */
|
||||
if (tstamp.t64 > signing->timestamp) {
|
||||
signing->timestamp = tstamp.t64;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ MAVLINK_HELPER uint16_t mavlink_finalize_message_buffer(mavlink_message_t* msg,
|
||||
msg->seq = status->current_tx_seq;
|
||||
status->current_tx_seq = status->current_tx_seq + 1;
|
||||
|
||||
// form the header as a byte array for the crc
|
||||
/* form the header as a byte array for the crc */
|
||||
buf[0] = msg->magic;
|
||||
buf[1] = msg->len;
|
||||
if (mavlink1) {
|
||||
@@ -305,7 +305,7 @@ MAVLINK_HELPER void _mav_finalize_message_chan_send(mavlink_channel_t chan, uint
|
||||
if (mavlink1) {
|
||||
length = min_length;
|
||||
if (msgid > 255) {
|
||||
// can't send 16 bit messages
|
||||
/* can't send 16 bit messages */
|
||||
_mav_parse_error(status);
|
||||
return;
|
||||
}
|
||||
@@ -325,7 +325,7 @@ MAVLINK_HELPER void _mav_finalize_message_chan_send(mavlink_channel_t chan, uint
|
||||
buf[0] = MAVLINK_STX;
|
||||
buf[1] = length;
|
||||
buf[2] = incompat_flags;
|
||||
buf[3] = 0; // compat_flags
|
||||
buf[3] = 0; /* compat_flags */
|
||||
buf[4] = status->current_tx_seq;
|
||||
buf[5] = mavlink_system.sysid;
|
||||
buf[6] = mavlink_system.compid;
|
||||
@@ -341,7 +341,7 @@ MAVLINK_HELPER void _mav_finalize_message_chan_send(mavlink_channel_t chan, uint
|
||||
ck[1] = (uint8_t)(checksum >> 8);
|
||||
|
||||
if (signing) {
|
||||
// possibly add a signature
|
||||
/* possibly add a signature */
|
||||
signature_len = mavlink_sign_packet(status->signing, signature, buf, header_len+1,
|
||||
(const uint8_t *)packet, length, ck);
|
||||
}
|
||||
@@ -367,7 +367,7 @@ MAVLINK_HELPER void _mavlink_resend_uart(mavlink_channel_t chan, const mavlink_m
|
||||
|
||||
ck[0] = (uint8_t)(msg->checksum & 0xFF);
|
||||
ck[1] = (uint8_t)(msg->checksum >> 8);
|
||||
// XXX use the right sequence here
|
||||
/* XXX use the right sequence here */
|
||||
|
||||
uint8_t header_len;
|
||||
uint8_t signature_len;
|
||||
@@ -376,7 +376,7 @@ MAVLINK_HELPER void _mavlink_resend_uart(mavlink_channel_t chan, const mavlink_m
|
||||
header_len = MAVLINK_CORE_HEADER_MAVLINK1_LEN + 1;
|
||||
signature_len = 0;
|
||||
MAVLINK_START_UART_SEND(chan, header_len + msg->len + 2 + signature_len);
|
||||
// we can't send the structure directly as it has extra mavlink2 elements in it
|
||||
/* we can't send the structure directly as it has extra mavlink2 elements in it */
|
||||
uint8_t buf[MAVLINK_CORE_HEADER_MAVLINK1_LEN + 1];
|
||||
buf[0] = msg->magic;
|
||||
buf[1] = msg->len;
|
||||
@@ -409,7 +409,7 @@ MAVLINK_HELPER void _mavlink_resend_uart(mavlink_channel_t chan, const mavlink_m
|
||||
}
|
||||
MAVLINK_END_UART_SEND(chan, header_len + msg->len + 2 + signature_len);
|
||||
}
|
||||
#endif // MAVLINK_USE_CONVENIENCE_FUNCTIONS
|
||||
#endif /* MAVLINK_USE_CONVENIENCE_FUNCTIONS */
|
||||
|
||||
/**
|
||||
* @brief Pack a message to send it over a serial byte stream
|
||||
@@ -503,12 +503,12 @@ MAVLINK_HELPER const mavlink_msg_entry_t *mavlink_get_msg_entry(uint32_t msgid)
|
||||
break;
|
||||
}
|
||||
if (mavlink_message_crcs[low].msgid != msgid) {
|
||||
// msgid is not in the table
|
||||
/* msgid is not in the table */
|
||||
return NULL;
|
||||
}
|
||||
return &mavlink_message_crcs[low];
|
||||
}
|
||||
#endif // MAVLINK_GET_MSG_ENTRY
|
||||
#endif /* MAVLINK_GET_MSG_ENTRY */
|
||||
|
||||
/*
|
||||
return the crc_extra value for a message
|
||||
@@ -623,7 +623,7 @@ MAVLINK_HELPER uint8_t mavlink_frame_char_buffer(mavlink_message_t* rxmsg,
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOT counting STX, LENGTH, SEQ, SYSID, COMPID, MSGID, CRC1 and CRC2
|
||||
/* NOT counting STX, LENGTH, SEQ, SYSID, COMPID, MSGID, CRC1 and CRC2 */
|
||||
rxmsg->len = c;
|
||||
status->packet_idx = 0;
|
||||
mavlink_update_checksum(rxmsg, c);
|
||||
@@ -640,7 +640,7 @@ MAVLINK_HELPER uint8_t mavlink_frame_char_buffer(mavlink_message_t* rxmsg,
|
||||
case MAVLINK_PARSE_STATE_GOT_LENGTH:
|
||||
rxmsg->incompat_flags = c;
|
||||
if ((rxmsg->incompat_flags & ~MAVLINK_IFLAG_MASK) != 0) {
|
||||
// message includes an incompatible feature flag
|
||||
/* message includes an incompatible feature flag */
|
||||
_mav_parse_error(status);
|
||||
status->msg_received = 0;
|
||||
status->parse_state = MAVLINK_PARSE_STATE_IDLE;
|
||||
@@ -740,7 +740,7 @@ MAVLINK_HELPER uint8_t mavlink_frame_char_buffer(mavlink_message_t* rxmsg,
|
||||
}
|
||||
rxmsg->ck[0] = c;
|
||||
|
||||
// zero-fill the packet to cope with short incoming packets
|
||||
/* zero-fill the packet to cope with short incoming packets */
|
||||
if (e && status->packet_idx < e->msg_len) {
|
||||
memset(&_MAV_PAYLOAD_NON_CONST(rxmsg)[status->packet_idx], 0, e->msg_len - status->packet_idx);
|
||||
}
|
||||
@@ -750,10 +750,10 @@ MAVLINK_HELPER uint8_t mavlink_frame_char_buffer(mavlink_message_t* rxmsg,
|
||||
case MAVLINK_PARSE_STATE_GOT_CRC1:
|
||||
case MAVLINK_PARSE_STATE_GOT_BAD_CRC1:
|
||||
if (status->parse_state == MAVLINK_PARSE_STATE_GOT_BAD_CRC1 || c != (rxmsg->checksum >> 8)) {
|
||||
// got a bad CRC message
|
||||
/* got a bad CRC message */
|
||||
status->msg_received = MAVLINK_FRAMING_BAD_CRC;
|
||||
} else {
|
||||
// Successfully got message
|
||||
/* Successfully got message */
|
||||
status->msg_received = MAVLINK_FRAMING_OK;
|
||||
}
|
||||
rxmsg->ck[1] = c;
|
||||
@@ -762,8 +762,8 @@ MAVLINK_HELPER uint8_t mavlink_frame_char_buffer(mavlink_message_t* rxmsg,
|
||||
status->parse_state = MAVLINK_PARSE_STATE_SIGNATURE_WAIT;
|
||||
status->signature_wait = MAVLINK_SIGNATURE_BLOCK_LEN;
|
||||
|
||||
// If the CRC is already wrong, don't overwrite msg_received,
|
||||
// otherwise we can end up with garbage flagged as valid.
|
||||
/* If the CRC is already wrong, don't overwrite msg_received, */
|
||||
/* otherwise we can end up with garbage flagged as valid. */
|
||||
if (status->msg_received != MAVLINK_FRAMING_BAD_CRC) {
|
||||
status->msg_received = MAVLINK_FRAMING_INCOMPLETE;
|
||||
}
|
||||
@@ -772,7 +772,7 @@ MAVLINK_HELPER uint8_t mavlink_frame_char_buffer(mavlink_message_t* rxmsg,
|
||||
(status->signing->accept_unsigned_callback == NULL ||
|
||||
!status->signing->accept_unsigned_callback(status, rxmsg->msgid))) {
|
||||
|
||||
// If the CRC is already wrong, don't overwrite msg_received.
|
||||
/* If the CRC is already wrong, don't overwrite msg_received. */
|
||||
if (status->msg_received != MAVLINK_FRAMING_BAD_CRC) {
|
||||
status->msg_received = MAVLINK_FRAMING_BAD_SIGNATURE;
|
||||
}
|
||||
@@ -785,12 +785,12 @@ MAVLINK_HELPER uint8_t mavlink_frame_char_buffer(mavlink_message_t* rxmsg,
|
||||
rxmsg->signature[MAVLINK_SIGNATURE_BLOCK_LEN-status->signature_wait] = c;
|
||||
status->signature_wait--;
|
||||
if (status->signature_wait == 0) {
|
||||
// we have the whole signature, check it is OK
|
||||
/* we have the whole signature, check it is OK */
|
||||
bool sig_ok = mavlink_signature_check(status->signing, status->signing_streams, rxmsg);
|
||||
if (!sig_ok &&
|
||||
(status->signing->accept_unsigned_callback &&
|
||||
status->signing->accept_unsigned_callback(status, rxmsg->msgid))) {
|
||||
// accepted via application level override
|
||||
/* accepted via application level override */
|
||||
sig_ok = true;
|
||||
}
|
||||
if (sig_ok) {
|
||||
@@ -805,22 +805,22 @@ MAVLINK_HELPER uint8_t mavlink_frame_char_buffer(mavlink_message_t* rxmsg,
|
||||
}
|
||||
|
||||
bufferIndex++;
|
||||
// If a message has been sucessfully decoded, check index
|
||||
/* If a message has been sucessfully decoded, check index */
|
||||
if (status->msg_received == MAVLINK_FRAMING_OK)
|
||||
{
|
||||
//while(status->current_seq != rxmsg->seq)
|
||||
//{
|
||||
// status->packet_rx_drop_count++;
|
||||
// status->current_seq++;
|
||||
//}
|
||||
/*while(status->current_seq != rxmsg->seq) */
|
||||
/*{ */
|
||||
/* status->packet_rx_drop_count++; */
|
||||
/* status->current_seq++; */
|
||||
/*} */
|
||||
status->current_rx_seq = rxmsg->seq;
|
||||
// Initial condition: If no packet has been received so far, drop count is undefined
|
||||
/* Initial condition: If no packet has been received so far, drop count is undefined */
|
||||
if (status->packet_rx_success_count == 0) status->packet_rx_drop_count = 0;
|
||||
// Count this packet as received
|
||||
/* Count this packet as received */
|
||||
status->packet_rx_success_count++;
|
||||
}
|
||||
|
||||
r_message->len = rxmsg->len; // Provide visibility on how far we are into current msg
|
||||
r_message->len = rxmsg->len; /* Provide visibility on how far we are into current msg */
|
||||
r_mavlink_status->parse_state = status->parse_state;
|
||||
r_mavlink_status->packet_idx = status->packet_idx;
|
||||
r_mavlink_status->current_rx_seq = status->current_rx_seq+1;
|
||||
@@ -966,7 +966,7 @@ MAVLINK_HELPER uint8_t mavlink_parse_char(uint8_t chan, uint8_t c, mavlink_messa
|
||||
uint8_t msg_received = mavlink_frame_char(chan, c, r_message, r_mavlink_status);
|
||||
if (msg_received == MAVLINK_FRAMING_BAD_CRC ||
|
||||
msg_received == MAVLINK_FRAMING_BAD_SIGNATURE) {
|
||||
// we got a bad CRC. Treat as a parse failure
|
||||
/* we got a bad CRC. Treat as a parse failure */
|
||||
mavlink_message_t* rxmsg = mavlink_get_channel_buffer(chan);
|
||||
mavlink_status_t* status = mavlink_get_channel_status(chan);
|
||||
_mav_parse_error(status);
|
||||
@@ -996,7 +996,7 @@ MAVLINK_HELPER uint8_t mavlink_parse_char(uint8_t chan, uint8_t c, mavlink_messa
|
||||
MAVLINK_HELPER uint8_t put_bitfield_n_by_index(int32_t b, uint8_t bits, uint8_t packet_index, uint8_t bit_index, uint8_t* r_bit_index, uint8_t* buffer)
|
||||
{
|
||||
uint16_t bits_remain = bits;
|
||||
// Transform number into network order
|
||||
/* Transform number into network order */
|
||||
int32_t v;
|
||||
uint8_t i_bit_index, i_byte_index, curr_bits_n;
|
||||
#if MAVLINK_NEED_BYTE_SWAP
|
||||
@@ -1014,44 +1014,44 @@ MAVLINK_HELPER uint8_t put_bitfield_n_by_index(int32_t b, uint8_t bits, uint8_t
|
||||
v = b;
|
||||
#endif
|
||||
|
||||
// buffer in
|
||||
// 01100000 01000000 00000000 11110001
|
||||
// buffer out
|
||||
// 11110001 00000000 01000000 01100000
|
||||
/* buffer in */
|
||||
/* 01100000 01000000 00000000 11110001 */
|
||||
/* buffer out */
|
||||
/* 11110001 00000000 01000000 01100000 */
|
||||
|
||||
// Existing partly filled byte (four free slots)
|
||||
// 0111xxxx
|
||||
/* Existing partly filled byte (four free slots) */
|
||||
/* 0111xxxx */
|
||||
|
||||
// Mask n free bits
|
||||
// 00001111 = 2^0 + 2^1 + 2^2 + 2^3 = 2^n - 1
|
||||
// = ((uint32_t)(1 << n)) - 1; // = 2^n - 1
|
||||
/* Mask n free bits */
|
||||
/* 00001111 = 2^0 + 2^1 + 2^2 + 2^3 = 2^n - 1 */
|
||||
/* = ((uint32_t)(1 << n)) - 1; // = 2^n - 1 */
|
||||
|
||||
// Shift n bits into the right position
|
||||
// out = in >> n;
|
||||
/* Shift n bits into the right position */
|
||||
/* out = in >> n; */
|
||||
|
||||
// Mask and shift bytes
|
||||
/* Mask and shift bytes */
|
||||
i_bit_index = bit_index;
|
||||
i_byte_index = packet_index;
|
||||
if (bit_index > 0)
|
||||
{
|
||||
// If bits were available at start, they were available
|
||||
// in the byte before the current index
|
||||
/* If bits were available at start, they were available */
|
||||
/* in the byte before the current index */
|
||||
i_byte_index--;
|
||||
}
|
||||
|
||||
// While bits have not been packed yet
|
||||
/* While bits have not been packed yet */
|
||||
while (bits_remain > 0)
|
||||
{
|
||||
// Bits still have to be packed
|
||||
// there can be more than 8 bits, so
|
||||
// we might have to pack them into more than one byte
|
||||
/* Bits still have to be packed */
|
||||
/* there can be more than 8 bits, so */
|
||||
/* we might have to pack them into more than one byte */
|
||||
|
||||
// First pack everything we can into the current 'open' byte
|
||||
//curr_bits_n = bits_remain << 3; // Equals bits_remain mod 8
|
||||
//FIXME
|
||||
/* First pack everything we can into the current 'open' byte */
|
||||
/*curr_bits_n = bits_remain << 3; // Equals bits_remain mod 8 */
|
||||
/*FIXME */
|
||||
if (bits_remain <= (uint8_t)(8 - i_bit_index))
|
||||
{
|
||||
// Enough space
|
||||
/* Enough space */
|
||||
curr_bits_n = (uint8_t)bits_remain;
|
||||
}
|
||||
else
|
||||
@@ -1059,36 +1059,36 @@ MAVLINK_HELPER uint8_t put_bitfield_n_by_index(int32_t b, uint8_t bits, uint8_t
|
||||
curr_bits_n = (8 - i_bit_index);
|
||||
}
|
||||
|
||||
// Pack these n bits into the current byte
|
||||
// Mask out whatever was at that position with ones (xxx11111)
|
||||
/* Pack these n bits into the current byte */
|
||||
/* Mask out whatever was at that position with ones (xxx11111) */
|
||||
buffer[i_byte_index] &= (0xFF >> (8 - curr_bits_n));
|
||||
// Put content to this position, by masking out the non-used part
|
||||
/* Put content to this position, by masking out the non-used part */
|
||||
buffer[i_byte_index] |= ((0x00 << curr_bits_n) & v);
|
||||
|
||||
// Increment the bit index
|
||||
/* Increment the bit index */
|
||||
i_bit_index += curr_bits_n;
|
||||
|
||||
// Now proceed to the next byte, if necessary
|
||||
/* Now proceed to the next byte, if necessary */
|
||||
bits_remain -= curr_bits_n;
|
||||
if (bits_remain > 0)
|
||||
{
|
||||
// Offer another 8 bits / one byte
|
||||
/* Offer another 8 bits / one byte */
|
||||
i_byte_index++;
|
||||
i_bit_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
*r_bit_index = i_bit_index;
|
||||
// If a partly filled byte is present, mark this as consumed
|
||||
/* If a partly filled byte is present, mark this as consumed */
|
||||
if (i_bit_index != 7) i_byte_index++;
|
||||
return i_byte_index - packet_index;
|
||||
}
|
||||
|
||||
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
|
||||
|
||||
// To make MAVLink work on your MCU, define comm_send_ch() if you wish
|
||||
// to send 1 byte at a time, or MAVLINK_SEND_UART_BYTES() to send a
|
||||
// whole packet at a time
|
||||
/* To make MAVLink work on your MCU, define comm_send_ch() if you wish */
|
||||
/* to send 1 byte at a time, or MAVLINK_SEND_UART_BYTES() to send a */
|
||||
/* whole packet at a time */
|
||||
|
||||
/*
|
||||
|
||||
@@ -1121,8 +1121,8 @@ MAVLINK_HELPER void _mavlink_send_uart(mavlink_channel_t chan, const char *buf,
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // MAVLINK_USE_CONVENIENCE_FUNCTIONS
|
||||
#endif /* MAVLINK_USE_CONVENIENCE_FUNCTIONS */
|
||||
|
||||
#ifdef MAVLINK_USE_CXX_NAMESPACE
|
||||
} // namespace mavlink
|
||||
} /* namespace mavlink */
|
||||
#endif
|
||||
|
||||
+6
-6
@@ -218,9 +218,9 @@ MAVLINK_HELPER void mavlink_sha256_final_48(mavlink_sha256_ctx *m, uint8_t resul
|
||||
|
||||
mavlink_sha256_update(m, zeros, dstart + 8);
|
||||
|
||||
// this ordering makes the result consistent with taking the first
|
||||
// 6 bytes of more conventional sha256 functions. It assumes
|
||||
// little-endian ordering of m->counter
|
||||
/* this ordering makes the result consistent with taking the first */
|
||||
/* 6 bytes of more conventional sha256 functions. It assumes */
|
||||
/* little-endian ordering of m->counter */
|
||||
result[0] = p[3];
|
||||
result[1] = p[2];
|
||||
result[2] = p[1];
|
||||
@@ -229,7 +229,7 @@ MAVLINK_HELPER void mavlink_sha256_final_48(mavlink_sha256_ctx *m, uint8_t resul
|
||||
result[5] = p[6];
|
||||
}
|
||||
|
||||
// prevent conflicts with users of the header
|
||||
/* prevent conflicts with users of the header */
|
||||
#undef A
|
||||
#undef B
|
||||
#undef C
|
||||
@@ -246,7 +246,7 @@ MAVLINK_HELPER void mavlink_sha256_final_48(mavlink_sha256_ctx *m, uint8_t resul
|
||||
#undef sigma1
|
||||
|
||||
#ifdef MAVLINK_USE_CXX_NAMESPACE
|
||||
} // namespace mavlink
|
||||
} /* namespace mavlink */
|
||||
#endif
|
||||
|
||||
#endif // HAVE_MAVLINK_SHA256
|
||||
#endif /* HAVE_MAVLINK_SHA256 */
|
||||
|
||||
+58
-58
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
// Visual Studio versions before 2010 don't have stdint.h, so we just error out.
|
||||
/* Visual Studio versions before 2010 don't have stdint.h, so we just error out. */
|
||||
#if (defined _MSC_VER) && (_MSC_VER < 1600)
|
||||
#error "The C-MAVLink implementation requires Visual Studio 2010 or greater"
|
||||
#endif
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace mavlink {
|
||||
#endif
|
||||
|
||||
// Macro to define packed structures
|
||||
/* Macro to define packed structures */
|
||||
#ifdef __GNUC__
|
||||
#define MAVPACKED( __Declaration__ ) __Declaration__ __attribute__((packed))
|
||||
#elif defined __ARMCC_VERSION
|
||||
@@ -23,19 +23,19 @@ namespace mavlink {
|
||||
#endif
|
||||
|
||||
#ifndef MAVLINK_MAX_PAYLOAD_LEN
|
||||
// it is possible to override this, but be careful!
|
||||
#define MAVLINK_MAX_PAYLOAD_LEN 255 ///< Maximum payload length
|
||||
/* it is possible to override this, but be careful! */
|
||||
#define MAVLINK_MAX_PAYLOAD_LEN 255 /*< Maximum payload length */
|
||||
#endif
|
||||
|
||||
#define MAVLINK_CORE_HEADER_LEN 9 ///< Length of core header (of the comm. layer)
|
||||
#define MAVLINK_CORE_HEADER_MAVLINK1_LEN 5 ///< Length of MAVLink1 core header (of the comm. layer)
|
||||
#define MAVLINK_NUM_HEADER_BYTES (MAVLINK_CORE_HEADER_LEN + 1) ///< Length of all header bytes, including core and stx
|
||||
#define MAVLINK_CORE_HEADER_LEN 9 /*< Length of core header (of the comm. layer) */
|
||||
#define MAVLINK_CORE_HEADER_MAVLINK1_LEN 5 /*< Length of MAVLink1 core header (of the comm. layer) */
|
||||
#define MAVLINK_NUM_HEADER_BYTES (MAVLINK_CORE_HEADER_LEN + 1) /*< Length of all header bytes, including core and stx */
|
||||
#define MAVLINK_NUM_CHECKSUM_BYTES 2
|
||||
#define MAVLINK_NUM_NON_PAYLOAD_BYTES (MAVLINK_NUM_HEADER_BYTES + MAVLINK_NUM_CHECKSUM_BYTES)
|
||||
|
||||
#define MAVLINK_SIGNATURE_BLOCK_LEN 13
|
||||
|
||||
#define MAVLINK_MAX_PACKET_LEN (MAVLINK_MAX_PAYLOAD_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES + MAVLINK_SIGNATURE_BLOCK_LEN) ///< Maximum packet length
|
||||
#define MAVLINK_MAX_PACKET_LEN (MAVLINK_MAX_PAYLOAD_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES + MAVLINK_SIGNATURE_BLOCK_LEN) /*< Maximum packet length */
|
||||
|
||||
/**
|
||||
* Old-style 4 byte param union
|
||||
@@ -103,23 +103,23 @@ typedef struct param_union_extended {
|
||||
*/
|
||||
MAVPACKED(
|
||||
typedef struct __mavlink_system {
|
||||
uint8_t sysid; ///< Used by the MAVLink message_xx_send() convenience function
|
||||
uint8_t compid; ///< Used by the MAVLink message_xx_send() convenience function
|
||||
uint8_t sysid; /*< Used by the MAVLink message_xx_send() convenience function */
|
||||
uint8_t compid; /*< Used by the MAVLink message_xx_send() convenience function */
|
||||
}) mavlink_system_t;
|
||||
|
||||
MAVPACKED(
|
||||
typedef struct __mavlink_message {
|
||||
uint16_t checksum; ///< sent at end of packet
|
||||
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
|
||||
uint32_t msgid:24; ///< ID of message in payload
|
||||
uint16_t checksum; /*< sent at end of packet */
|
||||
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 */
|
||||
uint32_t msgid:24; /*< ID of message in payload */
|
||||
uint64_t payload64[(MAVLINK_MAX_PAYLOAD_LEN+MAVLINK_NUM_CHECKSUM_BYTES+7)/8];
|
||||
uint8_t ck[2]; ///< incoming checksum bytes
|
||||
uint8_t ck[2]; /*< incoming checksum bytes */
|
||||
uint8_t signature[MAVLINK_SIGNATURE_BLOCK_LEN];
|
||||
}) mavlink_message_t;
|
||||
|
||||
@@ -140,27 +140,27 @@ typedef enum {
|
||||
#define MAVLINK_MAX_FIELDS 64
|
||||
|
||||
typedef struct __mavlink_field_info {
|
||||
const char *name; // name of this field
|
||||
const char *print_format; // printing format hint, or NULL
|
||||
mavlink_message_type_t type; // type of this field
|
||||
unsigned int array_length; // if non-zero, field is an array
|
||||
unsigned int wire_offset; // offset of each field in the payload
|
||||
unsigned int structure_offset; // offset in a C structure
|
||||
const char *name; /* name of this field */
|
||||
const char *print_format; /* printing format hint, or NULL */
|
||||
mavlink_message_type_t type; /* type of this field */
|
||||
unsigned int array_length; /* if non-zero, field is an array */
|
||||
unsigned int wire_offset; /* offset of each field in the payload */
|
||||
unsigned int structure_offset; /* offset in a C structure */
|
||||
} mavlink_field_info_t;
|
||||
|
||||
// note that in this structure the order of fields is the order
|
||||
// in the XML file, not necessary the wire order
|
||||
/* note that in this structure the order of fields is the order */
|
||||
/* in the XML file, not necessary the wire order */
|
||||
typedef struct __mavlink_message_info {
|
||||
uint32_t msgid; // message ID
|
||||
const char *name; // name of the message
|
||||
unsigned num_fields; // how many fields in this message
|
||||
mavlink_field_info_t fields[MAVLINK_MAX_FIELDS]; // field information
|
||||
uint32_t msgid; /* message ID */
|
||||
const char *name; /* name of the message */
|
||||
unsigned num_fields; /* how many fields in this message */
|
||||
mavlink_field_info_t fields[MAVLINK_MAX_FIELDS]; /* field information */
|
||||
} mavlink_message_info_t;
|
||||
|
||||
#define _MAV_PAYLOAD(msg) ((const char *)(&((msg)->payload64[0])))
|
||||
#define _MAV_PAYLOAD_NON_CONST(msg) ((char *)(&((msg)->payload64[0])))
|
||||
|
||||
// checksum is immediately after the payload bytes
|
||||
/* checksum is immediately after the payload bytes */
|
||||
#define mavlink_ck_a(msg) *((msg)->len + (uint8_t *)_MAV_PAYLOAD_NON_CONST(msg))
|
||||
#define mavlink_ck_b(msg) *(((msg)->len+(uint16_t)1) + (uint8_t *)_MAV_PAYLOAD_NON_CONST(msg))
|
||||
|
||||
@@ -201,7 +201,7 @@ typedef enum {
|
||||
MAVLINK_PARSE_STATE_GOT_CRC1,
|
||||
MAVLINK_PARSE_STATE_GOT_BAD_CRC1,
|
||||
MAVLINK_PARSE_STATE_SIGNATURE_WAIT
|
||||
} mavlink_parse_state_t; ///< The state machine for the comm parser
|
||||
} mavlink_parse_state_t; /*< The state machine for the comm parser */
|
||||
|
||||
typedef enum {
|
||||
MAVLINK_FRAMING_INCOMPLETE=0,
|
||||
@@ -210,27 +210,27 @@ typedef enum {
|
||||
MAVLINK_FRAMING_BAD_SIGNATURE=3
|
||||
} mavlink_framing_t;
|
||||
|
||||
#define MAVLINK_STATUS_FLAG_IN_MAVLINK1 1 // last incoming packet was MAVLink1
|
||||
#define MAVLINK_STATUS_FLAG_OUT_MAVLINK1 2 // generate MAVLink1 by default
|
||||
#define MAVLINK_STATUS_FLAG_IN_SIGNED 4 // last incoming packet was signed and validated
|
||||
#define MAVLINK_STATUS_FLAG_IN_BADSIG 8 // last incoming packet had a bad signature
|
||||
#define MAVLINK_STATUS_FLAG_IN_MAVLINK1 1 /* last incoming packet was MAVLink1 */
|
||||
#define MAVLINK_STATUS_FLAG_OUT_MAVLINK1 2 /* generate MAVLink1 by default */
|
||||
#define MAVLINK_STATUS_FLAG_IN_SIGNED 4 /* last incoming packet was signed and validated */
|
||||
#define MAVLINK_STATUS_FLAG_IN_BADSIG 8 /* last incoming packet had a bad signature */
|
||||
|
||||
#define MAVLINK_STX_MAVLINK1 0xFE // marker for old protocol
|
||||
#define MAVLINK_STX_MAVLINK1 0xFE /* marker for old protocol */
|
||||
|
||||
typedef struct __mavlink_status {
|
||||
uint8_t msg_received; ///< Number of received messages
|
||||
uint8_t buffer_overrun; ///< Number of buffer overruns
|
||||
uint8_t parse_error; ///< Number of parse errors
|
||||
mavlink_parse_state_t parse_state; ///< Parsing state machine
|
||||
uint8_t packet_idx; ///< Index in current packet
|
||||
uint8_t current_rx_seq; ///< Sequence number of last packet received
|
||||
uint8_t current_tx_seq; ///< Sequence number of last packet sent
|
||||
uint16_t packet_rx_success_count; ///< Received packets
|
||||
uint16_t packet_rx_drop_count; ///< Number of packet drops
|
||||
uint8_t flags; ///< MAVLINK_STATUS_FLAG_*
|
||||
uint8_t signature_wait; ///< number of signature bytes left to receive
|
||||
struct __mavlink_signing *signing; ///< optional signing state
|
||||
struct __mavlink_signing_streams *signing_streams; ///< global record of stream timestamps
|
||||
uint8_t msg_received; /*< Number of received messages */
|
||||
uint8_t buffer_overrun; /*< Number of buffer overruns */
|
||||
uint8_t parse_error; /*< Number of parse errors */
|
||||
mavlink_parse_state_t parse_state; /*< Parsing state machine */
|
||||
uint8_t packet_idx; /*< Index in current packet */
|
||||
uint8_t current_rx_seq; /*< Sequence number of last packet received */
|
||||
uint8_t current_tx_seq; /*< Sequence number of last packet sent */
|
||||
uint16_t packet_rx_success_count; /*< Received packets */
|
||||
uint16_t packet_rx_drop_count; /*< Number of packet drops */
|
||||
uint8_t flags; /*< MAVLINK_STATUS_FLAG_* */
|
||||
uint8_t signature_wait; /*< number of signature bytes left to receive */
|
||||
struct __mavlink_signing *signing; /*< optional signing state */
|
||||
struct __mavlink_signing_streams *signing_streams; /*< global record of stream timestamps */
|
||||
} mavlink_status_t;
|
||||
|
||||
/*
|
||||
@@ -247,7 +247,7 @@ typedef bool (*mavlink_accept_unsigned_t)(const mavlink_status_t *status, uint32
|
||||
state of MAVLink signing for this channel
|
||||
*/
|
||||
typedef struct __mavlink_signing {
|
||||
uint8_t flags; ///< MAVLINK_SIGNING_FLAG_*
|
||||
uint8_t flags; /*< MAVLINK_SIGNING_FLAG_* */
|
||||
uint8_t link_id;
|
||||
uint64_t timestamp;
|
||||
uint8_t secret_key[32];
|
||||
@@ -285,17 +285,17 @@ typedef struct __mavlink_msg_entry {
|
||||
uint32_t msgid;
|
||||
uint8_t crc_extra;
|
||||
uint8_t msg_len;
|
||||
uint8_t flags; // MAV_MSG_ENTRY_FLAG_*
|
||||
uint8_t target_system_ofs; // payload offset to target_system, or 0
|
||||
uint8_t target_component_ofs; // payload offset to target_component, or 0
|
||||
uint8_t flags; /* MAV_MSG_ENTRY_FLAG_* */
|
||||
uint8_t target_system_ofs; /* payload offset to target_system, or 0 */
|
||||
uint8_t target_component_ofs; /* payload offset to target_component, or 0 */
|
||||
} mavlink_msg_entry_t;
|
||||
|
||||
/*
|
||||
incompat_flags bits
|
||||
*/
|
||||
#define MAVLINK_IFLAG_SIGNED 0x01
|
||||
#define MAVLINK_IFLAG_MASK 0x01 // mask of all understood bits
|
||||
#define MAVLINK_IFLAG_MASK 0x01 /* mask of all understood bits */
|
||||
|
||||
#ifdef MAVLINK_USE_CXX_NAMESPACE
|
||||
} // namespace mavlink
|
||||
} /* namespace mavlink */
|
||||
#endif
|
||||
|
||||
+3
-3
@@ -74,7 +74,7 @@
|
||||
#define MAVLINK_HELPER static inline
|
||||
#include "mavlink_helpers.h"
|
||||
|
||||
#endif // MAVLINK_SEPARATE_HELPERS
|
||||
#endif /* MAVLINK_SEPARATE_HELPERS */
|
||||
|
||||
|
||||
/**
|
||||
@@ -265,7 +265,7 @@ _MAV_MSG_RETURN_TYPE(uint64_t, 8)
|
||||
_MAV_MSG_RETURN_TYPE(int64_t, 8)
|
||||
_MAV_MSG_RETURN_TYPE(float, 4)
|
||||
_MAV_MSG_RETURN_TYPE(double, 8)
|
||||
#else // nicely aligned, no swap
|
||||
#else /* nicely aligned, no swap */
|
||||
#define _MAV_MSG_RETURN_TYPE(TYPE) \
|
||||
static inline TYPE _MAV_RETURN_## TYPE(const mavlink_message_t *msg, uint8_t ofs) \
|
||||
{ return *(const TYPE *)(&_MAV_PAYLOAD(msg)[ofs]);}
|
||||
@@ -278,7 +278,7 @@ _MAV_MSG_RETURN_TYPE(uint64_t)
|
||||
_MAV_MSG_RETURN_TYPE(int64_t)
|
||||
_MAV_MSG_RETURN_TYPE(float)
|
||||
_MAV_MSG_RETURN_TYPE(double)
|
||||
#endif // MAVLINK_NEED_BYTE_SWAP
|
||||
#endif /* MAVLINK_NEED_BYTE_SWAP */
|
||||
|
||||
static inline uint16_t _MAV_RETURN_char_array(const mavlink_message_t *msg, char *value,
|
||||
uint8_t array_length, uint8_t wire_offset)
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
#ifndef MAVLINK_VERSION_H
|
||||
#define MAVLINK_VERSION_H
|
||||
|
||||
#define MAVLINK_BUILD_DATE "Fri May 04 2018"
|
||||
#define MAVLINK_BUILD_DATE "Sun May 06 2018"
|
||||
#define MAVLINK_WIRE_PROTOCOL_VERSION "2.0"
|
||||
#define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 255
|
||||
|
||||
|
||||
Reference in New Issue
Block a user