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_watchdog_command.h Source File

mavlink_msg_watchdog_command.h

00001 // MESSAGE WATCHDOG_COMMAND PACKING
00002 
00003 #define MAVLINK_MSG_ID_WATCHDOG_COMMAND 153
00004 
00005 typedef struct __mavlink_watchdog_command_t 
00006 {
00007     uint8_t target_system_id; ///< Target system ID
00008     uint16_t watchdog_id; ///< Watchdog ID
00009     uint16_t process_id; ///< Process ID
00010     uint8_t command_id; ///< Command ID
00011 
00012 } mavlink_watchdog_command_t;
00013 
00014 
00015 
00016 /**
00017  * @brief Pack a watchdog_command message
00018  * @param system_id ID of this system
00019  * @param component_id ID of this component (e.g. 200 for IMU)
00020  * @param msg The MAVLink message to compress the data into
00021  *
00022  * @param target_system_id Target system ID
00023  * @param watchdog_id Watchdog ID
00024  * @param process_id Process ID
00025  * @param command_id Command ID
00026  * @return length of the message in bytes (excluding serial stream start sign)
00027  */
00028 static inline uint16_t mavlink_msg_watchdog_command_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t target_system_id, uint16_t watchdog_id, uint16_t process_id, uint8_t command_id)
00029 {
00030     uint16_t i = 0;
00031     msg->msgid = MAVLINK_MSG_ID_WATCHDOG_COMMAND;
00032 
00033     i += put_uint8_t_by_index(target_system_id, i, msg->payload); // Target system ID
00034     i += put_uint16_t_by_index(watchdog_id, i, msg->payload); // Watchdog ID
00035     i += put_uint16_t_by_index(process_id, i, msg->payload); // Process ID
00036     i += put_uint8_t_by_index(command_id, i, msg->payload); // Command ID
00037 
00038     return mavlink_finalize_message(msg, system_id, component_id, i);
00039 }
00040 
00041 /**
00042  * @brief Pack a watchdog_command message
00043  * @param system_id ID of this system
00044  * @param component_id ID of this component (e.g. 200 for IMU)
00045  * @param chan The MAVLink channel this message was sent over
00046  * @param msg The MAVLink message to compress the data into
00047  * @param target_system_id Target system ID
00048  * @param watchdog_id Watchdog ID
00049  * @param process_id Process ID
00050  * @param command_id Command ID
00051  * @return length of the message in bytes (excluding serial stream start sign)
00052  */
00053 static inline uint16_t mavlink_msg_watchdog_command_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t target_system_id, uint16_t watchdog_id, uint16_t process_id, uint8_t command_id)
00054 {
00055     uint16_t i = 0;
00056     msg->msgid = MAVLINK_MSG_ID_WATCHDOG_COMMAND;
00057 
00058     i += put_uint8_t_by_index(target_system_id, i, msg->payload); // Target system ID
00059     i += put_uint16_t_by_index(watchdog_id, i, msg->payload); // Watchdog ID
00060     i += put_uint16_t_by_index(process_id, i, msg->payload); // Process ID
00061     i += put_uint8_t_by_index(command_id, i, msg->payload); // Command ID
00062 
00063     return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
00064 }
00065 
00066 /**
00067  * @brief Encode a watchdog_command struct into a message
00068  *
00069  * @param system_id ID of this system
00070  * @param component_id ID of this component (e.g. 200 for IMU)
00071  * @param msg The MAVLink message to compress the data into
00072  * @param watchdog_command C-struct to read the message contents from
00073  */
00074 static inline uint16_t mavlink_msg_watchdog_command_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_watchdog_command_t* watchdog_command)
00075 {
00076     return mavlink_msg_watchdog_command_pack(system_id, component_id, msg, watchdog_command->target_system_id, watchdog_command->watchdog_id, watchdog_command->process_id, watchdog_command->command_id);
00077 }
00078 
00079 /**
00080  * @brief Send a watchdog_command message
00081  * @param chan MAVLink channel to send the message
00082  *
00083  * @param target_system_id Target system ID
00084  * @param watchdog_id Watchdog ID
00085  * @param process_id Process ID
00086  * @param command_id Command ID
00087  */
00088 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
00089 
00090 static inline void mavlink_msg_watchdog_command_send(mavlink_channel_t chan, uint8_t target_system_id, uint16_t watchdog_id, uint16_t process_id, uint8_t command_id)
00091 {
00092     mavlink_message_t msg;
00093     mavlink_msg_watchdog_command_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, target_system_id, watchdog_id, process_id, command_id);
00094     mavlink_send_uart(chan, &msg);
00095 }
00096 
00097 #endif
00098 // MESSAGE WATCHDOG_COMMAND UNPACKING
00099 
00100 /**
00101  * @brief Get field target_system_id from watchdog_command message
00102  *
00103  * @return Target system ID
00104  */
00105 static inline uint8_t mavlink_msg_watchdog_command_get_target_system_id(const mavlink_message_t* msg)
00106 {
00107     return (uint8_t)(msg->payload)[0];
00108 }
00109 
00110 /**
00111  * @brief Get field watchdog_id from watchdog_command message
00112  *
00113  * @return Watchdog ID
00114  */
00115 static inline uint16_t mavlink_msg_watchdog_command_get_watchdog_id(const mavlink_message_t* msg)
00116 {
00117     generic_16bit r;
00118     r.b[1] = (msg->payload+sizeof(uint8_t))[0];
00119     r.b[0] = (msg->payload+sizeof(uint8_t))[1];
00120     return (uint16_t)r.s;
00121 }
00122 
00123 /**
00124  * @brief Get field process_id from watchdog_command message
00125  *
00126  * @return Process ID
00127  */
00128 static inline uint16_t mavlink_msg_watchdog_command_get_process_id(const mavlink_message_t* msg)
00129 {
00130     generic_16bit r;
00131     r.b[1] = (msg->payload+sizeof(uint8_t)+sizeof(uint16_t))[0];
00132     r.b[0] = (msg->payload+sizeof(uint8_t)+sizeof(uint16_t))[1];
00133     return (uint16_t)r.s;
00134 }
00135 
00136 /**
00137  * @brief Get field command_id from watchdog_command message
00138  *
00139  * @return Command ID
00140  */
00141 static inline uint8_t mavlink_msg_watchdog_command_get_command_id(const mavlink_message_t* msg)
00142 {
00143     return (uint8_t)(msg->payload+sizeof(uint8_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
00144 }
00145 
00146 /**
00147  * @brief Decode a watchdog_command message into a struct
00148  *
00149  * @param msg The message to decode
00150  * @param watchdog_command C-struct to decode the message contents into
00151  */
00152 static inline void mavlink_msg_watchdog_command_decode(const mavlink_message_t* msg, mavlink_watchdog_command_t* watchdog_command)
00153 {
00154     watchdog_command->target_system_id = mavlink_msg_watchdog_command_get_target_system_id(msg);
00155     watchdog_command->watchdog_id = mavlink_msg_watchdog_command_get_watchdog_id(msg);
00156     watchdog_command->process_id = mavlink_msg_watchdog_command_get_process_id(msg);
00157     watchdog_command->command_id = mavlink_msg_watchdog_command_get_command_id(msg);
00158 }