Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
// MESSAGE PARAM_VALUE PACKING
2
 
3
#define MAVLINK_MSG_ID_PARAM_VALUE 22
4
 
5
typedef struct __mavlink_param_value_t
6
{
7
 int8_t param_id[15]; ///< Onboard parameter id
8
 float param_value; ///< Onboard parameter value
9
 uint16_t param_count; ///< Total number of onboard parameters
10
 uint16_t param_index; ///< Index of this onboard parameter
11
} mavlink_param_value_t;
12
 
13
#define MAVLINK_MSG_ID_PARAM_VALUE_LEN 23
14
#define MAVLINK_MSG_ID_22_LEN 23
15
 
16
#define MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN 15
17
 
18
#define MAVLINK_MESSAGE_INFO_PARAM_VALUE { \
19
        "PARAM_VALUE", \
20
        4, \
21
        {  { "param_id", NULL, MAVLINK_TYPE_INT8_T, 15, 0, offsetof(mavlink_param_value_t, param_id) }, \
22
         { "param_value", NULL, MAVLINK_TYPE_FLOAT, 0, 15, offsetof(mavlink_param_value_t, param_value) }, \
23
         { "param_count", NULL, MAVLINK_TYPE_UINT16_T, 0, 19, offsetof(mavlink_param_value_t, param_count) }, \
24
         { "param_index", NULL, MAVLINK_TYPE_UINT16_T, 0, 21, offsetof(mavlink_param_value_t, param_index) }, \
25
         } \
26
}
27
 
28
 
29
/**
30
 * @brief Pack a param_value message
31
 * @param system_id ID of this system
32
 * @param component_id ID of this component (e.g. 200 for IMU)
33
 * @param msg The MAVLink message to compress the data into
34
 *
35
 * @param param_id Onboard parameter id
36
 * @param param_value Onboard parameter value
37
 * @param param_count Total number of onboard parameters
38
 * @param param_index Index of this onboard parameter
39
 * @return length of the message in bytes (excluding serial stream start sign)
40
 */
41
static inline uint16_t mavlink_msg_param_value_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
42
                                                       const int8_t *param_id, float param_value, uint16_t param_count, uint16_t param_index)
43
{
44
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
45
        char buf[23];
46
        _mav_put_float(buf, 15, param_value);
47
        _mav_put_uint16_t(buf, 19, param_count);
48
        _mav_put_uint16_t(buf, 21, param_index);
49
        _mav_put_int8_t_array(buf, 0, param_id, 15);
50
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 23);
51
#else
52
        mavlink_param_value_t packet;
53
        packet.param_value = param_value;
54
        packet.param_count = param_count;
55
        packet.param_index = param_index;
56
        mav_array_memcpy(packet.param_id, param_id, sizeof(int8_t)*15);
57
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 23);
58
#endif
59
 
60
        msg->msgid = MAVLINK_MSG_ID_PARAM_VALUE;
61
        return mavlink_finalize_message(msg, system_id, component_id, 23);
62
}
63
 
64
/**
65
 * @brief Pack a param_value message on a channel
66
 * @param system_id ID of this system
67
 * @param component_id ID of this component (e.g. 200 for IMU)
68
 * @param chan The MAVLink channel this message was sent over
69
 * @param msg The MAVLink message to compress the data into
70
 * @param param_id Onboard parameter id
71
 * @param param_value Onboard parameter value
72
 * @param param_count Total number of onboard parameters
73
 * @param param_index Index of this onboard parameter
74
 * @return length of the message in bytes (excluding serial stream start sign)
75
 */
76
static inline uint16_t mavlink_msg_param_value_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
77
                                                           mavlink_message_t* msg,
78
                                                           const int8_t *param_id,float param_value,uint16_t param_count,uint16_t param_index)
79
{
80
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
81
        char buf[23];
82
        _mav_put_float(buf, 15, param_value);
83
        _mav_put_uint16_t(buf, 19, param_count);
84
        _mav_put_uint16_t(buf, 21, param_index);
85
        _mav_put_int8_t_array(buf, 0, param_id, 15);
86
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 23);
87
#else
88
        mavlink_param_value_t packet;
89
        packet.param_value = param_value;
90
        packet.param_count = param_count;
91
        packet.param_index = param_index;
