Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
MAVlink/include/pixhawk/mavlink_msg_data_transmission_handshake.h@0:826c6171fc1b, 2012-06-20 (annotated)
- Committer:
- shimniok
- Date:
- Wed Jun 20 14:57:48 2012 +0000
- Revision:
- 0:826c6171fc1b
Updated documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:826c6171fc1b | 1 | // MESSAGE DATA_TRANSMISSION_HANDSHAKE PACKING |
shimniok | 0:826c6171fc1b | 2 | |
shimniok | 0:826c6171fc1b | 3 | #define MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE 170 |
shimniok | 0:826c6171fc1b | 4 | |
shimniok | 0:826c6171fc1b | 5 | typedef struct __mavlink_data_transmission_handshake_t |
shimniok | 0:826c6171fc1b | 6 | { |
shimniok | 0:826c6171fc1b | 7 | uint8_t type; ///< type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h) |
shimniok | 0:826c6171fc1b | 8 | uint32_t size; ///< total data size in bytes (set on ACK only) |
shimniok | 0:826c6171fc1b | 9 | uint8_t packets; ///< number of packets beeing sent (set on ACK only) |
shimniok | 0:826c6171fc1b | 10 | uint8_t payload; ///< payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only) |
shimniok | 0:826c6171fc1b | 11 | uint8_t jpg_quality; ///< JPEG quality out of [1,100] |
shimniok | 0:826c6171fc1b | 12 | |
shimniok | 0:826c6171fc1b | 13 | } mavlink_data_transmission_handshake_t; |
shimniok | 0:826c6171fc1b | 14 | |
shimniok | 0:826c6171fc1b | 15 | |
shimniok | 0:826c6171fc1b | 16 | |
shimniok | 0:826c6171fc1b | 17 | /** |
shimniok | 0:826c6171fc1b | 18 | * @brief Pack a data_transmission_handshake message |
shimniok | 0:826c6171fc1b | 19 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 20 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 21 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 22 | * |
shimniok | 0:826c6171fc1b | 23 | * @param type type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h) |
shimniok | 0:826c6171fc1b | 24 | * @param size total data size in bytes (set on ACK only) |
shimniok | 0:826c6171fc1b | 25 | * @param packets number of packets beeing sent (set on ACK only) |
shimniok | 0:826c6171fc1b | 26 | * @param payload payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only) |
shimniok | 0:826c6171fc1b | 27 | * @param jpg_quality JPEG quality out of [1,100] |
shimniok | 0:826c6171fc1b | 28 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 29 | */ |
shimniok | 0:826c6171fc1b | 30 | static inline uint16_t mavlink_msg_data_transmission_handshake_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t type, uint32_t size, uint8_t packets, uint8_t payload, uint8_t jpg_quality) |
shimniok | 0:826c6171fc1b | 31 | { |
shimniok | 0:826c6171fc1b | 32 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 33 | msg->msgid = MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE; |
shimniok | 0:826c6171fc1b | 34 | |
shimniok | 0:826c6171fc1b | 35 | i += put_uint8_t_by_index(type, i, msg->payload); // type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h) |
shimniok | 0:826c6171fc1b | 36 | i += put_uint32_t_by_index(size, i, msg->payload); // total data size in bytes (set on ACK only) |
shimniok | 0:826c6171fc1b | 37 | i += put_uint8_t_by_index(packets, i, msg->payload); // number of packets beeing sent (set on ACK only) |
shimniok | 0:826c6171fc1b | 38 | i += put_uint8_t_by_index(payload, i, msg->payload); // payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only) |
shimniok | 0:826c6171fc1b | 39 | i += put_uint8_t_by_index(jpg_quality, i, msg->payload); // JPEG quality out of [1,100] |
shimniok | 0:826c6171fc1b | 40 | |
shimniok | 0:826c6171fc1b | 41 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:826c6171fc1b | 42 | } |
shimniok | 0:826c6171fc1b | 43 | |
shimniok | 0:826c6171fc1b | 44 | /** |
shimniok | 0:826c6171fc1b | 45 | * @brief Pack a data_transmission_handshake message |
shimniok | 0:826c6171fc1b | 46 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 47 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 48 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:826c6171fc1b | 49 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 50 | * @param type type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h) |
shimniok | 0:826c6171fc1b | 51 | * @param size total data size in bytes (set on ACK only) |
shimniok | 0:826c6171fc1b | 52 | * @param packets number of packets beeing sent (set on ACK only) |
shimniok | 0:826c6171fc1b | 53 | * @param payload payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only) |
shimniok | 0:826c6171fc1b | 54 | * @param jpg_quality JPEG quality out of [1,100] |
shimniok | 0:826c6171fc1b | 55 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 56 | */ |
shimniok | 0:826c6171fc1b | 57 | static inline uint16_t mavlink_msg_data_transmission_handshake_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t type, uint32_t size, uint8_t packets, uint8_t payload, uint8_t jpg_quality) |
shimniok | 0:826c6171fc1b | 58 | { |
shimniok | 0:826c6171fc1b | 59 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 60 | msg->msgid = MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE; |
shimniok | 0:826c6171fc1b | 61 | |
shimniok | 0:826c6171fc1b | 62 | i += put_uint8_t_by_index(type, i, msg->payload); // type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h) |
shimniok | 0:826c6171fc1b | 63 | i += put_uint32_t_by_index(size, i, msg->payload); // total data size in bytes (set on ACK only) |
shimniok | 0:826c6171fc1b | 64 | i += put_uint8_t_by_index(packets, i, msg->payload); // number of packets beeing sent (set on ACK only) |
shimniok | 0:826c6171fc1b | 65 | i += put_uint8_t_by_index(payload, i, msg->payload); // payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only) |
shimniok | 0:826c6171fc1b | 66 | i += put_uint8_t_by_index(jpg_quality, i, msg->payload); // JPEG quality out of [1,100] |
shimniok | 0:826c6171fc1b | 67 | |
shimniok | 0:826c6171fc1b | 68 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:826c6171fc1b | 69 | } |
shimniok | 0:826c6171fc1b | 70 | |
shimniok | 0:826c6171fc1b | 71 | /** |
shimniok | 0:826c6171fc1b | 72 | * @brief Encode a data_transmission_handshake struct into a message |
shimniok | 0:826c6171fc1b | 73 | * |
shimniok | 0:826c6171fc1b | 74 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 75 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 76 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 77 | * @param data_transmission_handshake C-struct to read the message contents from |
shimniok | 0:826c6171fc1b | 78 | */ |
shimniok | 0:826c6171fc1b | 79 | static inline uint16_t mavlink_msg_data_transmission_handshake_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_data_transmission_handshake_t* data_transmission_handshake) |
shimniok | 0:826c6171fc1b | 80 | { |
shimniok | 0:826c6171fc1b | 81 | return mavlink_msg_data_transmission_handshake_pack(system_id, component_id, msg, data_transmission_handshake->type, data_transmission_handshake->size, data_transmission_handshake->packets, data_transmission_handshake->payload, data_transmission_handshake->jpg_quality); |
shimniok | 0:826c6171fc1b | 82 | } |
shimniok | 0:826c6171fc1b | 83 | |
shimniok | 0:826c6171fc1b | 84 | /** |
shimniok | 0:826c6171fc1b | 85 | * @brief Send a data_transmission_handshake message |
shimniok | 0:826c6171fc1b | 86 | * @param chan MAVLink channel to send the message |
shimniok | 0:826c6171fc1b | 87 | * |
shimniok | 0:826c6171fc1b | 88 | * @param type type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h) |
shimniok | 0:826c6171fc1b | 89 | * @param size total data size in bytes (set on ACK only) |
shimniok | 0:826c6171fc1b | 90 | * @param packets number of packets beeing sent (set on ACK only) |
shimniok | 0:826c6171fc1b | 91 | * @param payload payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only) |
shimniok | 0:826c6171fc1b | 92 | * @param jpg_quality JPEG quality out of [1,100] |
shimniok | 0:826c6171fc1b | 93 | */ |
shimniok | 0:826c6171fc1b | 94 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:826c6171fc1b | 95 | |
shimniok | 0:826c6171fc1b | 96 | static inline void mavlink_msg_data_transmission_handshake_send(mavlink_channel_t chan, uint8_t type, uint32_t size, uint8_t packets, uint8_t payload, uint8_t jpg_quality) |
shimniok | 0:826c6171fc1b | 97 | { |
shimniok | 0:826c6171fc1b | 98 | mavlink_message_t msg; |
shimniok | 0:826c6171fc1b | 99 | mavlink_msg_data_transmission_handshake_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, type, size, packets, payload, jpg_quality); |
shimniok | 0:826c6171fc1b | 100 | mavlink_send_uart(chan, &msg); |
shimniok | 0:826c6171fc1b | 101 | } |
shimniok | 0:826c6171fc1b | 102 | |
shimniok | 0:826c6171fc1b | 103 | #endif |
shimniok | 0:826c6171fc1b | 104 | // MESSAGE DATA_TRANSMISSION_HANDSHAKE UNPACKING |
shimniok | 0:826c6171fc1b | 105 | |
shimniok | 0:826c6171fc1b | 106 | /** |
shimniok | 0:826c6171fc1b | 107 | * @brief Get field type from data_transmission_handshake message |
shimniok | 0:826c6171fc1b | 108 | * |
shimniok | 0:826c6171fc1b | 109 | * @return type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h) |
shimniok | 0:826c6171fc1b | 110 | */ |
shimniok | 0:826c6171fc1b | 111 | static inline uint8_t mavlink_msg_data_transmission_handshake_get_type(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 112 | { |
shimniok | 0:826c6171fc1b | 113 | return (uint8_t)(msg->payload)[0]; |
shimniok | 0:826c6171fc1b | 114 | } |
shimniok | 0:826c6171fc1b | 115 | |
shimniok | 0:826c6171fc1b | 116 | /** |
shimniok | 0:826c6171fc1b | 117 | * @brief Get field size from data_transmission_handshake message |
shimniok | 0:826c6171fc1b | 118 | * |
shimniok | 0:826c6171fc1b | 119 | * @return total data size in bytes (set on ACK only) |
shimniok | 0:826c6171fc1b | 120 | */ |
shimniok | 0:826c6171fc1b | 121 | static inline uint32_t mavlink_msg_data_transmission_handshake_get_size(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 122 | { |
shimniok | 0:826c6171fc1b | 123 | generic_32bit r; |
shimniok | 0:826c6171fc1b | 124 | r.b[3] = (msg->payload+sizeof(uint8_t))[0]; |
shimniok | 0:826c6171fc1b | 125 | r.b[2] = (msg->payload+sizeof(uint8_t))[1]; |
shimniok | 0:826c6171fc1b | 126 | r.b[1] = (msg->payload+sizeof(uint8_t))[2]; |
shimniok | 0:826c6171fc1b | 127 | r.b[0] = (msg->payload+sizeof(uint8_t))[3]; |
shimniok | 0:826c6171fc1b | 128 | return (uint32_t)r.i; |
shimniok | 0:826c6171fc1b | 129 | } |
shimniok | 0:826c6171fc1b | 130 | |
shimniok | 0:826c6171fc1b | 131 | /** |
shimniok | 0:826c6171fc1b | 132 | * @brief Get field packets from data_transmission_handshake message |
shimniok | 0:826c6171fc1b | 133 | * |
shimniok | 0:826c6171fc1b | 134 | * @return number of packets beeing sent (set on ACK only) |
shimniok | 0:826c6171fc1b | 135 | */ |
shimniok | 0:826c6171fc1b | 136 | static inline uint8_t mavlink_msg_data_transmission_handshake_get_packets(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 137 | { |
shimniok | 0:826c6171fc1b | 138 | return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint32_t))[0]; |
shimniok | 0:826c6171fc1b | 139 | } |
shimniok | 0:826c6171fc1b | 140 | |
shimniok | 0:826c6171fc1b | 141 | /** |
shimniok | 0:826c6171fc1b | 142 | * @brief Get field payload from data_transmission_handshake message |
shimniok | 0:826c6171fc1b | 143 | * |
shimniok | 0:826c6171fc1b | 144 | * @return payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only) |
shimniok | 0:826c6171fc1b | 145 | */ |
shimniok | 0:826c6171fc1b | 146 | static inline uint8_t mavlink_msg_data_transmission_handshake_get_payload(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 147 | { |
shimniok | 0:826c6171fc1b | 148 | return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint32_t)+sizeof(uint8_t))[0]; |
shimniok | 0:826c6171fc1b | 149 | } |
shimniok | 0:826c6171fc1b | 150 | |
shimniok | 0:826c6171fc1b | 151 | /** |
shimniok | 0:826c6171fc1b | 152 | * @brief Get field jpg_quality from data_transmission_handshake message |
shimniok | 0:826c6171fc1b | 153 | * |
shimniok | 0:826c6171fc1b | 154 | * @return JPEG quality out of [1,100] |
shimniok | 0:826c6171fc1b | 155 | */ |
shimniok | 0:826c6171fc1b | 156 | static inline uint8_t mavlink_msg_data_transmission_handshake_get_jpg_quality(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 157 | { |
shimniok | 0:826c6171fc1b | 158 | return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint32_t)+sizeof(uint8_t)+sizeof(uint8_t))[0]; |
shimniok | 0:826c6171fc1b | 159 | } |
shimniok | 0:826c6171fc1b | 160 | |
shimniok | 0:826c6171fc1b | 161 | /** |
shimniok | 0:826c6171fc1b | 162 | * @brief Decode a data_transmission_handshake message into a struct |
shimniok | 0:826c6171fc1b | 163 | * |
shimniok | 0:826c6171fc1b | 164 | * @param msg The message to decode |
shimniok | 0:826c6171fc1b | 165 | * @param data_transmission_handshake C-struct to decode the message contents into |
shimniok | 0:826c6171fc1b | 166 | */ |
shimniok | 0:826c6171fc1b | 167 | static inline void mavlink_msg_data_transmission_handshake_decode(const mavlink_message_t* msg, mavlink_data_transmission_handshake_t* data_transmission_handshake) |
shimniok | 0:826c6171fc1b | 168 | { |
shimniok | 0:826c6171fc1b | 169 | data_transmission_handshake->type = mavlink_msg_data_transmission_handshake_get_type(msg); |
shimniok | 0:826c6171fc1b | 170 | data_transmission_handshake->size = mavlink_msg_data_transmission_handshake_get_size(msg); |
shimniok | 0:826c6171fc1b | 171 | data_transmission_handshake->packets = mavlink_msg_data_transmission_handshake_get_packets(msg); |
shimniok | 0:826c6171fc1b | 172 | data_transmission_handshake->payload = mavlink_msg_data_transmission_handshake_get_payload(msg); |
shimniok | 0:826c6171fc1b | 173 | data_transmission_handshake->jpg_quality = mavlink_msg_data_transmission_handshake_get_jpg_quality(msg); |
shimniok | 0:826c6171fc1b | 174 | } |