Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.

Dependencies:   Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mavlink_msg_boot.h Source File

mavlink_msg_boot.h

00001 // MESSAGE BOOT PACKING
00002 
00003 #define MAVLINK_MSG_ID_BOOT 1
00004 
00005 typedef struct __mavlink_boot_t 
00006 {
00007     uint32_t version; ///< The onboard software version
00008 
00009 } mavlink_boot_t;
00010 
00011 
00012 
00013 /**
00014  * @brief Pack a boot message
00015  * @param system_id ID of this system
00016  * @param component_id ID of this component (e.g. 200 for IMU)
00017  * @param msg The MAVLink message to compress the data into
00018  *
00019  * @param version The onboard software version
00020  * @return length of the message in bytes (excluding serial stream start sign)
00021  */
00022 static inline uint16_t mavlink_msg_boot_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint32_t version)
00023 {
00024     uint16_t i = 0;
00025     msg->msgid = MAVLINK_MSG_ID_BOOT;
00026 
00027     i += put_uint32_t_by_index(version, i, msg->payload); // The onboard software version
00028 
00029     return mavlink_finalize_message(msg, system_id, component_id, i);
00030 }
00031 
00032 /**
00033  * @brief Pack a boot message
00034  * @param system_id ID of this system
00035  * @param component_id ID of this component (e.g. 200 for IMU)
00036  * @param chan The MAVLink channel this message was sent over
00037  * @param msg The MAVLink message to compress the data into
00038  * @param version The onboard software version
00039  * @return length of the message in bytes (excluding serial stream start sign)
00040  */
00041 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)
00042 {
00043     uint16_t i = 0;
00044     msg->msgid = MAVLINK_MSG_ID_BOOT;
00045 
00046     i += put_uint32_t_by_index(version, i, msg->payload); // The onboard software version
00047 
00048     return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
00049 }
00050 
00051 /**
00052  * @brief Encode a boot struct into a message
00053  *
00054  * @param system_id ID of this system
00055  * @param component_id ID of this component (e.g. 200 for IMU)
00056  * @param msg The MAVLink message to compress the data into
00057  * @param boot C-struct to read the message contents from
00058  */
00059 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)
00060 {
00061     return mavlink_msg_boot_pack(system_id, component_id, msg, boot->version);
00062 }
00063 
00064 /**
00065  * @brief Send a boot message
00066  * @param chan MAVLink channel to send the message
00067  *
00068  * @param version The onboard software version
00069  */
00070 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
00071 
00072 static inline void mavlink_msg_boot_send(mavlink_channel_t chan, uint32_t version)
00073 {
00074     mavlink_message_t msg;
00075     mavlink_msg_boot_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, version);
00076     mavlink_send_uart(chan, &msg);
00077 }
00078 
00079 #endif
00080 // MESSAGE BOOT UNPACKING
00081 
00082 /**
00083  * @brief Get field version from boot message
00084  *
00085  * @return The onboard software version
00086  */
00087 static inline uint32_t mavlink_msg_boot_get_version(const mavlink_message_t* msg)
00088 {
00089     generic_32bit r;
00090     r.b[3] = (msg->payload)[0];
00091     r.b[2] = (msg->payload)[1];
00092     r.b[1] = (msg->payload)[2];
00093     r.b[0] = (msg->payload)[3];
00094     return (uint32_t)r.i;
00095 }
00096 
00097 /**
00098  * @brief Decode a boot message into a struct
00099  *
00100  * @param msg The message to decode
00101  * @param boot C-struct to decode the message contents into
00102  */
00103 static inline void mavlink_msg_boot_decode(const mavlink_message_t* msg, mavlink_boot_t* boot)
00104 {
00105     boot->version = mavlink_msg_boot_get_version(msg);
00106 }