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/common/mavlink_msg_boot.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 BOOT PACKING |
shimniok | 0:826c6171fc1b | 2 | |
shimniok | 0:826c6171fc1b | 3 | #define MAVLINK_MSG_ID_BOOT 1 |
shimniok | 0:826c6171fc1b | 4 | |
shimniok | 0:826c6171fc1b | 5 | typedef struct __mavlink_boot_t |
shimniok | 0:826c6171fc1b | 6 | { |
shimniok | 0:826c6171fc1b | 7 | uint32_t version; ///< The onboard software version |
shimniok | 0:826c6171fc1b | 8 | |
shimniok | 0:826c6171fc1b | 9 | } mavlink_boot_t; |
shimniok | 0:826c6171fc1b | 10 | |
shimniok | 0:826c6171fc1b | 11 | |
shimniok | 0:826c6171fc1b | 12 | |
shimniok | 0:826c6171fc1b | 13 | /** |
shimniok | 0:826c6171fc1b | 14 | * @brief Pack a boot message |
shimniok | 0:826c6171fc1b | 15 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 16 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 17 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 18 | * |
shimniok | 0:826c6171fc1b | 19 | * @param version The onboard software version |
shimniok | 0:826c6171fc1b | 20 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 21 | */ |
shimniok | 0:826c6171fc1b | 22 | static inline uint16_t mavlink_msg_boot_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint32_t version) |
shimniok | 0:826c6171fc1b | 23 | { |
shimniok | 0:826c6171fc1b | 24 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 25 | msg->msgid = MAVLINK_MSG_ID_BOOT; |
shimniok | 0:826c6171fc1b | 26 | |
shimniok | 0:826c6171fc1b | 27 | i += put_uint32_t_by_index(version, i, msg->payload); // The onboard software version |
shimniok | 0:826c6171fc1b | 28 | |
shimniok | 0:826c6171fc1b | 29 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:826c6171fc1b | 30 | } |
shimniok | 0:826c6171fc1b | 31 | |
shimniok | 0:826c6171fc1b | 32 | /** |
shimniok | 0:826c6171fc1b | 33 | * @brief Pack a boot message |
shimniok | 0:826c6171fc1b | 34 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 35 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 36 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:826c6171fc1b | 37 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 38 | * @param version The onboard software version |
shimniok | 0:826c6171fc1b | 39 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 40 | */ |
shimniok | 0:826c6171fc1b | 41 | static inline uint16_t mavlink_msg_boot_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint32_t version) |
shimniok | 0:826c6171fc1b | 42 | { |
shimniok | 0:826c6171fc1b | 43 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 44 | msg->msgid = MAVLINK_MSG_ID_BOOT; |
shimniok | 0:826c6171fc1b | 45 | |
shimniok | 0:826c6171fc1b | 46 | i += put_uint32_t_by_index(version, i, msg->payload); // The onboard software version |
shimniok | 0:826c6171fc1b | 47 | |
shimniok | 0:826c6171fc1b | 48 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:826c6171fc1b | 49 | } |
shimniok | 0:826c6171fc1b | 50 | |
shimniok | 0:826c6171fc1b | 51 | /** |
shimniok | 0:826c6171fc1b | 52 | * @brief Encode a boot struct into a message |
shimniok | 0:826c6171fc1b | 53 | * |
shimniok | 0:826c6171fc1b | 54 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 55 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 56 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 57 | * @param boot C-struct to read the message contents from |
shimniok | 0:826c6171fc1b | 58 | */ |
shimniok | 0:826c6171fc1b | 59 | static inline uint16_t mavlink_msg_boot_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_boot_t* boot) |
shimniok | 0:826c6171fc1b | 60 | { |
shimniok | 0:826c6171fc1b | 61 | return mavlink_msg_boot_pack(system_id, component_id, msg, boot->version); |
shimniok | 0:826c6171fc1b | 62 | } |
shimniok | 0:826c6171fc1b | 63 | |
shimniok | 0:826c6171fc1b | 64 | /** |
shimniok | 0:826c6171fc1b | 65 | * @brief Send a boot message |
shimniok | 0:826c6171fc1b | 66 | * @param chan MAVLink channel to send the message |
shimniok | 0:826c6171fc1b | 67 | * |
shimniok | 0:826c6171fc1b | 68 | * @param version The onboard software version |
shimniok | 0:826c6171fc1b | 69 | */ |
shimniok | 0:826c6171fc1b | 70 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:826c6171fc1b | 71 | |
shimniok | 0:826c6171fc1b | 72 | static inline void mavlink_msg_boot_send(mavlink_channel_t chan, uint32_t version) |
shimniok | 0:826c6171fc1b | 73 | { |
shimniok | 0:826c6171fc1b | 74 | mavlink_message_t msg; |
shimniok | 0:826c6171fc1b | 75 | mavlink_msg_boot_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, version); |
shimniok | 0:826c6171fc1b | 76 | mavlink_send_uart(chan, &msg); |
shimniok | 0:826c6171fc1b | 77 | } |
shimniok | 0:826c6171fc1b | 78 | |
shimniok | 0:826c6171fc1b | 79 | #endif |
shimniok | 0:826c6171fc1b | 80 | // MESSAGE BOOT UNPACKING |
shimniok | 0:826c6171fc1b | 81 | |
shimniok | 0:826c6171fc1b | 82 | /** |
shimniok | 0:826c6171fc1b | 83 | * @brief Get field version from boot message |
shimniok | 0:826c6171fc1b | 84 | * |
shimniok | 0:826c6171fc1b | 85 | * @return The onboard software version |
shimniok | 0:826c6171fc1b | 86 | */ |
shimniok | 0:826c6171fc1b | 87 | static inline uint32_t mavlink_msg_boot_get_version(const mavlink_message_t* msg) |
shimniok | 0:826c6171fc1b | 88 | { |
shimniok | 0:826c6171fc1b | 89 | generic_32bit r; |
shimniok | 0:826c6171fc1b | 90 | r.b[3] = (msg->payload)[0]; |
shimniok | 0:826c6171fc1b | 91 | r.b[2] = (msg->payload)[1]; |
shimniok | 0:826c6171fc1b | 92 | r.b[1] = (msg->payload)[2]; |
shimniok | 0:826c6171fc1b | 93 | r.b[0] = (msg->payload)[3]; |
shimniok | 0:826c6171fc1b | 94 | return (uint32_t)r.i; |
shimniok | 0:826c6171fc1b | 95 | } |
shimniok | 0:826c6171fc1b | 96 | |
shimniok | 0:826c6171fc1b | 97 | /** |
shimniok | 0:826c6171fc1b | 98 | * @brief Decode a boot message into a struct |
shimniok | 0:826c6171fc1b | 99 | * |
shimniok | 0:826c6171fc1b | 100 | * @param msg The message to decode |
shimniok | 0:826c6171fc1b | 101 | * @param boot C-struct to decode the message contents into |
shimniok | 0:826c6171fc1b | 102 | */ |
shimniok | 0:826c6171fc1b | 103 | static inline void mavlink_msg_boot_decode(const mavlink_message_t* msg, mavlink_boot_t* boot) |
shimniok | 0:826c6171fc1b | 104 | { |
shimniok | 0:826c6171fc1b | 105 | boot->version = mavlink_msg_boot_get_version(msg); |
shimniok | 0:826c6171fc1b | 106 | } |