92
        mav_array_memcpy(packet.param_id, param_id, sizeof(int8_t)*15);
93
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 23);
94
#endif
95
 
96
        msg->msgid = MAVLINK_MSG_ID_PARAM_VALUE;
97
        return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 23);
98
}
99
 
100
/**
101
 * @brief Encode a param_value struct into a message
102
 *
103
 * @param system_id ID of this system
104
 * @param component_id ID of this component (e.g. 200 for IMU)
105
 * @param msg The MAVLink message to compress the data into
106
 * @param param_value C-struct to read the message contents from
107
 */
108
static inline uint16_t mavlink_msg_param_value_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_param_value_t* param_value)
109
{
110
        return mavlink_msg_param_value_pack(system_id, component_id, msg, param_value->param_id, param_value->param_value, param_value->param_count, param_value->param_index);
111
}
112
 
113
/**
114
 * @brief Send a param_value message
115
 * @param chan MAVLink channel to send the message
116
 *
117
 * @param param_id Onboard parameter id
118
 * @param param_value Onboard parameter value
119
 * @param param_count Total number of onboard parameters
120
 * @param param_index Index of this onboard parameter
121
 */
122
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
123
 
124
static inline void mavlink_msg_param_value_send(mavlink_channel_t chan, const int8_t *param_id, float param_value, uint16_t param_count, uint16_t param_index)
125
{
126
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
127
        char buf[23];
128
        _mav_put_float(buf, 15, param_value);
129
        _mav_put_uint16_t(buf, 19, param_count);
130
        _mav_put_uint16_t(buf, 21, param_index);
131
        _mav_put_int8_t_array(buf, 0, param_id, 15);
132
        _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_VALUE, buf, 23);
133
#else
134
        mavlink_param_value_t packet;
135
        packet.param_value = param_value;
136
        packet.param_count = param_count;
137
        packet.param_index = param_index;
138
        mav_array_memcpy(packet.param_id, param_id, sizeof(int8_t)*15);
139
        _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_VALUE, (const char *)&packet, 23);
140
#endif
141
}
142
 
143
#endif
144
 
145
// MESSAGE PARAM_VALUE UNPACKING
146
 
147
 
148
/**
149
 * @brief Get field param_id from param_value message
150
 *
151
 * @return Onboard parameter id
152
 */
153
static inline uint16_t mavlink_msg_param_value_get_param_id(const mavlink_message_t* msg, int8_t *param_id)
154
{
155
        return _MAV_RETURN_int8_t_array(msg, param_id, 15,  0);
156
}
157
 
158
/**
159
 * @brief Get field param_value from param_value message
160
 *
161
 * @return Onboard parameter value
162
 */
163
static inline float mavlink_msg_param_value_get_param_value(const mavlink_message_t* msg)
164
{
165
        return _MAV_RETURN_float(msg,  15);
166
}
167
 
168
/**
169
 * @brief Get field param_count from param_value message
170
 *
171
 * @return Total number of onboard parameters
172
 */
173
static inline uint16_t mavlink_msg_param_value_get_param_count(const mavlink_message_t* msg)
174
{
175
        return _MAV_RETURN_uint16_t(msg,  19);
176
}
177
 
178
/**
179
 * @brief Get field param_index from param_value message
180
 *
181
 * @return Index of this onboard parameter
182
 */
183
static inline uint16_t mavlink_msg_param_value_get_param_index(const mavlink_message_t* msg)
184
{
185
        return _MAV_RETURN_uint16_t(msg,  21);
186
}
187
 
188
/**
189
 * @brief Decode a param_value message into a struct
190
 *
191
 * @param msg The message to decode
192
 * @param param_value C-struct to decode the message contents into
193
 */
194
static inline void mavlink_msg_param_value_decode(const mavlink_message_t* msg, mavlink_param_value_t* param_value)
195
{
196
#if MAVLINK_NEED_BYTE_SWAP
197
        mavlink_msg_param_value_get_param_id(msg, param_value->param_id);
198
        param_value->param_value = mavlink_msg_param_value_get_param_value(msg);
199
        param_value->param_count = mavlink_msg_param_value_get_param_count(msg);
200
        param_value->param_index = mavlink_msg_param_value_get_param_index(msg);
201
#else
202
        memcpy(param_value, _MAV_PAYLOAD(msg), 23);
203
#endif
204
}