Subversion Repositories Projects

Rev

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

Rev Author Line No. Line
1702 - 1
// MESSAGE SET_MAG_OFFSETS PACKING
2
 
3
#define MAVLINK_MSG_ID_SET_MAG_OFFSETS 151
4
 
5
typedef struct __mavlink_set_mag_offsets_t
6
{
7
 uint8_t target_system; ///< System ID
8
 uint8_t target_component; ///< Component ID
9
 int16_t mag_ofs_x; ///< magnetometer X offset
10
 int16_t mag_ofs_y; ///< magnetometer Y offset
11
 int16_t mag_ofs_z; ///< magnetometer Z offset
12
} mavlink_set_mag_offsets_t;
13
 
14
#define MAVLINK_MSG_ID_SET_MAG_OFFSETS_LEN 8
15
#define MAVLINK_MSG_ID_151_LEN 8
16
 
17
 
18
 
19
#define MAVLINK_MESSAGE_INFO_SET_MAG_OFFSETS { \
20
        "SET_MAG_OFFSETS", \
21
        5, \
22
        {  { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_set_mag_offsets_t, target_system) }, \
23
         { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_set_mag_offsets_t, target_component) }, \
24
         { "mag_ofs_x", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_set_mag_offsets_t, mag_ofs_x) }, \
25
         { "mag_ofs_y", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_set_mag_offsets_t, mag_ofs_y) }, \
26
         { "mag_ofs_z", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_set_mag_offsets_t, mag_ofs_z) }, \
27
         } \
28
}
29
 
30
 
31
/**
32
 * @brief Pack a set_mag_offsets message
33
 * @param system_id ID of this system
34
 * @param component_id ID of this component (e.g. 200 for IMU)
35
 * @param msg The MAVLink message to compress the data into
36
 *
37
 * @param target_system System ID
38
 * @param target_component Component ID
39
 * @param mag_ofs_x magnetometer X offset
40
 * @param mag_ofs_y magnetometer Y offset
41
 * @param mag_ofs_z magnetometer Z offset
42
 * @return length of the message in bytes (excluding serial stream start sign)
43
 */
44
static inline uint16_t mavlink_msg_set_mag_offsets_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
45
                                                       uint8_t target_system, uint8_t target_component, int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z)
46
{
47
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
48
        char buf[8];
49
        _mav_put_uint8_t(buf, 0, target_system);
50
        _mav_put_uint8_t(buf, 1, target_component);
51
        _mav_put_int16_t(buf, 2, mag_ofs_x);
52
        _mav_put_int16_t(buf, 4, mag_ofs_y);
53
        _mav_put_int16_t(buf, 6, mag_ofs_z);
54
 
55
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8);
56
#else
57
        mavlink_set_mag_offsets_t packet;
58
        packet.target_system = target_system;
59
        packet.target_component = target_component;
60
        packet.mag_ofs_x = mag_ofs_x;
61
        packet.mag_ofs_y = mag_ofs_y;
62
        packet.mag_ofs_z = mag_ofs_z;
63
 
64
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8);
65
#endif
66
 
67
        msg->msgid = MAVLINK_MSG_ID_SET_MAG_OFFSETS;
68
        return mavlink_finalize_message(msg, system_id, component_id, 8);
69
}
70
 
71
/**
72
 * @brief Pack a set_mag_offsets message on a channel
73
 * @param system_id ID of this system
74
 * @param component_id ID of this component (e.g. 200 for IMU)
75
 * @param chan The MAVLink channel this message was sent over
76
 * @param msg The MAVLink message to compress the data into
77
 * @param target_system System ID
78
 * @param target_component Component ID
79
 * @param mag_ofs_x magnetometer X offset
80
 * @param mag_ofs_y magnetometer Y offset
81
 * @param mag_ofs_z magnetometer Z offset
82
 * @return length of the message in bytes (excluding serial stream start sign)
83
 */
84
static inline uint16_t mavlink_msg_set_mag_offsets_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
85
                                                           mavlink_message_t* msg,
86
                                                           uint8_t target_system,uint8_t target_component,int16_t mag_ofs_x,int16_t mag_ofs_y,int16_t mag_ofs_z)
87
{
88
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
89
        char buf[8];
90
        _mav_put_uint8_t(buf, 0, target_system);
91
        _mav_put_uint8_t(buf, 1, target_component);
92
        _mav_put_int16_t(buf, 2, mag_ofs_x);
93
        _mav_put_int16_t(buf, 4, mag_ofs_y);
94
        _mav_put_int16_t(buf, 6, mag_ofs_z);
95
 
96
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8);
97
#else
98
        mavlink_set_mag_offsets_t packet;
99
        packet.target_system = target_system;
100
        packet.target_component = target_component;
101
        packet.mag_ofs_x = mag_ofs_x;
102
        packet.mag_ofs_y = mag_ofs_y;
103
        packet.mag_ofs_z = mag_ofs_z;
104
 
105
        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8);
106
#endif
107
 
108
        msg->msgid = MAVLINK_MSG_ID_SET_MAG_OFFSETS;
109
        return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 8);
110
}
111
 
