Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.

Dependencies:   mbed Watchdog SDFileSystem DigoleSerialDisp

Committer:
shimniok
Date:
Fri Nov 30 16:11:53 2018 +0000
Revision:
25:bb5356402687
Parent:
0:a6a169de725f
Initial publish of revised version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:a6a169de725f 1 // MESSAGE REQUEST_DATA_STREAM PACKING
shimniok 0:a6a169de725f 2
shimniok 0:a6a169de725f 3 #define MAVLINK_MSG_ID_REQUEST_DATA_STREAM 66
shimniok 0:a6a169de725f 4
shimniok 0:a6a169de725f 5 typedef struct __mavlink_request_data_stream_t
shimniok 0:a6a169de725f 6 {
shimniok 0:a6a169de725f 7 uint8_t target_system; ///< The target requested to send the message stream.
shimniok 0:a6a169de725f 8 uint8_t target_component; ///< The target requested to send the message stream.
shimniok 0:a6a169de725f 9 uint8_t req_stream_id; ///< The ID of the requested message type
shimniok 0:a6a169de725f 10 uint16_t req_message_rate; ///< Update rate in Hertz
shimniok 0:a6a169de725f 11 uint8_t start_stop; ///< 1 to start sending, 0 to stop sending.
shimniok 0:a6a169de725f 12
shimniok 0:a6a169de725f 13 } mavlink_request_data_stream_t;
shimniok 0:a6a169de725f 14
shimniok 0:a6a169de725f 15
shimniok 0:a6a169de725f 16
shimniok 0:a6a169de725f 17 /**
shimniok 0:a6a169de725f 18 * @brief Pack a request_data_stream message
shimniok 0:a6a169de725f 19 * @param system_id ID of this system
shimniok 0:a6a169de725f 20 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:a6a169de725f 21 * @param msg The MAVLink message to compress the data into
shimniok 0:a6a169de725f 22 *
shimniok 0:a6a169de725f 23 * @param target_system The target requested to send the message stream.
shimniok 0:a6a169de725f 24 * @param target_component The target requested to send the message stream.
shimniok 0:a6a169de725f 25 * @param req_stream_id The ID of the requested message type
shimniok 0:a6a169de725f 26 * @param req_message_rate Update rate in Hertz
shimniok 0:a6a169de725f 27 * @param start_stop 1 to start sending, 0 to stop sending.
shimniok 0:a6a169de725f 28 * @return length of the message in bytes (excluding serial stream start sign)
shimniok 0:a6a169de725f 29 */
shimniok 0:a6a169de725f 30 static inline uint16_t mavlink_msg_request_data_stream_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t target_system, uint8_t target_component, uint8_t req_stream_id, uint16_t req_message_rate, uint8_t start_stop)
shimniok 0:a6a169de725f 31 {
shimniok 0:a6a169de725f 32 uint16_t i = 0;
shimniok 0:a6a169de725f 33 msg->msgid = MAVLINK_MSG_ID_REQUEST_DATA_STREAM;
shimniok 0:a6a169de725f 34
shimniok 0:a6a169de725f 35 i += put_uint8_t_by_index(target_system, i, msg->payload); // The target requested to send the message stream.
shimniok 0:a6a169de725f 36 i += put_uint8_t_by_index(target_component, i, msg->payload); // The target requested to send the message stream.
shimniok 0:a6a169de725f 37 i += put_uint8_t_by_index(req_stream_id, i, msg->payload); // The ID of the requested message type
shimniok 0:a6a169de725f 38 i += put_uint16_t_by_index(req_message_rate, i, msg->payload); // Update rate in Hertz
shimniok 0:a6a169de725f 39 i += put_uint8_t_by_index(start_stop, i, msg->payload); // 1 to start sending, 0 to stop sending.
shimniok 0:a6a169de725f 40
shimniok 0:a6a169de725f 41 return mavlink_finalize_message(msg, system_id, component_id, i);
shimniok 0:a6a169de725f 42 }
shimniok 0:a6a169de725f 43
shimniok 0:a6a169de725f 44 /**
shimniok 0:a6a169de725f 45 * @brief Pack a request_data_stream message
shimniok 0:a6a169de725f 46 * @param system_id ID of this system
shimniok 0:a6a169de725f 47 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:a6a169de725f 48 * @param chan The MAVLink channel this message was sent over
shimniok 0:a6a169de725f 49 * @param msg The MAVLink message to compress the data into
shimniok 0:a6a169de725f 50 * @param target_system The target requested to send the message stream.
shimniok 0:a6a169de725f 51 * @param target_component The target requested to send the message stream.
shimniok 0:a6a169de725f 52 * @param req_stream_id The ID of the requested message type
shimniok 0:a6a169de725f 53 * @param req_message_rate Update rate in Hertz
shimniok 0:a6a169de725f 54 * @param start_stop 1 to start sending, 0 to stop sending.
shimniok 0:a6a169de725f 55 * @return length of the message in bytes (excluding serial stream start sign)
shimniok 0:a6a169de725f 56 */
shimniok 0:a6a169de725f 57 static inline uint16_t mavlink_msg_request_data_stream_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t target_system, uint8_t target_component, uint8_t req_stream_id, uint16_t req_message_rate, uint8_t start_stop)
shimniok 0:a6a169de725f 58 {
shimniok 0:a6a169de725f 59 uint16_t i = 0;
shimniok 0:a6a169de725f 60 msg->msgid = MAVLINK_MSG_ID_REQUEST_DATA_STREAM;
shimniok 0:a6a169de725f 61
shimniok 0:a6a169de725f 62 i += put_uint8_t_by_index(target_system, i, msg->payload); // The target requested to send the message stream.
shimniok 0:a6a169de725f 63 i += put_uint8_t_by_index(target_component, i, msg->payload); // The target requested to send the message stream.
shimniok 0:a6a169de725f 64 i += put_uint8_t_by_index(req_stream_id, i, msg->payload); // The ID of the requested message type
shimniok 0:a6a169de725f 65 i += put_uint16_t_by_index(req_message_rate, i, msg->payload); // Update rate in Hertz
shimniok 0:a6a169de725f 66 i += put_uint8_t_by_index(start_stop, i, msg->payload); // 1 to start sending, 0 to stop sending.
shimniok 0:a6a169de725f 67
shimniok 0:a6a169de725f 68 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
shimniok 0:a6a169de725f 69 }
shimniok 0:a6a169de725f 70
shimniok 0:a6a169de725f 71 /**
shimniok 0:a6a169de725f 72 * @brief Encode a request_data_stream struct into a message
shimniok 0:a6a169de725f 73 *
shimniok 0:a6a169de725f 74 * @param system_id ID of this system
shimniok 0:a6a169de725f 75 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:a6a169de725f 76 * @param msg The MAVLink message to compress the data into
shimniok 0:a6a169de725f 77 * @param request_data_stream C-struct to read the message contents from
shimniok 0:a6a169de725f 78 */
shimniok 0:a6a169de725f 79 static inline uint16_t mavlink_msg_request_data_stream_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_request_data_stream_t* request_data_stream)
shimniok 0:a6a169de725f 80 {
shimniok 0:a6a169de725f 81 return mavlink_msg_request_data_stream_pack(system_id, component_id, msg, request_data_stream->target_system, request_data_stream->target_component, request_data_stream->req_stream_id, request_data_stream->req_message_rate, request_data_stream->start_stop);
shimniok 0:a6a169de725f 82 }
shimniok 0:a6a169de725f 83
shimniok 0:a6a169de725f 84 /**
shimniok 0:a6a169de725f 85 * @brief Send a request_data_stream message
shimniok 0:a6a169de725f 86 * @param chan MAVLink channel to send the message
shimniok 0:a6a169de725f 87 *
shimniok 0:a6a169de725f 88 * @param target_system The target requested to send the message stream.
shimniok 0:a6a169de725f 89 * @param target_component The target requested to send the message stream.
shimniok 0:a6a169de725f 90 * @param req_stream_id The ID of the requested message type
shimniok 0:a6a169de725f 91 * @param req_message_rate Update rate in Hertz
shimniok 0:a6a169de725f 92 * @param start_stop 1 to start sending, 0 to stop sending.
shimniok 0:a6a169de725f 93 */
shimniok 0:a6a169de725f 94 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
shimniok 0:a6a169de725f 95
shimniok 0:a6a169de725f 96 static inline void mavlink_msg_request_data_stream_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t req_stream_id, uint16_t req_message_rate, uint8_t start_stop)
shimniok 0:a6a169de725f 97 {
shimniok 0:a6a169de725f 98 mavlink_message_t msg;
shimniok 0:a6a169de725f 99 mavlink_msg_request_data_stream_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, target_system, target_component, req_stream_id, req_message_rate, start_stop);
shimniok 0:a6a169de725f 100 mavlink_send_uart(chan, &msg);
shimniok 0:a6a169de725f 101 }
shimniok 0:a6a169de725f 102
shimniok 0:a6a169de725f 103 #endif
shimniok 0:a6a169de725f 104 // MESSAGE REQUEST_DATA_STREAM UNPACKING
shimniok 0:a6a169de725f 105
shimniok 0:a6a169de725f 106 /**
shimniok 0:a6a169de725f 107 * @brief Get field target_system from request_data_stream message
shimniok 0:a6a169de725f 108 *
shimniok 0:a6a169de725f 109 * @return The target requested to send the message stream.
shimniok 0:a6a169de725f 110 */
shimniok 0:a6a169de725f 111 static inline uint8_t mavlink_msg_request_data_stream_get_target_system(const mavlink_message_t* msg)
shimniok 0:a6a169de725f 112 {
shimniok 0:a6a169de725f 113 return (uint8_t)(msg->payload)[0];
shimniok 0:a6a169de725f 114 }
shimniok 0:a6a169de725f 115
shimniok 0:a6a169de725f 116 /**
shimniok 0:a6a169de725f 117 * @brief Get field target_component from request_data_stream message
shimniok 0:a6a169de725f 118 *
shimniok 0:a6a169de725f 119 * @return The target requested to send the message stream.
shimniok 0:a6a169de725f 120 */
shimniok 0:a6a169de725f 121 static inline uint8_t mavlink_msg_request_data_stream_get_target_component(const mavlink_message_t* msg)
shimniok 0:a6a169de725f 122 {
shimniok 0:a6a169de725f 123 return (uint8_t)(msg->payload+sizeof(uint8_t))[0];
shimniok 0:a6a169de725f 124 }
shimniok 0:a6a169de725f 125
shimniok 0:a6a169de725f 126 /**
shimniok 0:a6a169de725f 127 * @brief Get field req_stream_id from request_data_stream message
shimniok 0:a6a169de725f 128 *
shimniok 0:a6a169de725f 129 * @return The ID of the requested message type
shimniok 0:a6a169de725f 130 */
shimniok 0:a6a169de725f 131 static inline uint8_t mavlink_msg_request_data_stream_get_req_stream_id(const mavlink_message_t* msg)
shimniok 0:a6a169de725f 132 {
shimniok 0:a6a169de725f 133 return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t))[0];
shimniok 0:a6a169de725f 134 }
shimniok 0:a6a169de725f 135
shimniok 0:a6a169de725f 136 /**
shimniok 0:a6a169de725f 137 * @brief Get field req_message_rate from request_data_stream message
shimniok 0:a6a169de725f 138 *
shimniok 0:a6a169de725f 139 * @return Update rate in Hertz
shimniok 0:a6a169de725f 140 */
shimniok 0:a6a169de725f 141 static inline uint16_t mavlink_msg_request_data_stream_get_req_message_rate(const mavlink_message_t* msg)
shimniok 0:a6a169de725f 142 {
shimniok 0:a6a169de725f 143 generic_16bit r;
shimniok 0:a6a169de725f 144 r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t))[0];
shimniok 0:a6a169de725f 145 r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t))[1];
shimniok 0:a6a169de725f 146 return (uint16_t)r.s;
shimniok 0:a6a169de725f 147 }
shimniok 0:a6a169de725f 148
shimniok 0:a6a169de725f 149 /**
shimniok 0:a6a169de725f 150 * @brief Get field start_stop from request_data_stream message
shimniok 0:a6a169de725f 151 *
shimniok 0:a6a169de725f 152 * @return 1 to start sending, 0 to stop sending.
shimniok 0:a6a169de725f 153 */
shimniok 0:a6a169de725f 154 static inline uint8_t mavlink_msg_request_data_stream_get_start_stop(const mavlink_message_t* msg)
shimniok 0:a6a169de725f 155 {
shimniok 0:a6a169de725f 156 return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint8_t)+sizeof(uint16_t))[0];
shimniok 0:a6a169de725f 157 }
shimniok 0:a6a169de725f 158
shimniok 0:a6a169de725f 159 /**
shimniok 0:a6a169de725f 160 * @brief Decode a request_data_stream message into a struct
shimniok 0:a6a169de725f 161 *
shimniok 0:a6a169de725f 162 * @param msg The message to decode
shimniok 0:a6a169de725f 163 * @param request_data_stream C-struct to decode the message contents into
shimniok 0:a6a169de725f 164 */
shimniok 0:a6a169de725f 165 static inline void mavlink_msg_request_data_stream_decode(const mavlink_message_t* msg, mavlink_request_data_stream_t* request_data_stream)
shimniok 0:a6a169de725f 166 {
shimniok 0:a6a169de725f 167 request_data_stream->target_system = mavlink_msg_request_data_stream_get_target_system(msg);
shimniok 0:a6a169de725f 168 request_data_stream->target_component = mavlink_msg_request_data_stream_get_target_component(msg);
shimniok 0:a6a169de725f 169 request_data_stream->req_stream_id = mavlink_msg_request_data_stream_get_req_stream_id(msg);
shimniok 0:a6a169de725f 170 request_data_stream->req_message_rate = mavlink_msg_request_data_stream_get_req_message_rate(msg);
shimniok 0:a6a169de725f 171 request_data_stream->start_stop = mavlink_msg_request_data_stream_get_start_stop(msg);
shimniok 0:a6a169de725f 172 }