307 lines
12 KiB
C
307 lines
12 KiB
C
#pragma once
|
|
// MESSAGE CCMState PACKING
|
|
|
|
#define MAVLINK_MSG_ID_CCMState 20302
|
|
|
|
|
|
typedef struct __mavlink_ccmstate_t {
|
|
uint32_t time_boot_ms; /*< [ms] Timestamp (milliseconds since system boot)*/
|
|
uint32_t fuel_level; /*< fuel level*/
|
|
int16_t temp[4]; /*< temp*/
|
|
uint16_t volts[4]; /*< volts*/
|
|
uint8_t echo_seq; /*< echo seq*/
|
|
} mavlink_ccmstate_t;
|
|
|
|
#define MAVLINK_MSG_ID_CCMState_LEN 25
|
|
#define MAVLINK_MSG_ID_CCMState_MIN_LEN 25
|
|
#define MAVLINK_MSG_ID_20302_LEN 25
|
|
#define MAVLINK_MSG_ID_20302_MIN_LEN 25
|
|
|
|
#define MAVLINK_MSG_ID_CCMState_CRC 5
|
|
#define MAVLINK_MSG_ID_20302_CRC 5
|
|
|
|
#define MAVLINK_MSG_CCMState_FIELD_TEMP_LEN 4
|
|
#define MAVLINK_MSG_CCMState_FIELD_VOLTS_LEN 4
|
|
|
|
#if MAVLINK_COMMAND_24BIT
|
|
#define MAVLINK_MESSAGE_INFO_CCMState { \
|
|
20302, \
|
|
"CCMState", \
|
|
5, \
|
|
{ { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_ccmstate_t, time_boot_ms) }, \
|
|
{ "fuel_level", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_ccmstate_t, fuel_level) }, \
|
|
{ "temp", NULL, MAVLINK_TYPE_INT16_T, 4, 8, offsetof(mavlink_ccmstate_t, temp) }, \
|
|
{ "volts", NULL, MAVLINK_TYPE_UINT16_T, 4, 16, offsetof(mavlink_ccmstate_t, volts) }, \
|
|
{ "echo_seq", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_ccmstate_t, echo_seq) }, \
|
|
} \
|
|
}
|
|
#else
|
|
#define MAVLINK_MESSAGE_INFO_CCMState { \
|
|
"CCMState", \
|
|
5, \
|
|
{ { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_ccmstate_t, time_boot_ms) }, \
|
|
{ "fuel_level", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_ccmstate_t, fuel_level) }, \
|
|
{ "temp", NULL, MAVLINK_TYPE_INT16_T, 4, 8, offsetof(mavlink_ccmstate_t, temp) }, \
|
|
{ "volts", NULL, MAVLINK_TYPE_UINT16_T, 4, 16, offsetof(mavlink_ccmstate_t, volts) }, \
|
|
{ "echo_seq", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_ccmstate_t, echo_seq) }, \
|
|
} \
|
|
}
|
|
#endif
|
|
|
|
/**
|
|
* @brief Pack a ccmstate message
|
|
* @param system_id ID of this system
|
|
* @param component_id ID of this component (e.g. 200 for IMU)
|
|
* @param msg The MAVLink message to compress the data into
|
|
*
|
|
* @param time_boot_ms [ms] Timestamp (milliseconds since system boot)
|
|
* @param fuel_level fuel level
|
|
* @param temp temp
|
|
* @param volts volts
|
|
* @param echo_seq echo seq
|
|
* @return length of the message in bytes (excluding serial stream start sign)
|
|
*/
|
|
static inline uint16_t mavlink_msg_ccmstate_pack(uint16_t system_id, uint8_t component_id, mavlink_message_t* msg,
|
|
uint32_t time_boot_ms, uint32_t fuel_level, const int16_t *temp, const uint16_t *volts, uint8_t echo_seq)
|
|
{
|
|
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
char buf[MAVLINK_MSG_ID_CCMState_LEN];
|
|
_mav_put_uint32_t(buf, 0, time_boot_ms);
|
|
_mav_put_uint32_t(buf, 4, fuel_level);
|
|
_mav_put_uint8_t(buf, 24, echo_seq);
|
|
_mav_put_int16_t_array(buf, 8, temp, 4);
|
|
_mav_put_uint16_t_array(buf, 16, volts, 4);
|
|
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CCMState_LEN);
|
|
#else
|
|
mavlink_ccmstate_t packet;
|
|
packet.time_boot_ms = time_boot_ms;
|
|
packet.fuel_level = fuel_level;
|
|
packet.echo_seq = echo_seq;
|
|
mav_array_memcpy(packet.temp, temp, sizeof(int16_t)*4);
|
|
mav_array_memcpy(packet.volts, volts, sizeof(uint16_t)*4);
|
|
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CCMState_LEN);
|
|
#endif
|
|
|
|
msg->msgid = MAVLINK_MSG_ID_CCMState;
|
|
return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
|
|
}
|
|
|
|
/**
|
|
* @brief Pack a ccmstate message on a channel
|
|
* @param system_id ID of this system
|
|
* @param component_id ID of this component (e.g. 200 for IMU)
|
|
* @param chan The MAVLink channel this message will be sent over
|
|
* @param msg The MAVLink message to compress the data into
|
|
* @param time_boot_ms [ms] Timestamp (milliseconds since system boot)
|
|
* @param fuel_level fuel level
|
|
* @param temp temp
|
|
* @param volts volts
|
|
* @param echo_seq echo seq
|
|
* @return length of the message in bytes (excluding serial stream start sign)
|
|
*/
|
|
static inline uint16_t mavlink_msg_ccmstate_pack_chan(uint16_t system_id, uint8_t component_id, uint8_t chan,
|
|
mavlink_message_t* msg,
|
|
uint32_t time_boot_ms,uint32_t fuel_level,const int16_t *temp,const uint16_t *volts,uint8_t echo_seq)
|
|
{
|
|
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
char buf[MAVLINK_MSG_ID_CCMState_LEN];
|
|
_mav_put_uint32_t(buf, 0, time_boot_ms);
|
|
_mav_put_uint32_t(buf, 4, fuel_level);
|
|
_mav_put_uint8_t(buf, 24, echo_seq);
|
|
_mav_put_int16_t_array(buf, 8, temp, 4);
|
|
_mav_put_uint16_t_array(buf, 16, volts, 4);
|
|
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CCMState_LEN);
|
|
#else
|
|
mavlink_ccmstate_t packet;
|
|
packet.time_boot_ms = time_boot_ms;
|
|
packet.fuel_level = fuel_level;
|
|
packet.echo_seq = echo_seq;
|
|
mav_array_memcpy(packet.temp, temp, sizeof(int16_t)*4);
|
|
mav_array_memcpy(packet.volts, volts, sizeof(uint16_t)*4);
|
|
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CCMState_LEN);
|
|
#endif
|
|
|
|
msg->msgid = MAVLINK_MSG_ID_CCMState;
|
|
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
|
|
}
|
|
|
|
/**
|
|
* @brief Encode a ccmstate struct
|
|
*
|
|
* @param system_id ID of this system
|
|
* @param component_id ID of this component (e.g. 200 for IMU)
|
|
* @param msg The MAVLink message to compress the data into
|
|
* @param ccmstate C-struct to read the message contents from
|
|
*/
|
|
static inline uint16_t mavlink_msg_ccmstate_encode(uint16_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_ccmstate_t* ccmstate)
|
|
{
|
|
return mavlink_msg_ccmstate_pack(system_id, component_id, msg, ccmstate->time_boot_ms, ccmstate->fuel_level, ccmstate->temp, ccmstate->volts, ccmstate->echo_seq);
|
|
}
|
|
|
|
/**
|
|
* @brief Encode a ccmstate struct on a channel
|
|
*
|
|
* @param system_id ID of this system
|
|
* @param component_id ID of this component (e.g. 200 for IMU)
|
|
* @param chan The MAVLink channel this message will be sent over
|
|
* @param msg The MAVLink message to compress the data into
|
|
* @param ccmstate C-struct to read the message contents from
|
|
*/
|
|
static inline uint16_t mavlink_msg_ccmstate_encode_chan(uint16_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_ccmstate_t* ccmstate)
|
|
{
|
|
return mavlink_msg_ccmstate_pack_chan(system_id, component_id, chan, msg, ccmstate->time_boot_ms, ccmstate->fuel_level, ccmstate->temp, ccmstate->volts, ccmstate->echo_seq);
|
|
}
|
|
|
|
/**
|
|
* @brief Send a ccmstate message
|
|
* @param chan MAVLink channel to send the message
|
|
*
|
|
* @param time_boot_ms [ms] Timestamp (milliseconds since system boot)
|
|
* @param fuel_level fuel level
|
|
* @param temp temp
|
|
* @param volts volts
|
|
* @param echo_seq echo seq
|
|
*/
|
|
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
|
|
|
|
static inline void mavlink_msg_ccmstate_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint32_t fuel_level, const int16_t *temp, const uint16_t *volts, uint8_t echo_seq)
|
|
{
|
|
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
char buf[MAVLINK_MSG_ID_CCMState_LEN];
|
|
_mav_put_uint32_t(buf, 0, time_boot_ms);
|
|
_mav_put_uint32_t(buf, 4, fuel_level);
|
|
_mav_put_uint8_t(buf, 24, echo_seq);
|
|
_mav_put_int16_t_array(buf, 8, temp, 4);
|
|
_mav_put_uint16_t_array(buf, 16, volts, 4);
|
|
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CCMState, buf, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
|
|
#else
|
|
mavlink_ccmstate_t packet;
|
|
packet.time_boot_ms = time_boot_ms;
|
|
packet.fuel_level = fuel_level;
|
|
packet.echo_seq = echo_seq;
|
|
mav_array_memcpy(packet.temp, temp, sizeof(int16_t)*4);
|
|
mav_array_memcpy(packet.volts, volts, sizeof(uint16_t)*4);
|
|
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CCMState, (const char *)&packet, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
|
|
#endif
|
|
}
|
|
|
|
/**
|
|
* @brief Send a ccmstate message
|
|
* @param chan MAVLink channel to send the message
|
|
* @param struct The MAVLink struct to serialize
|
|
*/
|
|
static inline void mavlink_msg_ccmstate_send_struct(mavlink_channel_t chan, const mavlink_ccmstate_t* ccmstate)
|
|
{
|
|
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
mavlink_msg_ccmstate_send(chan, ccmstate->time_boot_ms, ccmstate->fuel_level, ccmstate->temp, ccmstate->volts, ccmstate->echo_seq);
|
|
#else
|
|
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CCMState, (const char *)ccmstate, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
|
|
#endif
|
|
}
|
|
|
|
#if MAVLINK_MSG_ID_CCMState_LEN <= MAVLINK_MAX_PAYLOAD_LEN
|
|
/*
|
|
This varient of _send() can be used to save stack space by re-using
|
|
memory from the receive buffer. The caller provides a
|
|
mavlink_message_t which is the size of a full mavlink message. This
|
|
is usually the receive buffer for the channel, and allows a reply to an
|
|
incoming message with minimum stack space usage.
|
|
*/
|
|
static inline void mavlink_msg_ccmstate_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint32_t fuel_level, const int16_t *temp, const uint16_t *volts, uint8_t echo_seq)
|
|
{
|
|
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
char *buf = (char *)msgbuf;
|
|
_mav_put_uint32_t(buf, 0, time_boot_ms);
|
|
_mav_put_uint32_t(buf, 4, fuel_level);
|
|
_mav_put_uint8_t(buf, 24, echo_seq);
|
|
_mav_put_int16_t_array(buf, 8, temp, 4);
|
|
_mav_put_uint16_t_array(buf, 16, volts, 4);
|
|
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CCMState, buf, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
|
|
#else
|
|
mavlink_ccmstate_t *packet = (mavlink_ccmstate_t *)msgbuf;
|
|
packet->time_boot_ms = time_boot_ms;
|
|
packet->fuel_level = fuel_level;
|
|
packet->echo_seq = echo_seq;
|
|
mav_array_memcpy(packet->temp, temp, sizeof(int16_t)*4);
|
|
mav_array_memcpy(packet->volts, volts, sizeof(uint16_t)*4);
|
|
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CCMState, (const char *)packet, MAVLINK_MSG_ID_CCMState_MIN_LEN, MAVLINK_MSG_ID_CCMState_LEN, MAVLINK_MSG_ID_CCMState_CRC);
|
|
#endif
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
// MESSAGE CCMState UNPACKING
|
|
|
|
|
|
/**
|
|
* @brief Get field time_boot_ms from ccmstate message
|
|
*
|
|
* @return [ms] Timestamp (milliseconds since system boot)
|
|
*/
|
|
static inline uint32_t mavlink_msg_ccmstate_get_time_boot_ms(const mavlink_message_t* msg)
|
|
{
|
|
return _MAV_RETURN_uint32_t(msg, 0);
|
|
}
|
|
|
|
/**
|
|
* @brief Get field fuel_level from ccmstate message
|
|
*
|
|
* @return fuel level
|
|
*/
|
|
static inline uint32_t mavlink_msg_ccmstate_get_fuel_level(const mavlink_message_t* msg)
|
|
{
|
|
return _MAV_RETURN_uint32_t(msg, 4);
|
|
}
|
|
|
|
/**
|
|
* @brief Get field temp from ccmstate message
|
|
*
|
|
* @return temp
|
|
*/
|
|
static inline uint16_t mavlink_msg_ccmstate_get_temp(const mavlink_message_t* msg, int16_t *temp)
|
|
{
|
|
return _MAV_RETURN_int16_t_array(msg, temp, 4, 8);
|
|
}
|
|
|
|
/**
|
|
* @brief Get field volts from ccmstate message
|
|
*
|
|
* @return volts
|
|
*/
|
|
static inline uint16_t mavlink_msg_ccmstate_get_volts(const mavlink_message_t* msg, uint16_t *volts)
|
|
{
|
|
return _MAV_RETURN_uint16_t_array(msg, volts, 4, 16);
|
|
}
|
|
|
|
/**
|
|
* @brief Get field echo_seq from ccmstate message
|
|
*
|
|
* @return echo seq
|
|
*/
|
|
static inline uint8_t mavlink_msg_ccmstate_get_echo_seq(const mavlink_message_t* msg)
|
|
{
|
|
return _MAV_RETURN_uint8_t(msg, 24);
|
|
}
|
|
|
|
/**
|
|
* @brief Decode a ccmstate message into a struct
|
|
*
|
|
* @param msg The message to decode
|
|
* @param ccmstate C-struct to decode the message contents into
|
|
*/
|
|
static inline void mavlink_msg_ccmstate_decode(const mavlink_message_t* msg, mavlink_ccmstate_t* ccmstate)
|
|
{
|
|
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
|
|
ccmstate->time_boot_ms = mavlink_msg_ccmstate_get_time_boot_ms(msg);
|
|
ccmstate->fuel_level = mavlink_msg_ccmstate_get_fuel_level(msg);
|
|
mavlink_msg_ccmstate_get_temp(msg, ccmstate->temp);
|
|
mavlink_msg_ccmstate_get_volts(msg, ccmstate->volts);
|
|
ccmstate->echo_seq = mavlink_msg_ccmstate_get_echo_seq(msg);
|
|
#else
|
|
uint8_t len = msg->len < MAVLINK_MSG_ID_CCMState_LEN? msg->len : MAVLINK_MSG_ID_CCMState_LEN;
|
|
memset(ccmstate, 0, MAVLINK_MSG_ID_CCMState_LEN);
|
|
memcpy(ccmstate, _MAV_PAYLOAD(msg), len);
|
|
#endif
|
|
}
|