112
/**
113
 * @brief Encode a set_mag_offsets struct into a message
114
 *
115
 * @param system_id ID of this system
116
 * @param component_id ID of this component (e.g. 200 for IMU)
117
 * @param msg The MAVLink message to compress the data into
118
 * @param set_mag_offsets C-struct to read the message contents from
119
 */
120
static inline uint16_t mavlink_msg_set_mag_offsets_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_mag_offsets_t* set_mag_offsets)
121
{
122
        return mavlink_msg_set_mag_offsets_pack(system_id, component_id, msg, set_mag_offsets->target_system, set_mag_offsets->target_component, set_mag_offsets->mag_ofs_x, set_mag_offsets->mag_ofs_y, set_mag_offsets->mag_ofs_z);
123
}
124
 
125
/**
126
 * @brief Send a set_mag_offsets message
127
 * @param chan MAVLink channel to send the message
128
 *
129
 * @param target_system System ID
130
 * @param target_component Component ID
131
 * @param mag_ofs_x magnetometer X offset
132
 * @param mag_ofs_y magnetometer Y offset
133
 * @param mag_ofs_z magnetometer Z offset
134
 */
135
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
136
 
137
static inline void mavlink_msg_set_mag_offsets_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, int16_t mag_ofs_x, int16_t mag_ofs_y, int16_t mag_ofs_z)
138
{
139
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
140
        char buf[8];
141
        _mav_put_uint8_t(buf, 0, target_system);
142
        _mav_put_uint8_t(buf, 1, target_component);
143
        _mav_put_int16_t(buf, 2, mag_ofs_x);
144
        _mav_put_int16_t(buf, 4, mag_ofs_y);
145
        _mav_put_int16_t(buf, 6, mag_ofs_z);
146
 
147
        _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MAG_OFFSETS, buf, 8);
148
#else
149
        mavlink_set_mag_offsets_t packet;
150
        packet.target_system = target_system;
151
        packet.target_component = target_component;
152
        packet.mag_ofs_x = mag_ofs_x;
153
        packet.mag_ofs_y = mag_ofs_y;
154
        packet.mag_ofs_z = mag_ofs_z;
155
 
156
        _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_MAG_OFFSETS, (const char *)&packet, 8);
157
#endif
158
}
159
 
160
#endif
161
 
162
// MESSAGE SET_MAG_OFFSETS UNPACKING
163
 
164
 
165
/**
166
 * @brief Get field target_system from set_mag_offsets message
167
 *
168
 * @return System ID
169
 */
170
static inline uint8_t mavlink_msg_set_mag_offsets_get_target_system(const mavlink_message_t* msg)
171
{
172
        return _MAV_RETURN_uint8_t(msg,  0);
173
}
174
 
175
/**
176
 * @brief Get field target_component from set_mag_offsets message
177
 *
178
 * @return Component ID
179
 */
180
static inline uint8_t mavlink_msg_set_mag_offsets_get_target_component(const mavlink_message_t* msg)
181
{
182
        return _MAV_RETURN_uint8_t(msg,  1);
183
}
184
 
185
/**
186
 * @brief Get field mag_ofs_x from set_mag_offsets message
187
 *
188
 * @return magnetometer X offset
189
 */
190
static inline int16_t mavlink_msg_set_mag_offsets_get_mag_ofs_x(const mavlink_message_t* msg)
191
{
192
        return _MAV_RETURN_int16_t(msg,  2);
193
}
194
 
195
/**
196
 * @brief Get field mag_ofs_y from set_mag_offsets message
197
 *
198
 * @return magnetometer Y offset
199
 */
200
static inline int16_t mavlink_msg_set_mag_offsets_get_mag_ofs_y(const mavlink_message_t* msg)
201
{
202
        return _MAV_RETURN_int16_t(msg,  4);
203
}
204
 
205
/**
206
 * @brief Get field mag_ofs_z from set_mag_offsets message
207
 *
208
 * @return magnetometer Z offset
209
 */
210
static inline int16_t mavlink_msg_set_mag_offsets_get_mag_ofs_z(const mavlink_message_t* msg)
211
{
212
        return _MAV_RETURN_int16_t(msg,  6);
213
}
214
 
215
/**
216
 * @brief Decode a set_mag_offsets message into a struct
217
 *
218
 * @param msg The message to decode
219
 * @param set_mag_offsets C-struct to decode the message contents into
220
 */
221
static inline void mavlink_msg_set_mag_offsets_decode(const mavlink_message_t* msg, mavlink_set_mag_offsets_t* set_mag_offsets)
222
{
223
#if MAVLINK_NEED_BYTE_SWAP
224
        set_mag_offsets->target_system = mavlink_msg_set_mag_offsets_get_target_system(msg);
225
        set_mag_offsets->target_component = mavlink_msg_set_mag_offsets_get_target_component(msg);
226
        set_mag_offsets->mag_ofs_x = mavlink_msg_set_mag_offsets_get_mag_ofs_x(msg);
227
        set_mag_offsets->mag_ofs_y = mavlink_msg_set_mag_offsets_get_mag_ofs_y(msg);
228
        set_mag_offsets->mag_ofs_z = mavlink_msg_set_mag_offsets_get_mag_ofs_z(msg);
229
#else
230
        memcpy(set_mag_offsets, _MAV_PAYLOAD(msg), 8);
231
#endif
232
}