Line data Source code
1 : // ServoPackets.c was generated by ProtoGen version 3.2.a
2 :
3 : /*
4 : * This file is free software: you can redistribute it and/or modify it
5 : * under the terms of the GNU General Public License as published by the
6 : * Free Software Foundation, either version 3 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * This file is distributed in the hope that it will be useful, but
10 : * WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 : * See the GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License along
15 : * with this program. If not, see <http://www.gnu.org/licenses/>.
16 : *
17 : * Author: Oliver Walters / Currawong Engineering Pty Ltd
18 : */
19 :
20 : #include "ServoPackets.h"
21 : #include "fielddecode.h"
22 : #include "fieldencode.h"
23 : #include "scaleddecode.h"
24 : #include "scaledencode.h"
25 :
26 : /*!
27 : * \brief Create the Servo_Config packet
28 : *
29 : * General servo configuration settings
30 : * \param _pg_pkt points to the packet which will be created by this function
31 : * \param _pg_user points to the user data that will be encoded in _pg_pkt
32 : */
33 0 : void encodeServo_ConfigPacketStructure(void* _pg_pkt, const Servo_Config_t* _pg_user)
34 : {
35 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
36 0 : int _pg_byteindex = 0;
37 0 : unsigned _pg_i = 0;
38 :
39 : // Servo configuration parameters
40 0 : encodeServo_ConfigBits_t(_pg_data, &_pg_byteindex, &_pg_user->options);
41 :
42 : // Servo command timeout
43 : // Range of commandTimeout is 0 to 65535.
44 0 : uint16ToBeBytes(_pg_user->commandTimeout, _pg_data, &_pg_byteindex);
45 :
46 : // Servo neutral position. Servo can be configured to return to this position at powerup, or after loss of communication
47 : // Range of homePosition is -32768 to 32767.
48 0 : int16ToBeBytes(_pg_user->homePosition, _pg_data, &_pg_byteindex);
49 :
50 : // Reserved for future use
51 : // Range of reserved is 0 to 255.
52 0 : for(_pg_i = 0; _pg_i < 2; _pg_i++)
53 0 : uint8ToBytes(_pg_user->reserved[_pg_i], _pg_data, &_pg_byteindex);
54 :
55 : // complete the process of creating the packet
56 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_ConfigPacketID());
57 :
58 0 : }// encodeServo_ConfigPacketStructure
59 :
60 : /*!
61 : * \brief Decode the Servo_Config packet
62 : *
63 : * General servo configuration settings
64 : * \param _pg_pkt points to the packet being decoded by this function
65 : * \param _pg_user receives the data decoded from the packet
66 : * \return 0 is returned if the packet ID or size is wrong, else 1
67 : */
68 0 : int decodeServo_ConfigPacketStructure(const void* _pg_pkt, Servo_Config_t* _pg_user)
69 : {
70 : int _pg_numbytes;
71 0 : int _pg_byteindex = 0;
72 : const uint8_t* _pg_data;
73 0 : unsigned _pg_i = 0;
74 :
75 : // Verify the packet identifier
76 0 : if(getServoPacketID(_pg_pkt) != getServo_ConfigPacketID())
77 0 : return 0;
78 :
79 : // Verify the packet size
80 0 : _pg_numbytes = getServoPacketSize(_pg_pkt);
81 0 : if(_pg_numbytes < getServo_ConfigMinDataLength())
82 0 : return 0;
83 :
84 : // The raw data from the packet
85 0 : _pg_data = getServoPacketDataConst(_pg_pkt);
86 :
87 : // Servo configuration parameters
88 0 : if(decodeServo_ConfigBits_t(_pg_data, &_pg_byteindex, &_pg_user->options) == 0)
89 0 : return 0;
90 :
91 : // Servo command timeout
92 : // Range of commandTimeout is 0 to 65535.
93 0 : _pg_user->commandTimeout = uint16FromBeBytes(_pg_data, &_pg_byteindex);
94 :
95 : // Servo neutral position. Servo can be configured to return to this position at powerup, or after loss of communication
96 : // Range of homePosition is -32768 to 32767.
97 0 : _pg_user->homePosition = int16FromBeBytes(_pg_data, &_pg_byteindex);
98 :
99 : // Reserved for future use
100 : // Range of reserved is 0 to 255.
101 0 : for(_pg_i = 0; _pg_i < 2; _pg_i++)
102 0 : _pg_user->reserved[_pg_i] = uint8FromBytes(_pg_data, &_pg_byteindex);
103 :
104 0 : return 1;
105 :
106 : }// decodeServo_ConfigPacketStructure
107 :
108 : /*!
109 : * \brief Create the Servo_Config packet
110 : *
111 : * General servo configuration settings
112 : * \param _pg_pkt points to the packet which will be created by this function
113 : * \param options is Servo configuration parameters
114 : * \param commandTimeout is Servo command timeout
115 : * \param homePosition is Servo neutral position. Servo can be configured to return to this position at powerup, or after loss of communication
116 : * \param reserved is Reserved for future use
117 : */
118 0 : void encodeServo_ConfigPacket(void* _pg_pkt, const Servo_ConfigBits_t* options, uint16_t commandTimeout, int16_t homePosition, const uint8_t reserved[2])
119 : {
120 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
121 0 : int _pg_byteindex = 0;
122 0 : unsigned _pg_i = 0;
123 :
124 : // Servo configuration parameters
125 0 : encodeServo_ConfigBits_t(_pg_data, &_pg_byteindex, options);
126 :
127 : // Servo command timeout
128 : // Range of commandTimeout is 0 to 65535.
129 0 : uint16ToBeBytes(commandTimeout, _pg_data, &_pg_byteindex);
130 :
131 : // Servo neutral position. Servo can be configured to return to this position at powerup, or after loss of communication
132 : // Range of homePosition is -32768 to 32767.
133 0 : int16ToBeBytes(homePosition, _pg_data, &_pg_byteindex);
134 :
135 : // Reserved for future use
136 : // Range of reserved is 0 to 255.
137 0 : for(_pg_i = 0; _pg_i < 2; _pg_i++)
138 0 : uint8ToBytes(reserved[_pg_i], _pg_data, &_pg_byteindex);
139 :
140 : // complete the process of creating the packet
141 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_ConfigPacketID());
142 :
143 0 : }// encodeServo_ConfigPacket
144 :
145 : /*!
146 : * \brief Decode the Servo_Config packet
147 : *
148 : * General servo configuration settings
149 : * \param _pg_pkt points to the packet being decoded by this function
150 : * \param options receives Servo configuration parameters
151 : * \param commandTimeout receives Servo command timeout
152 : * \param homePosition receives Servo neutral position. Servo can be configured to return to this position at powerup, or after loss of communication
153 : * \param reserved receives Reserved for future use
154 : * \return 0 is returned if the packet ID or size is wrong, else 1
155 : */
156 0 : int decodeServo_ConfigPacket(const void* _pg_pkt, Servo_ConfigBits_t* options, uint16_t* commandTimeout, int16_t* homePosition, uint8_t reserved[2])
157 : {
158 0 : unsigned _pg_i = 0;
159 0 : int _pg_byteindex = 0;
160 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
161 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
162 :
163 : // Verify the packet identifier
164 0 : if(getServoPacketID(_pg_pkt) != getServo_ConfigPacketID())
165 0 : return 0;
166 :
167 0 : if(_pg_numbytes < getServo_ConfigMinDataLength())
168 0 : return 0;
169 :
170 : // Servo configuration parameters
171 0 : if(decodeServo_ConfigBits_t(_pg_data, &_pg_byteindex, options) == 0)
172 0 : return 0;
173 :
174 : // Servo command timeout
175 : // Range of commandTimeout is 0 to 65535.
176 0 : (*commandTimeout) = uint16FromBeBytes(_pg_data, &_pg_byteindex);
177 :
178 : // Servo neutral position. Servo can be configured to return to this position at powerup, or after loss of communication
179 : // Range of homePosition is -32768 to 32767.
180 0 : (*homePosition) = int16FromBeBytes(_pg_data, &_pg_byteindex);
181 :
182 : // Reserved for future use
183 : // Range of reserved is 0 to 255.
184 0 : for(_pg_i = 0; _pg_i < 2; _pg_i++)
185 0 : reserved[_pg_i] = uint8FromBytes(_pg_data, &_pg_byteindex);
186 :
187 0 : return 1;
188 :
189 : }// decodeServo_ConfigPacket
190 :
191 : /*!
192 : * \brief Encode a Servo_Config_t into a byte array
193 : *
194 : * General servo configuration settings
195 : * \param _pg_data points to the byte array to add encoded data to
196 : * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of encoded bytes.
197 : * \param _pg_user is the data to encode in the byte array
198 : */
199 0 : void encodeServo_Config_t(uint8_t* _pg_data, int* _pg_bytecount, const Servo_Config_t* _pg_user)
200 : {
201 0 : int _pg_byteindex = *_pg_bytecount;
202 0 : unsigned _pg_i = 0;
203 :
204 : // Servo configuration parameters
205 0 : encodeServo_ConfigBits_t(_pg_data, &_pg_byteindex, &_pg_user->options);
206 :
207 : // Servo command timeout
208 : // Range of commandTimeout is 0 to 65535.
209 0 : uint16ToBeBytes(_pg_user->commandTimeout, _pg_data, &_pg_byteindex);
210 :
211 : // Servo neutral position. Servo can be configured to return to this position at powerup, or after loss of communication
212 : // Range of homePosition is -32768 to 32767.
213 0 : int16ToBeBytes(_pg_user->homePosition, _pg_data, &_pg_byteindex);
214 :
215 : // Reserved for future use
216 : // Range of reserved is 0 to 255.
217 0 : for(_pg_i = 0; _pg_i < 2; _pg_i++)
218 0 : uint8ToBytes(_pg_user->reserved[_pg_i], _pg_data, &_pg_byteindex);
219 :
220 0 : *_pg_bytecount = _pg_byteindex;
221 :
222 0 : }// encodeServo_Config_t
223 :
224 : /*!
225 : * \brief Decode a Servo_Config_t from a byte array
226 : *
227 : * General servo configuration settings
228 : * \param _pg_data points to the byte array to decoded data from
229 : * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of bytes decoded
230 : * \param _pg_user is the data to decode from the byte array
231 : * \return 1 if the data are decoded, else 0.
232 : */
233 0 : int decodeServo_Config_t(const uint8_t* _pg_data, int* _pg_bytecount, Servo_Config_t* _pg_user)
234 : {
235 0 : int _pg_byteindex = *_pg_bytecount;
236 0 : unsigned _pg_i = 0;
237 :
238 : // Servo configuration parameters
239 0 : if(decodeServo_ConfigBits_t(_pg_data, &_pg_byteindex, &_pg_user->options) == 0)
240 0 : return 0;
241 :
242 : // Servo command timeout
243 : // Range of commandTimeout is 0 to 65535.
244 0 : _pg_user->commandTimeout = uint16FromBeBytes(_pg_data, &_pg_byteindex);
245 :
246 : // Servo neutral position. Servo can be configured to return to this position at powerup, or after loss of communication
247 : // Range of homePosition is -32768 to 32767.
248 0 : _pg_user->homePosition = int16FromBeBytes(_pg_data, &_pg_byteindex);
249 :
250 : // Reserved for future use
251 : // Range of reserved is 0 to 255.
252 0 : for(_pg_i = 0; _pg_i < 2; _pg_i++)
253 0 : _pg_user->reserved[_pg_i] = uint8FromBytes(_pg_data, &_pg_byteindex);
254 :
255 0 : *_pg_bytecount = _pg_byteindex;
256 :
257 0 : return 1;
258 :
259 : }// decodeServo_Config_t
260 :
261 : /*!
262 : * \brief Create the Servo_MultiPositionCommand packet
263 : *
264 : * This packet can be used to simultaneously command multiple servos which have
265 : * sequential CAN ID values. This packet must be sent as a broadcast packet
266 : * (address = 0xFF) such that all servos can receive it. These commands can be
267 : * sent to groups of servos with ID values up to 64, using different
268 : * PKT_SERVO_MULTI_COMMAND_x packet ID values.
269 : * \param _pg_pkt points to the packet which will be created by this function
270 : * \param commandA is Servo command for servo with address offset 0
271 : * \param commandB is Servo command for servo with address offset 1
272 : * \param commandC is Servo command for servo with address offset 3
273 : * \param commandD is Servo command for servo with address offset 3
274 : * \param id is the packet identifier for _pg_pkt
275 : */
276 0 : void encodeServo_MultiPositionCommandPacket(void* _pg_pkt, int16_t commandA, int16_t commandB, int16_t commandC, int16_t commandD, uint32_t _pg_id)
277 : {
278 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
279 0 : int _pg_byteindex = 0;
280 :
281 : // Servo command for servo with address offset 0
282 : // Range of commandA is -32768 to 32767.
283 0 : int16ToBeBytes(commandA, _pg_data, &_pg_byteindex);
284 :
285 : // Servo command for servo with address offset 1
286 : // Range of commandB is -32768 to 32767.
287 0 : int16ToBeBytes(commandB, _pg_data, &_pg_byteindex);
288 :
289 : // Servo command for servo with address offset 3
290 : // Range of commandC is -32768 to 32767.
291 0 : int16ToBeBytes(commandC, _pg_data, &_pg_byteindex);
292 :
293 : // Servo command for servo with address offset 3
294 : // Range of commandD is -32768 to 32767.
295 0 : int16ToBeBytes(commandD, _pg_data, &_pg_byteindex);
296 :
297 : // complete the process of creating the packet
298 0 : finishServoPacket(_pg_pkt, _pg_byteindex, _pg_id);
299 :
300 0 : }// encodeServo_MultiPositionCommandPacket
301 :
302 : /*!
303 : * \brief Decode the Servo_MultiPositionCommand packet
304 : *
305 : * This packet can be used to simultaneously command multiple servos which have
306 : * sequential CAN ID values. This packet must be sent as a broadcast packet
307 : * (address = 0xFF) such that all servos can receive it. These commands can be
308 : * sent to groups of servos with ID values up to 64, using different
309 : * PKT_SERVO_MULTI_COMMAND_x packet ID values.
310 : * \param _pg_pkt points to the packet being decoded by this function
311 : * \param commandA receives Servo command for servo with address offset 0
312 : * \param commandB receives Servo command for servo with address offset 1
313 : * \param commandC receives Servo command for servo with address offset 3
314 : * \param commandD receives Servo command for servo with address offset 3
315 : * \return 0 is returned if the packet ID or size is wrong, else 1
316 : */
317 0 : int decodeServo_MultiPositionCommandPacket(const void* _pg_pkt, int16_t* commandA, int16_t* commandB, int16_t* commandC, int16_t* commandD)
318 : {
319 0 : int _pg_byteindex = 0;
320 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
321 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
322 :
323 : // Verify the packet identifier, multiple options exist
324 0 : uint32_t packetid = getServoPacketID(_pg_pkt);
325 0 : if( packetid != PKT_SERVO_MULTI_COMMAND_1 &&
326 0 : packetid != PKT_SERVO_MULTI_COMMAND_2 &&
327 0 : packetid != PKT_SERVO_MULTI_COMMAND_3 &&
328 0 : packetid != PKT_SERVO_MULTI_COMMAND_4 &&
329 0 : packetid != PKT_SERVO_MULTI_COMMAND_5 &&
330 0 : packetid != PKT_SERVO_MULTI_COMMAND_6 &&
331 0 : packetid != PKT_SERVO_MULTI_COMMAND_7 &&
332 0 : packetid != PKT_SERVO_MULTI_COMMAND_8 &&
333 0 : packetid != PKT_SERVO_MULTI_COMMAND_9 &&
334 0 : packetid != PKT_SERVO_MULTI_COMMAND_10 &&
335 0 : packetid != PKT_SERVO_MULTI_COMMAND_11 &&
336 0 : packetid != PKT_SERVO_MULTI_COMMAND_12 &&
337 0 : packetid != PKT_SERVO_MULTI_COMMAND_13 &&
338 0 : packetid != PKT_SERVO_MULTI_COMMAND_14 &&
339 0 : packetid != PKT_SERVO_MULTI_COMMAND_15 &&
340 : packetid != PKT_SERVO_MULTI_COMMAND_16 )
341 0 : return 0;
342 :
343 0 : if(_pg_numbytes < getServo_MultiPositionCommandMinDataLength())
344 0 : return 0;
345 :
346 : // Servo command for servo with address offset 0
347 : // Range of commandA is -32768 to 32767.
348 0 : (*commandA) = int16FromBeBytes(_pg_data, &_pg_byteindex);
349 :
350 : // Servo command for servo with address offset 1
351 : // Range of commandB is -32768 to 32767.
352 0 : (*commandB) = int16FromBeBytes(_pg_data, &_pg_byteindex);
353 :
354 : // Servo command for servo with address offset 3
355 : // Range of commandC is -32768 to 32767.
356 0 : (*commandC) = int16FromBeBytes(_pg_data, &_pg_byteindex);
357 :
358 : // Servo command for servo with address offset 3
359 : // Range of commandD is -32768 to 32767.
360 0 : (*commandD) = int16FromBeBytes(_pg_data, &_pg_byteindex);
361 :
362 0 : return 1;
363 :
364 : }// decodeServo_MultiPositionCommandPacket
365 :
366 : /*!
367 : * \brief Create the Servo_PositionCommand packet
368 : *
369 : * Send this command to move the servo(s) to the commanded position. Position
370 : * command units depend on the configuration of the servo. Send with the
371 : * broadcast ID (0xFF) to send the position command to *all* servos.
372 : * \param _pg_pkt points to the packet which will be created by this function
373 : * \param command is Servo command
374 : */
375 0 : void encodeServo_PositionCommandPacket(void* _pg_pkt, int16_t command)
376 : {
377 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
378 0 : int _pg_byteindex = 0;
379 :
380 : // Servo command
381 : // Range of command is -32768 to 32767.
382 0 : int16ToBeBytes(command, _pg_data, &_pg_byteindex);
383 :
384 : // complete the process of creating the packet
385 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_PositionCommandPacketID());
386 :
387 0 : }// encodeServo_PositionCommandPacket
388 :
389 : /*!
390 : * \brief Decode the Servo_PositionCommand packet
391 : *
392 : * Send this command to move the servo(s) to the commanded position. Position
393 : * command units depend on the configuration of the servo. Send with the
394 : * broadcast ID (0xFF) to send the position command to *all* servos.
395 : * \param _pg_pkt points to the packet being decoded by this function
396 : * \param command receives Servo command
397 : * \return 0 is returned if the packet ID or size is wrong, else 1
398 : */
399 0 : int decodeServo_PositionCommandPacket(const void* _pg_pkt, int16_t* command)
400 : {
401 0 : int _pg_byteindex = 0;
402 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
403 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
404 :
405 : // Verify the packet identifier
406 0 : if(getServoPacketID(_pg_pkt) != getServo_PositionCommandPacketID())
407 0 : return 0;
408 :
409 0 : if(_pg_numbytes < getServo_PositionCommandMinDataLength())
410 0 : return 0;
411 :
412 : // Servo command
413 : // Range of command is -32768 to 32767.
414 0 : (*command) = int16FromBeBytes(_pg_data, &_pg_byteindex);
415 :
416 0 : return 1;
417 :
418 : }// decodeServo_PositionCommandPacket
419 :
420 : /*!
421 : * \brief Create the Servo_NeutralPositionCommand packet
422 : *
423 : * Send this command (with zero data bytes) to move the servo(s) to the neutral
424 : * position (if enabled). Send with the broadcast ID (0xFF) to move *all*
425 : * servos to their neutral positions
426 : * \param _pg_pkt points to the packet which will be created by this function
427 : */
428 0 : void encodeServo_NeutralPositionCommandPacket(void* _pg_pkt)
429 : {
430 :
431 : // Zero length packet, no data encoded
432 0 : finishServoPacket(_pg_pkt, 0, getServo_NeutralPositionCommandPacketID());
433 :
434 0 : }// encodeServo_NeutralPositionCommandPacket
435 :
436 : /*!
437 : * \brief Decode the Servo_NeutralPositionCommand packet
438 : *
439 : * Send this command (with zero data bytes) to move the servo(s) to the neutral
440 : * position (if enabled). Send with the broadcast ID (0xFF) to move *all*
441 : * servos to their neutral positions
442 : * \param _pg_pkt points to the packet being decoded by this function
443 : * \return 0 is returned if the packet ID or size is wrong, else 1
444 : */
445 0 : int decodeServo_NeutralPositionCommandPacket(const void* _pg_pkt)
446 : {
447 : // Verify the packet identifier
448 0 : if(getServoPacketID(_pg_pkt) != getServo_NeutralPositionCommandPacketID())
449 0 : return 0;
450 : else
451 0 : return 1;
452 :
453 : }// decodeServo_NeutralPositionCommandPacket
454 :
455 : /*!
456 : * \brief Create the Servo_Disable packet
457 : *
458 : * Send this command (with zero data bytes) to disable the servo. Send with the
459 : * broadcast ID (0xFF) to disable *all* servos.
460 : * \param _pg_pkt points to the packet which will be created by this function
461 : */
462 0 : void encodeServo_DisablePacket(void* _pg_pkt)
463 : {
464 :
465 : // Zero length packet, no data encoded
466 0 : finishServoPacket(_pg_pkt, 0, getServo_DisablePacketID());
467 :
468 0 : }// encodeServo_DisablePacket
469 :
470 : /*!
471 : * \brief Decode the Servo_Disable packet
472 : *
473 : * Send this command (with zero data bytes) to disable the servo. Send with the
474 : * broadcast ID (0xFF) to disable *all* servos.
475 : * \param _pg_pkt points to the packet being decoded by this function
476 : * \return 0 is returned if the packet ID or size is wrong, else 1
477 : */
478 0 : int decodeServo_DisablePacket(const void* _pg_pkt)
479 : {
480 : // Verify the packet identifier
481 0 : if(getServoPacketID(_pg_pkt) != getServo_DisablePacketID())
482 0 : return 0;
483 : else
484 0 : return 1;
485 :
486 : }// decodeServo_DisablePacket
487 :
488 : /*!
489 : * \brief Create the Servo_Enable packet
490 : *
491 : * Send this command (with zero data bytes) to enable the servo. Send with the
492 : * broadcast ID (0xFF) to enable *all* servos.
493 : * \param _pg_pkt points to the packet which will be created by this function
494 : */
495 0 : void encodeServo_EnablePacket(void* _pg_pkt)
496 : {
497 :
498 : // Zero length packet, no data encoded
499 0 : finishServoPacket(_pg_pkt, 0, getServo_EnablePacketID());
500 :
501 0 : }// encodeServo_EnablePacket
502 :
503 : /*!
504 : * \brief Decode the Servo_Enable packet
505 : *
506 : * Send this command (with zero data bytes) to enable the servo. Send with the
507 : * broadcast ID (0xFF) to enable *all* servos.
508 : * \param _pg_pkt points to the packet being decoded by this function
509 : * \return 0 is returned if the packet ID or size is wrong, else 1
510 : */
511 0 : int decodeServo_EnablePacket(const void* _pg_pkt)
512 : {
513 : // Verify the packet identifier
514 0 : if(getServoPacketID(_pg_pkt) != getServo_EnablePacketID())
515 0 : return 0;
516 : else
517 0 : return 1;
518 :
519 : }// decodeServo_EnablePacket
520 :
521 : /*!
522 : * \brief Create the Servo_SetTitle packet
523 : *
524 : * Set the human-readable description of this servo
525 : * \param _pg_pkt points to the packet which will be created by this function
526 : * \param title is
527 : */
528 0 : void encodeServo_SetTitlePacket(void* _pg_pkt, const uint8_t title[8])
529 : {
530 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
531 0 : int _pg_byteindex = 0;
532 0 : unsigned _pg_i = 0;
533 :
534 : // Range of title is 0 to 255.
535 0 : for(_pg_i = 0; _pg_i < 8; _pg_i++)
536 0 : uint8ToBytes(title[_pg_i], _pg_data, &_pg_byteindex);
537 :
538 : // complete the process of creating the packet
539 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_SetTitlePacketID());
540 :
541 0 : }// encodeServo_SetTitlePacket
542 :
543 : /*!
544 : * \brief Decode the Servo_SetTitle packet
545 : *
546 : * Set the human-readable description of this servo
547 : * \param _pg_pkt points to the packet being decoded by this function
548 : * \param title receives
549 : * \return 0 is returned if the packet ID or size is wrong, else 1
550 : */
551 0 : int decodeServo_SetTitlePacket(const void* _pg_pkt, uint8_t title[8])
552 : {
553 0 : unsigned _pg_i = 0;
554 0 : int _pg_byteindex = 0;
555 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
556 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
557 :
558 : // Verify the packet identifier
559 0 : if(getServoPacketID(_pg_pkt) != getServo_SetTitlePacketID())
560 0 : return 0;
561 :
562 0 : if(_pg_numbytes < getServo_SetTitleMinDataLength())
563 0 : return 0;
564 :
565 : // Range of title is 0 to 255.
566 0 : for(_pg_i = 0; _pg_i < 8; _pg_i++)
567 0 : title[_pg_i] = uint8FromBytes(_pg_data, &_pg_byteindex);
568 :
569 0 : return 1;
570 :
571 : }// decodeServo_SetTitlePacket
572 :
573 : /*!
574 : * \brief Create the Servo_StatusA packet
575 : *
576 : * The *SERVO_STATUS_A* packet contains status, warning and error information,
577 : * in addition to the servo position
578 : * \param _pg_pkt points to the packet which will be created by this function
579 : * \param _pg_user points to the user data that will be encoded in _pg_pkt
580 : */
581 0 : void encodeServo_StatusAPacketStructure(void* _pg_pkt, const Servo_StatusA_t* _pg_user)
582 : {
583 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
584 0 : int _pg_byteindex = 0;
585 :
586 : // Status bits contain information on servo operation
587 0 : encodeServo_StatusBits_t(_pg_data, &_pg_byteindex, &_pg_user->status);
588 :
589 : // Warning bits indicate servo is operation outside of desired range
590 0 : encodeServo_WarningBits_t(_pg_data, &_pg_byteindex, &_pg_user->warnings);
591 :
592 : // These bits indicate critical system error information
593 0 : encodeServo_ErrorBits_t(_pg_data, &_pg_byteindex, &_pg_user->errors);
594 :
595 : // Servo position, mapped to input units
596 : // Range of position is -32768 to 32767.
597 0 : int16ToBeBytes(_pg_user->position, _pg_data, &_pg_byteindex);
598 :
599 : // Servo commanded position
600 : // Range of command is -32768 to 32767.
601 0 : int16ToBeBytes(_pg_user->command, _pg_data, &_pg_byteindex);
602 :
603 : // complete the process of creating the packet
604 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_StatusAPacketID());
605 :
606 0 : }// encodeServo_StatusAPacketStructure
607 :
608 : /*!
609 : * \brief Decode the Servo_StatusA packet
610 : *
611 : * The *SERVO_STATUS_A* packet contains status, warning and error information,
612 : * in addition to the servo position
613 : * \param _pg_pkt points to the packet being decoded by this function
614 : * \param _pg_user receives the data decoded from the packet
615 : * \return 0 is returned if the packet ID or size is wrong, else 1
616 : */
617 0 : int decodeServo_StatusAPacketStructure(const void* _pg_pkt, Servo_StatusA_t* _pg_user)
618 : {
619 : int _pg_numbytes;
620 0 : int _pg_byteindex = 0;
621 : const uint8_t* _pg_data;
622 :
623 : // Verify the packet identifier
624 0 : if(getServoPacketID(_pg_pkt) != getServo_StatusAPacketID())
625 0 : return 0;
626 :
627 : // Verify the packet size
628 0 : _pg_numbytes = getServoPacketSize(_pg_pkt);
629 0 : if(_pg_numbytes < getServo_StatusAMinDataLength())
630 0 : return 0;
631 :
632 : // The raw data from the packet
633 0 : _pg_data = getServoPacketDataConst(_pg_pkt);
634 :
635 : // Status bits contain information on servo operation
636 0 : if(decodeServo_StatusBits_t(_pg_data, &_pg_byteindex, &_pg_user->status) == 0)
637 0 : return 0;
638 :
639 : // Warning bits indicate servo is operation outside of desired range
640 0 : if(decodeServo_WarningBits_t(_pg_data, &_pg_byteindex, &_pg_user->warnings) == 0)
641 0 : return 0;
642 :
643 : // These bits indicate critical system error information
644 0 : if(decodeServo_ErrorBits_t(_pg_data, &_pg_byteindex, &_pg_user->errors) == 0)
645 0 : return 0;
646 :
647 : // Servo position, mapped to input units
648 : // Range of position is -32768 to 32767.
649 0 : _pg_user->position = int16FromBeBytes(_pg_data, &_pg_byteindex);
650 :
651 : // Servo commanded position
652 : // Range of command is -32768 to 32767.
653 0 : _pg_user->command = int16FromBeBytes(_pg_data, &_pg_byteindex);
654 :
655 0 : return 1;
656 :
657 : }// decodeServo_StatusAPacketStructure
658 :
659 : /*!
660 : * \brief Create the Servo_StatusA packet
661 : *
662 : * The *SERVO_STATUS_A* packet contains status, warning and error information,
663 : * in addition to the servo position
664 : * \param _pg_pkt points to the packet which will be created by this function
665 : * \param status is Status bits contain information on servo operation
666 : * \param warnings is Warning bits indicate servo is operation outside of desired range
667 : * \param errors is These bits indicate critical system error information
668 : * \param position is Servo position, mapped to input units
669 : * \param command is Servo commanded position
670 : */
671 0 : void encodeServo_StatusAPacket(void* _pg_pkt, const Servo_StatusBits_t* status, const Servo_WarningBits_t* warnings, const Servo_ErrorBits_t* errors, int16_t position, int16_t command)
672 : {
673 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
674 0 : int _pg_byteindex = 0;
675 :
676 : // Status bits contain information on servo operation
677 0 : encodeServo_StatusBits_t(_pg_data, &_pg_byteindex, status);
678 :
679 : // Warning bits indicate servo is operation outside of desired range
680 0 : encodeServo_WarningBits_t(_pg_data, &_pg_byteindex, warnings);
681 :
682 : // These bits indicate critical system error information
683 0 : encodeServo_ErrorBits_t(_pg_data, &_pg_byteindex, errors);
684 :
685 : // Servo position, mapped to input units
686 : // Range of position is -32768 to 32767.
687 0 : int16ToBeBytes(position, _pg_data, &_pg_byteindex);
688 :
689 : // Servo commanded position
690 : // Range of command is -32768 to 32767.
691 0 : int16ToBeBytes(command, _pg_data, &_pg_byteindex);
692 :
693 : // complete the process of creating the packet
694 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_StatusAPacketID());
695 :
696 0 : }// encodeServo_StatusAPacket
697 :
698 : /*!
699 : * \brief Decode the Servo_StatusA packet
700 : *
701 : * The *SERVO_STATUS_A* packet contains status, warning and error information,
702 : * in addition to the servo position
703 : * \param _pg_pkt points to the packet being decoded by this function
704 : * \param status receives Status bits contain information on servo operation
705 : * \param warnings receives Warning bits indicate servo is operation outside of desired range
706 : * \param errors receives These bits indicate critical system error information
707 : * \param position receives Servo position, mapped to input units
708 : * \param command receives Servo commanded position
709 : * \return 0 is returned if the packet ID or size is wrong, else 1
710 : */
711 0 : int decodeServo_StatusAPacket(const void* _pg_pkt, Servo_StatusBits_t* status, Servo_WarningBits_t* warnings, Servo_ErrorBits_t* errors, int16_t* position, int16_t* command)
712 : {
713 0 : int _pg_byteindex = 0;
714 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
715 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
716 :
717 : // Verify the packet identifier
718 0 : if(getServoPacketID(_pg_pkt) != getServo_StatusAPacketID())
719 0 : return 0;
720 :
721 0 : if(_pg_numbytes < getServo_StatusAMinDataLength())
722 0 : return 0;
723 :
724 : // Status bits contain information on servo operation
725 0 : if(decodeServo_StatusBits_t(_pg_data, &_pg_byteindex, status) == 0)
726 0 : return 0;
727 :
728 : // Warning bits indicate servo is operation outside of desired range
729 0 : if(decodeServo_WarningBits_t(_pg_data, &_pg_byteindex, warnings) == 0)
730 0 : return 0;
731 :
732 : // These bits indicate critical system error information
733 0 : if(decodeServo_ErrorBits_t(_pg_data, &_pg_byteindex, errors) == 0)
734 0 : return 0;
735 :
736 : // Servo position, mapped to input units
737 : // Range of position is -32768 to 32767.
738 0 : (*position) = int16FromBeBytes(_pg_data, &_pg_byteindex);
739 :
740 : // Servo commanded position
741 : // Range of command is -32768 to 32767.
742 0 : (*command) = int16FromBeBytes(_pg_data, &_pg_byteindex);
743 :
744 0 : return 1;
745 :
746 : }// decodeServo_StatusAPacket
747 :
748 : /*!
749 : * \brief Create the Servo_StatusB packet
750 : *
751 : * The *SERVO_STATUS_B* packet contains various servo feedback data
752 : * \param _pg_pkt points to the packet which will be created by this function
753 : * \param _pg_user points to the user data that will be encoded in _pg_pkt
754 : */
755 0 : void encodeServo_StatusBPacketStructure(void* _pg_pkt, const Servo_StatusB_t* _pg_user)
756 : {
757 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
758 0 : int _pg_byteindex = 0;
759 :
760 : // Servo current
761 : // Range of current is 0 to 65535.
762 0 : uint16ToBeBytes(_pg_user->current, _pg_data, &_pg_byteindex);
763 :
764 : // Servo supply voltage
765 : // Range of voltage is 0 to 65535.
766 0 : uint16ToBeBytes(_pg_user->voltage, _pg_data, &_pg_byteindex);
767 :
768 : // Servo temperature
769 : // Range of temperature is -128 to 127.
770 0 : int8ToBytes(_pg_user->temperature, _pg_data, &_pg_byteindex);
771 :
772 : // Motor duty cycle
773 : // Range of dutyCycle is -128 to 127.
774 0 : int8ToBytes(_pg_user->dutyCycle, _pg_data, &_pg_byteindex);
775 :
776 : // Servo output shaft speed
777 : // Range of speed is -32768 to 32767.
778 0 : int16ToBeBytes(_pg_user->speed, _pg_data, &_pg_byteindex);
779 :
780 : // complete the process of creating the packet
781 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_StatusBPacketID());
782 :
783 0 : }// encodeServo_StatusBPacketStructure
784 :
785 : /*!
786 : * \brief Decode the Servo_StatusB packet
787 : *
788 : * The *SERVO_STATUS_B* packet contains various servo feedback data
789 : * \param _pg_pkt points to the packet being decoded by this function
790 : * \param _pg_user receives the data decoded from the packet
791 : * \return 0 is returned if the packet ID or size is wrong, else 1
792 : */
793 0 : int decodeServo_StatusBPacketStructure(const void* _pg_pkt, Servo_StatusB_t* _pg_user)
794 : {
795 : int _pg_numbytes;
796 0 : int _pg_byteindex = 0;
797 : const uint8_t* _pg_data;
798 :
799 : // Verify the packet identifier
800 0 : if(getServoPacketID(_pg_pkt) != getServo_StatusBPacketID())
801 0 : return 0;
802 :
803 : // Verify the packet size
804 0 : _pg_numbytes = getServoPacketSize(_pg_pkt);
805 0 : if(_pg_numbytes < getServo_StatusBMinDataLength())
806 0 : return 0;
807 :
808 : // The raw data from the packet
809 0 : _pg_data = getServoPacketDataConst(_pg_pkt);
810 :
811 : // this packet has default fields, make sure they are set
812 0 : _pg_user->dutyCycle = 0;
813 0 : _pg_user->speed = 0;
814 :
815 : // Servo current
816 : // Range of current is 0 to 65535.
817 0 : _pg_user->current = uint16FromBeBytes(_pg_data, &_pg_byteindex);
818 :
819 : // Servo supply voltage
820 : // Range of voltage is 0 to 65535.
821 0 : _pg_user->voltage = uint16FromBeBytes(_pg_data, &_pg_byteindex);
822 :
823 : // Servo temperature
824 : // Range of temperature is -128 to 127.
825 0 : _pg_user->temperature = int8FromBytes(_pg_data, &_pg_byteindex);
826 :
827 0 : if(_pg_byteindex + 1 > _pg_numbytes)
828 0 : return 1;
829 :
830 : // Motor duty cycle
831 : // Range of dutyCycle is -128 to 127.
832 0 : _pg_user->dutyCycle = int8FromBytes(_pg_data, &_pg_byteindex);
833 :
834 0 : if(_pg_byteindex + 2 > _pg_numbytes)
835 0 : return 1;
836 :
837 : // Servo output shaft speed
838 : // Range of speed is -32768 to 32767.
839 0 : _pg_user->speed = int16FromBeBytes(_pg_data, &_pg_byteindex);
840 :
841 0 : return 1;
842 :
843 : }// decodeServo_StatusBPacketStructure
844 :
845 : /*!
846 : * \brief Create the Servo_StatusB packet
847 : *
848 : * The *SERVO_STATUS_B* packet contains various servo feedback data
849 : * \param _pg_pkt points to the packet which will be created by this function
850 : * \param current is Servo current
851 : * \param voltage is Servo supply voltage
852 : * \param temperature is Servo temperature
853 : * \param dutyCycle is Motor duty cycle
854 : * \param speed is Servo output shaft speed
855 : */
856 0 : void encodeServo_StatusBPacket(void* _pg_pkt, uint16_t current, uint16_t voltage, int8_t temperature, int8_t dutyCycle, int16_t speed)
857 : {
858 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
859 0 : int _pg_byteindex = 0;
860 :
861 : // Servo current
862 : // Range of current is 0 to 65535.
863 0 : uint16ToBeBytes(current, _pg_data, &_pg_byteindex);
864 :
865 : // Servo supply voltage
866 : // Range of voltage is 0 to 65535.
867 0 : uint16ToBeBytes(voltage, _pg_data, &_pg_byteindex);
868 :
869 : // Servo temperature
870 : // Range of temperature is -128 to 127.
871 0 : int8ToBytes(temperature, _pg_data, &_pg_byteindex);
872 :
873 : // Motor duty cycle
874 : // Range of dutyCycle is -128 to 127.
875 0 : int8ToBytes(dutyCycle, _pg_data, &_pg_byteindex);
876 :
877 : // Servo output shaft speed
878 : // Range of speed is -32768 to 32767.
879 0 : int16ToBeBytes(speed, _pg_data, &_pg_byteindex);
880 :
881 : // complete the process of creating the packet
882 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_StatusBPacketID());
883 :
884 0 : }// encodeServo_StatusBPacket
885 :
886 : /*!
887 : * \brief Decode the Servo_StatusB packet
888 : *
889 : * The *SERVO_STATUS_B* packet contains various servo feedback data
890 : * \param _pg_pkt points to the packet being decoded by this function
891 : * \param current receives Servo current
892 : * \param voltage receives Servo supply voltage
893 : * \param temperature receives Servo temperature
894 : * \param dutyCycle receives Motor duty cycle
895 : * \param speed receives Servo output shaft speed
896 : * \return 0 is returned if the packet ID or size is wrong, else 1
897 : */
898 0 : int decodeServo_StatusBPacket(const void* _pg_pkt, uint16_t* current, uint16_t* voltage, int8_t* temperature, int8_t* dutyCycle, int16_t* speed)
899 : {
900 0 : int _pg_byteindex = 0;
901 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
902 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
903 :
904 : // Verify the packet identifier
905 0 : if(getServoPacketID(_pg_pkt) != getServo_StatusBPacketID())
906 0 : return 0;
907 :
908 0 : if(_pg_numbytes < getServo_StatusBMinDataLength())
909 0 : return 0;
910 :
911 : // this packet has default fields, make sure they are set
912 0 : (*dutyCycle) = 0;
913 0 : (*speed) = 0;
914 :
915 : // Servo current
916 : // Range of current is 0 to 65535.
917 0 : (*current) = uint16FromBeBytes(_pg_data, &_pg_byteindex);
918 :
919 : // Servo supply voltage
920 : // Range of voltage is 0 to 65535.
921 0 : (*voltage) = uint16FromBeBytes(_pg_data, &_pg_byteindex);
922 :
923 : // Servo temperature
924 : // Range of temperature is -128 to 127.
925 0 : (*temperature) = int8FromBytes(_pg_data, &_pg_byteindex);
926 :
927 0 : if(_pg_byteindex + 1 > _pg_numbytes)
928 0 : return 1;
929 :
930 : // Motor duty cycle
931 : // Range of dutyCycle is -128 to 127.
932 0 : (*dutyCycle) = int8FromBytes(_pg_data, &_pg_byteindex);
933 :
934 0 : if(_pg_byteindex + 2 > _pg_numbytes)
935 0 : return 1;
936 :
937 : // Servo output shaft speed
938 : // Range of speed is -32768 to 32767.
939 0 : (*speed) = int16FromBeBytes(_pg_data, &_pg_byteindex);
940 :
941 0 : return 1;
942 :
943 : }// decodeServo_StatusBPacket
944 :
945 : /*!
946 : * \brief Create the Servo_StatusC packet
947 : *
948 : * The *SERVO_STATUS_C* packet contains servo position data. It is a cut-down
949 : * packet to allow high-speed feedback on servo position
950 : * \param _pg_pkt points to the packet which will be created by this function
951 : * \param _pg_user points to the user data that will be encoded in _pg_pkt
952 : */
953 0 : void encodeServo_StatusCPacketStructure(void* _pg_pkt, const Servo_StatusC_t* _pg_user)
954 : {
955 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
956 0 : int _pg_byteindex = 0;
957 :
958 : // Servo position, mapped to input units
959 : // Range of position is -32768 to 32767.
960 0 : int16ToBeBytes(_pg_user->position, _pg_data, &_pg_byteindex);
961 :
962 : // complete the process of creating the packet
963 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_StatusCPacketID());
964 :
965 0 : }// encodeServo_StatusCPacketStructure
966 :
967 : /*!
968 : * \brief Decode the Servo_StatusC packet
969 : *
970 : * The *SERVO_STATUS_C* packet contains servo position data. It is a cut-down
971 : * packet to allow high-speed feedback on servo position
972 : * \param _pg_pkt points to the packet being decoded by this function
973 : * \param _pg_user receives the data decoded from the packet
974 : * \return 0 is returned if the packet ID or size is wrong, else 1
975 : */
976 0 : int decodeServo_StatusCPacketStructure(const void* _pg_pkt, Servo_StatusC_t* _pg_user)
977 : {
978 : int _pg_numbytes;
979 0 : int _pg_byteindex = 0;
980 : const uint8_t* _pg_data;
981 :
982 : // Verify the packet identifier
983 0 : if(getServoPacketID(_pg_pkt) != getServo_StatusCPacketID())
984 0 : return 0;
985 :
986 : // Verify the packet size
987 0 : _pg_numbytes = getServoPacketSize(_pg_pkt);
988 0 : if(_pg_numbytes < getServo_StatusCMinDataLength())
989 0 : return 0;
990 :
991 : // The raw data from the packet
992 0 : _pg_data = getServoPacketDataConst(_pg_pkt);
993 :
994 : // Servo position, mapped to input units
995 : // Range of position is -32768 to 32767.
996 0 : _pg_user->position = int16FromBeBytes(_pg_data, &_pg_byteindex);
997 :
998 0 : return 1;
999 :
1000 : }// decodeServo_StatusCPacketStructure
1001 :
1002 : /*!
1003 : * \brief Create the Servo_StatusC packet
1004 : *
1005 : * The *SERVO_STATUS_C* packet contains servo position data. It is a cut-down
1006 : * packet to allow high-speed feedback on servo position
1007 : * \param _pg_pkt points to the packet which will be created by this function
1008 : * \param position is Servo position, mapped to input units
1009 : */
1010 0 : void encodeServo_StatusCPacket(void* _pg_pkt, int16_t position)
1011 : {
1012 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1013 0 : int _pg_byteindex = 0;
1014 :
1015 : // Servo position, mapped to input units
1016 : // Range of position is -32768 to 32767.
1017 0 : int16ToBeBytes(position, _pg_data, &_pg_byteindex);
1018 :
1019 : // complete the process of creating the packet
1020 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_StatusCPacketID());
1021 :
1022 0 : }// encodeServo_StatusCPacket
1023 :
1024 : /*!
1025 : * \brief Decode the Servo_StatusC packet
1026 : *
1027 : * The *SERVO_STATUS_C* packet contains servo position data. It is a cut-down
1028 : * packet to allow high-speed feedback on servo position
1029 : * \param _pg_pkt points to the packet being decoded by this function
1030 : * \param position receives Servo position, mapped to input units
1031 : * \return 0 is returned if the packet ID or size is wrong, else 1
1032 : */
1033 0 : int decodeServo_StatusCPacket(const void* _pg_pkt, int16_t* position)
1034 : {
1035 0 : int _pg_byteindex = 0;
1036 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
1037 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
1038 :
1039 : // Verify the packet identifier
1040 0 : if(getServoPacketID(_pg_pkt) != getServo_StatusCPacketID())
1041 0 : return 0;
1042 :
1043 0 : if(_pg_numbytes < getServo_StatusCMinDataLength())
1044 0 : return 0;
1045 :
1046 : // Servo position, mapped to input units
1047 : // Range of position is -32768 to 32767.
1048 0 : (*position) = int16FromBeBytes(_pg_data, &_pg_byteindex);
1049 :
1050 0 : return 1;
1051 :
1052 : }// decodeServo_StatusCPacket
1053 :
1054 : /*!
1055 : * \brief Create the Servo_Accelerometer packet
1056 : *
1057 : * Raw accelerometer data. To convert these raw readings to 'real' units, use
1058 : * the formula acc = 0.5 * raw * fullscale / (2^resolution)
1059 : * \param _pg_pkt points to the packet which will be created by this function
1060 : * \param xAcc is X axis acceleration value
1061 : * \param yAcc is Y axis acceleration value
1062 : * \param zAcc is Z axis acceleration value
1063 : * \param fullscale is Accelerometer full-scale range
1064 : * \param resolution is Accelerometer measurement resolution, in 'bits'.
1065 : */
1066 0 : void encodeServo_AccelerometerPacket(void* _pg_pkt, int16_t xAcc, int16_t yAcc, int16_t zAcc, uint8_t fullscale, uint8_t resolution)
1067 : {
1068 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1069 0 : int _pg_byteindex = 0;
1070 :
1071 : // X axis acceleration value
1072 : // Range of xAcc is -32768 to 32767.
1073 0 : int16ToBeBytes(xAcc, _pg_data, &_pg_byteindex);
1074 :
1075 : // Y axis acceleration value
1076 : // Range of yAcc is -32768 to 32767.
1077 0 : int16ToBeBytes(yAcc, _pg_data, &_pg_byteindex);
1078 :
1079 : // Z axis acceleration value
1080 : // Range of zAcc is -32768 to 32767.
1081 0 : int16ToBeBytes(zAcc, _pg_data, &_pg_byteindex);
1082 :
1083 : // Accelerometer full-scale range
1084 : // Range of fullscale is 0 to 255.
1085 0 : uint8ToBytes(fullscale, _pg_data, &_pg_byteindex);
1086 :
1087 : // Accelerometer measurement resolution, in 'bits'.
1088 : // Range of resolution is 0 to 255.
1089 0 : uint8ToBytes(resolution, _pg_data, &_pg_byteindex);
1090 :
1091 : // complete the process of creating the packet
1092 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_AccelerometerPacketID());
1093 :
1094 0 : }// encodeServo_AccelerometerPacket
1095 :
1096 : /*!
1097 : * \brief Decode the Servo_Accelerometer packet
1098 : *
1099 : * Raw accelerometer data. To convert these raw readings to 'real' units, use
1100 : * the formula acc = 0.5 * raw * fullscale / (2^resolution)
1101 : * \param _pg_pkt points to the packet being decoded by this function
1102 : * \param xAcc receives X axis acceleration value
1103 : * \param yAcc receives Y axis acceleration value
1104 : * \param zAcc receives Z axis acceleration value
1105 : * \param fullscale receives Accelerometer full-scale range
1106 : * \param resolution receives Accelerometer measurement resolution, in 'bits'.
1107 : * \return 0 is returned if the packet ID or size is wrong, else 1
1108 : */
1109 0 : int decodeServo_AccelerometerPacket(const void* _pg_pkt, int16_t* xAcc, int16_t* yAcc, int16_t* zAcc, uint8_t* fullscale, uint8_t* resolution)
1110 : {
1111 0 : int _pg_byteindex = 0;
1112 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
1113 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
1114 :
1115 : // Verify the packet identifier
1116 0 : if(getServoPacketID(_pg_pkt) != getServo_AccelerometerPacketID())
1117 0 : return 0;
1118 :
1119 0 : if(_pg_numbytes < getServo_AccelerometerMinDataLength())
1120 0 : return 0;
1121 :
1122 : // X axis acceleration value
1123 : // Range of xAcc is -32768 to 32767.
1124 0 : (*xAcc) = int16FromBeBytes(_pg_data, &_pg_byteindex);
1125 :
1126 : // Y axis acceleration value
1127 : // Range of yAcc is -32768 to 32767.
1128 0 : (*yAcc) = int16FromBeBytes(_pg_data, &_pg_byteindex);
1129 :
1130 : // Z axis acceleration value
1131 : // Range of zAcc is -32768 to 32767.
1132 0 : (*zAcc) = int16FromBeBytes(_pg_data, &_pg_byteindex);
1133 :
1134 : // Accelerometer full-scale range
1135 : // Range of fullscale is 0 to 255.
1136 0 : (*fullscale) = uint8FromBytes(_pg_data, &_pg_byteindex);
1137 :
1138 : // Accelerometer measurement resolution, in 'bits'.
1139 : // Range of resolution is 0 to 255.
1140 0 : (*resolution) = uint8FromBytes(_pg_data, &_pg_byteindex);
1141 :
1142 0 : return 1;
1143 :
1144 : }// decodeServo_AccelerometerPacket
1145 :
1146 : /*!
1147 : * \brief Create the Servo_Address packet
1148 : *
1149 : * Servo address information
1150 : * \param _pg_pkt points to the packet which will be created by this function
1151 : * \param _pg_user points to the user data that will be encoded in _pg_pkt
1152 : */
1153 0 : void encodeServo_AddressPacketStructure(void* _pg_pkt, const Servo_Address_t* _pg_user)
1154 : {
1155 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1156 0 : int _pg_byteindex = 0;
1157 :
1158 : // Hardware revision
1159 : // Range of hwRev is 0 to 255.
1160 0 : uint8ToBytes(_pg_user->hwRev, _pg_data, &_pg_byteindex);
1161 :
1162 : // Servo serial number
1163 : // Range of serialNumber is 0 to 16777215.
1164 0 : uint24ToBeBytes((uint32_t)(limitMax(_pg_user->serialNumber, 16777215)), _pg_data, &_pg_byteindex);
1165 :
1166 : // Programmable User ID value 1/2
1167 : // Range of userIDA is 0 to 65535.
1168 0 : uint16ToBeBytes(_pg_user->userIDA, _pg_data, &_pg_byteindex);
1169 :
1170 : // Programmable User ID value 2/2
1171 : // Range of userIDB is 0 to 65535.
1172 0 : uint16ToBeBytes(_pg_user->userIDB, _pg_data, &_pg_byteindex);
1173 :
1174 : // complete the process of creating the packet
1175 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_AddressPacketID());
1176 :
1177 0 : }// encodeServo_AddressPacketStructure
1178 :
1179 : /*!
1180 : * \brief Decode the Servo_Address packet
1181 : *
1182 : * Servo address information
1183 : * \param _pg_pkt points to the packet being decoded by this function
1184 : * \param _pg_user receives the data decoded from the packet
1185 : * \return 0 is returned if the packet ID or size is wrong, else 1
1186 : */
1187 0 : int decodeServo_AddressPacketStructure(const void* _pg_pkt, Servo_Address_t* _pg_user)
1188 : {
1189 : int _pg_numbytes;
1190 0 : int _pg_byteindex = 0;
1191 : const uint8_t* _pg_data;
1192 :
1193 : // Verify the packet identifier
1194 0 : if(getServoPacketID(_pg_pkt) != getServo_AddressPacketID())
1195 0 : return 0;
1196 :
1197 : // Verify the packet size
1198 0 : _pg_numbytes = getServoPacketSize(_pg_pkt);
1199 0 : if(_pg_numbytes < getServo_AddressMinDataLength())
1200 0 : return 0;
1201 :
1202 : // The raw data from the packet
1203 0 : _pg_data = getServoPacketDataConst(_pg_pkt);
1204 :
1205 : // Hardware revision
1206 : // Range of hwRev is 0 to 255.
1207 0 : _pg_user->hwRev = uint8FromBytes(_pg_data, &_pg_byteindex);
1208 :
1209 : // Servo serial number
1210 : // Range of serialNumber is 0 to 16777215.
1211 0 : _pg_user->serialNumber = (uint32_t)uint24FromBeBytes(_pg_data, &_pg_byteindex);
1212 :
1213 : // Programmable User ID value 1/2
1214 : // Range of userIDA is 0 to 65535.
1215 0 : _pg_user->userIDA = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1216 :
1217 : // Programmable User ID value 2/2
1218 : // Range of userIDB is 0 to 65535.
1219 0 : _pg_user->userIDB = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1220 :
1221 0 : return 1;
1222 :
1223 : }// decodeServo_AddressPacketStructure
1224 :
1225 : /*!
1226 : * \brief Create the Servo_Address packet
1227 : *
1228 : * Servo address information
1229 : * \param _pg_pkt points to the packet which will be created by this function
1230 : * \param hwRev is Hardware revision
1231 : * \param serialNumber is Servo serial number
1232 : * \param userIDA is Programmable User ID value 1/2
1233 : * \param userIDB is Programmable User ID value 2/2
1234 : */
1235 0 : void encodeServo_AddressPacket(void* _pg_pkt, uint8_t hwRev, uint32_t serialNumber, uint16_t userIDA, uint16_t userIDB)
1236 : {
1237 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1238 0 : int _pg_byteindex = 0;
1239 :
1240 : // Hardware revision
1241 : // Range of hwRev is 0 to 255.
1242 0 : uint8ToBytes(hwRev, _pg_data, &_pg_byteindex);
1243 :
1244 : // Servo serial number
1245 : // Range of serialNumber is 0 to 16777215.
1246 0 : uint24ToBeBytes((uint32_t)(limitMax(serialNumber, 16777215)), _pg_data, &_pg_byteindex);
1247 :
1248 : // Programmable User ID value 1/2
1249 : // Range of userIDA is 0 to 65535.
1250 0 : uint16ToBeBytes(userIDA, _pg_data, &_pg_byteindex);
1251 :
1252 : // Programmable User ID value 2/2
1253 : // Range of userIDB is 0 to 65535.
1254 0 : uint16ToBeBytes(userIDB, _pg_data, &_pg_byteindex);
1255 :
1256 : // complete the process of creating the packet
1257 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_AddressPacketID());
1258 :
1259 0 : }// encodeServo_AddressPacket
1260 :
1261 : /*!
1262 : * \brief Decode the Servo_Address packet
1263 : *
1264 : * Servo address information
1265 : * \param _pg_pkt points to the packet being decoded by this function
1266 : * \param hwRev receives Hardware revision
1267 : * \param serialNumber receives Servo serial number
1268 : * \param userIDA receives Programmable User ID value 1/2
1269 : * \param userIDB receives Programmable User ID value 2/2
1270 : * \return 0 is returned if the packet ID or size is wrong, else 1
1271 : */
1272 0 : int decodeServo_AddressPacket(const void* _pg_pkt, uint8_t* hwRev, uint32_t* serialNumber, uint16_t* userIDA, uint16_t* userIDB)
1273 : {
1274 0 : int _pg_byteindex = 0;
1275 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
1276 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
1277 :
1278 : // Verify the packet identifier
1279 0 : if(getServoPacketID(_pg_pkt) != getServo_AddressPacketID())
1280 0 : return 0;
1281 :
1282 0 : if(_pg_numbytes < getServo_AddressMinDataLength())
1283 0 : return 0;
1284 :
1285 : // Hardware revision
1286 : // Range of hwRev is 0 to 255.
1287 0 : (*hwRev) = uint8FromBytes(_pg_data, &_pg_byteindex);
1288 :
1289 : // Servo serial number
1290 : // Range of serialNumber is 0 to 16777215.
1291 0 : (*serialNumber) = (uint32_t)uint24FromBeBytes(_pg_data, &_pg_byteindex);
1292 :
1293 : // Programmable User ID value 1/2
1294 : // Range of userIDA is 0 to 65535.
1295 0 : (*userIDA) = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1296 :
1297 : // Programmable User ID value 2/2
1298 : // Range of userIDB is 0 to 65535.
1299 0 : (*userIDB) = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1300 :
1301 0 : return 1;
1302 :
1303 : }// decodeServo_AddressPacket
1304 :
1305 : /*!
1306 : * \brief Create the Servo_Title packet
1307 : *
1308 : * Servo title information
1309 : * \param _pg_pkt points to the packet which will be created by this function
1310 : * \param title is Human readable description string for the servo
1311 : */
1312 0 : void encodeServo_TitlePacket(void* _pg_pkt, const uint8_t title[8])
1313 : {
1314 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1315 0 : int _pg_byteindex = 0;
1316 0 : unsigned _pg_i = 0;
1317 :
1318 : // Human readable description string for the servo
1319 : // Range of title is 0 to 255.
1320 0 : for(_pg_i = 0; _pg_i < 8; _pg_i++)
1321 0 : uint8ToBytes(title[_pg_i], _pg_data, &_pg_byteindex);
1322 :
1323 : // complete the process of creating the packet
1324 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_TitlePacketID());
1325 :
1326 0 : }// encodeServo_TitlePacket
1327 :
1328 : /*!
1329 : * \brief Decode the Servo_Title packet
1330 : *
1331 : * Servo title information
1332 : * \param _pg_pkt points to the packet being decoded by this function
1333 : * \param title receives Human readable description string for the servo
1334 : * \return 0 is returned if the packet ID or size is wrong, else 1
1335 : */
1336 0 : int decodeServo_TitlePacket(const void* _pg_pkt, uint8_t title[8])
1337 : {
1338 0 : unsigned _pg_i = 0;
1339 0 : int _pg_byteindex = 0;
1340 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
1341 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
1342 :
1343 : // Verify the packet identifier
1344 0 : if(getServoPacketID(_pg_pkt) != getServo_TitlePacketID())
1345 0 : return 0;
1346 :
1347 0 : if(_pg_numbytes < getServo_TitleMinDataLength())
1348 0 : return 0;
1349 :
1350 : // Human readable description string for the servo
1351 : // Range of title is 0 to 255.
1352 0 : for(_pg_i = 0; _pg_i < 8; _pg_i++)
1353 0 : title[_pg_i] = uint8FromBytes(_pg_data, &_pg_byteindex);
1354 :
1355 0 : return 1;
1356 :
1357 : }// decodeServo_TitlePacket
1358 :
1359 : /*!
1360 : * \brief Create the Servo_Firmware packet
1361 : *
1362 : * Servo firmware information
1363 : * \param _pg_pkt points to the packet which will be created by this function
1364 : * \param _pg_user points to the user data that will be encoded in _pg_pkt
1365 : */
1366 0 : void encodeServo_FirmwarePacketStructure(void* _pg_pkt, const Servo_Firmware_t* _pg_user)
1367 : {
1368 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1369 0 : int _pg_byteindex = 0;
1370 :
1371 : // Firmware version, major number
1372 : // Range of major is 0 to 255.
1373 0 : uint8ToBytes(_pg_user->major, _pg_data, &_pg_byteindex);
1374 :
1375 : // Firmware version, minor number
1376 : // Range of minor is 0 to 255.
1377 0 : uint8ToBytes(_pg_user->minor, _pg_data, &_pg_byteindex);
1378 :
1379 : // Firmware release date, day-of-month
1380 : // Range of day is 0 to 255.
1381 0 : uint8ToBytes(_pg_user->day, _pg_data, &_pg_byteindex);
1382 :
1383 : // Firmware release date, month-of-year
1384 : // Range of month is 0 to 255.
1385 0 : uint8ToBytes(_pg_user->month, _pg_data, &_pg_byteindex);
1386 :
1387 : // Firmware release date, year
1388 : // Range of year is 0 to 65535.
1389 0 : uint16ToBeBytes(_pg_user->year, _pg_data, &_pg_byteindex);
1390 :
1391 : // Firmware checksum, 16-bit
1392 : // Range of checksum is 0 to 65535.
1393 0 : uint16ToBeBytes(_pg_user->checksum, _pg_data, &_pg_byteindex);
1394 :
1395 : // complete the process of creating the packet
1396 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_FirmwarePacketID());
1397 :
1398 0 : }// encodeServo_FirmwarePacketStructure
1399 :
1400 : /*!
1401 : * \brief Decode the Servo_Firmware packet
1402 : *
1403 : * Servo firmware information
1404 : * \param _pg_pkt points to the packet being decoded by this function
1405 : * \param _pg_user receives the data decoded from the packet
1406 : * \return 0 is returned if the packet ID or size is wrong, else 1
1407 : */
1408 0 : int decodeServo_FirmwarePacketStructure(const void* _pg_pkt, Servo_Firmware_t* _pg_user)
1409 : {
1410 : int _pg_numbytes;
1411 0 : int _pg_byteindex = 0;
1412 : const uint8_t* _pg_data;
1413 :
1414 : // Verify the packet identifier
1415 0 : if(getServoPacketID(_pg_pkt) != getServo_FirmwarePacketID())
1416 0 : return 0;
1417 :
1418 : // Verify the packet size
1419 0 : _pg_numbytes = getServoPacketSize(_pg_pkt);
1420 0 : if(_pg_numbytes < getServo_FirmwareMinDataLength())
1421 0 : return 0;
1422 :
1423 : // The raw data from the packet
1424 0 : _pg_data = getServoPacketDataConst(_pg_pkt);
1425 :
1426 : // Firmware version, major number
1427 : // Range of major is 0 to 255.
1428 0 : _pg_user->major = uint8FromBytes(_pg_data, &_pg_byteindex);
1429 :
1430 : // Firmware version, minor number
1431 : // Range of minor is 0 to 255.
1432 0 : _pg_user->minor = uint8FromBytes(_pg_data, &_pg_byteindex);
1433 :
1434 : // Firmware release date, day-of-month
1435 : // Range of day is 0 to 255.
1436 0 : _pg_user->day = uint8FromBytes(_pg_data, &_pg_byteindex);
1437 :
1438 : // Firmware release date, month-of-year
1439 : // Range of month is 0 to 255.
1440 0 : _pg_user->month = uint8FromBytes(_pg_data, &_pg_byteindex);
1441 :
1442 : // Firmware release date, year
1443 : // Range of year is 0 to 65535.
1444 0 : _pg_user->year = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1445 :
1446 : // Firmware checksum, 16-bit
1447 : // Range of checksum is 0 to 65535.
1448 0 : _pg_user->checksum = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1449 :
1450 0 : return 1;
1451 :
1452 : }// decodeServo_FirmwarePacketStructure
1453 :
1454 : /*!
1455 : * \brief Create the Servo_Firmware packet
1456 : *
1457 : * Servo firmware information
1458 : * \param _pg_pkt points to the packet which will be created by this function
1459 : * \param major is Firmware version, major number
1460 : * \param minor is Firmware version, minor number
1461 : * \param day is Firmware release date, day-of-month
1462 : * \param month is Firmware release date, month-of-year
1463 : * \param year is Firmware release date, year
1464 : * \param checksum is Firmware checksum, 16-bit
1465 : */
1466 0 : void encodeServo_FirmwarePacket(void* _pg_pkt, uint8_t major, uint8_t minor, uint8_t day, uint8_t month, uint16_t year, uint16_t checksum)
1467 : {
1468 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1469 0 : int _pg_byteindex = 0;
1470 :
1471 : // Firmware version, major number
1472 : // Range of major is 0 to 255.
1473 0 : uint8ToBytes(major, _pg_data, &_pg_byteindex);
1474 :
1475 : // Firmware version, minor number
1476 : // Range of minor is 0 to 255.
1477 0 : uint8ToBytes(minor, _pg_data, &_pg_byteindex);
1478 :
1479 : // Firmware release date, day-of-month
1480 : // Range of day is 0 to 255.
1481 0 : uint8ToBytes(day, _pg_data, &_pg_byteindex);
1482 :
1483 : // Firmware release date, month-of-year
1484 : // Range of month is 0 to 255.
1485 0 : uint8ToBytes(month, _pg_data, &_pg_byteindex);
1486 :
1487 : // Firmware release date, year
1488 : // Range of year is 0 to 65535.
1489 0 : uint16ToBeBytes(year, _pg_data, &_pg_byteindex);
1490 :
1491 : // Firmware checksum, 16-bit
1492 : // Range of checksum is 0 to 65535.
1493 0 : uint16ToBeBytes(checksum, _pg_data, &_pg_byteindex);
1494 :
1495 : // complete the process of creating the packet
1496 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_FirmwarePacketID());
1497 :
1498 0 : }// encodeServo_FirmwarePacket
1499 :
1500 : /*!
1501 : * \brief Decode the Servo_Firmware packet
1502 : *
1503 : * Servo firmware information
1504 : * \param _pg_pkt points to the packet being decoded by this function
1505 : * \param major receives Firmware version, major number
1506 : * \param minor receives Firmware version, minor number
1507 : * \param day receives Firmware release date, day-of-month
1508 : * \param month receives Firmware release date, month-of-year
1509 : * \param year receives Firmware release date, year
1510 : * \param checksum receives Firmware checksum, 16-bit
1511 : * \return 0 is returned if the packet ID or size is wrong, else 1
1512 : */
1513 0 : int decodeServo_FirmwarePacket(const void* _pg_pkt, uint8_t* major, uint8_t* minor, uint8_t* day, uint8_t* month, uint16_t* year, uint16_t* checksum)
1514 : {
1515 0 : int _pg_byteindex = 0;
1516 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
1517 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
1518 :
1519 : // Verify the packet identifier
1520 0 : if(getServoPacketID(_pg_pkt) != getServo_FirmwarePacketID())
1521 0 : return 0;
1522 :
1523 0 : if(_pg_numbytes < getServo_FirmwareMinDataLength())
1524 0 : return 0;
1525 :
1526 : // Firmware version, major number
1527 : // Range of major is 0 to 255.
1528 0 : (*major) = uint8FromBytes(_pg_data, &_pg_byteindex);
1529 :
1530 : // Firmware version, minor number
1531 : // Range of minor is 0 to 255.
1532 0 : (*minor) = uint8FromBytes(_pg_data, &_pg_byteindex);
1533 :
1534 : // Firmware release date, day-of-month
1535 : // Range of day is 0 to 255.
1536 0 : (*day) = uint8FromBytes(_pg_data, &_pg_byteindex);
1537 :
1538 : // Firmware release date, month-of-year
1539 : // Range of month is 0 to 255.
1540 0 : (*month) = uint8FromBytes(_pg_data, &_pg_byteindex);
1541 :
1542 : // Firmware release date, year
1543 : // Range of year is 0 to 65535.
1544 0 : (*year) = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1545 :
1546 : // Firmware checksum, 16-bit
1547 : // Range of checksum is 0 to 65535.
1548 0 : (*checksum) = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1549 :
1550 0 : return 1;
1551 :
1552 : }// decodeServo_FirmwarePacket
1553 :
1554 : /*!
1555 : * \brief Create the Servo_SystemInfo packet
1556 : *
1557 : * Servo system info (uptime, etc)
1558 : * \param _pg_pkt points to the packet which will be created by this function
1559 : * \param _pg_user points to the user data that will be encoded in _pg_pkt
1560 : */
1561 0 : void encodeServo_SystemInfoPacketStructure(void* _pg_pkt, const Servo_SystemInfo_t* _pg_user)
1562 : {
1563 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1564 0 : int _pg_byteindex = 0;
1565 :
1566 : // Time since last power cycle (milliseconds)
1567 : // Range of msSinceReset is 0 to 4294967295.
1568 0 : uint32ToBeBytes(_pg_user->msSinceReset, _pg_data, &_pg_byteindex);
1569 :
1570 : // Number of recorded power cycles
1571 : // Range of powerCycles is 0 to 65535.
1572 0 : uint16ToBeBytes(_pg_user->powerCycles, _pg_data, &_pg_byteindex);
1573 :
1574 : // Processor code indicating cause of most recent reset event
1575 : // Range of resetCode is 0 to 255.
1576 0 : uint8ToBytes(_pg_user->resetCode, _pg_data, &_pg_byteindex);
1577 :
1578 : // Range of cpuOccupancy is 0 to 255.
1579 0 : uint8ToBytes(_pg_user->cpuOccupancy, _pg_data, &_pg_byteindex);
1580 :
1581 : // complete the process of creating the packet
1582 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_SystemInfoPacketID());
1583 :
1584 0 : }// encodeServo_SystemInfoPacketStructure
1585 :
1586 : /*!
1587 : * \brief Decode the Servo_SystemInfo packet
1588 : *
1589 : * Servo system info (uptime, etc)
1590 : * \param _pg_pkt points to the packet being decoded by this function
1591 : * \param _pg_user receives the data decoded from the packet
1592 : * \return 0 is returned if the packet ID or size is wrong, else 1
1593 : */
1594 0 : int decodeServo_SystemInfoPacketStructure(const void* _pg_pkt, Servo_SystemInfo_t* _pg_user)
1595 : {
1596 : int _pg_numbytes;
1597 0 : int _pg_byteindex = 0;
1598 : const uint8_t* _pg_data;
1599 :
1600 : // Verify the packet identifier
1601 0 : if(getServoPacketID(_pg_pkt) != getServo_SystemInfoPacketID())
1602 0 : return 0;
1603 :
1604 : // Verify the packet size
1605 0 : _pg_numbytes = getServoPacketSize(_pg_pkt);
1606 0 : if(_pg_numbytes < getServo_SystemInfoMinDataLength())
1607 0 : return 0;
1608 :
1609 : // The raw data from the packet
1610 0 : _pg_data = getServoPacketDataConst(_pg_pkt);
1611 :
1612 : // Time since last power cycle (milliseconds)
1613 : // Range of msSinceReset is 0 to 4294967295.
1614 0 : _pg_user->msSinceReset = uint32FromBeBytes(_pg_data, &_pg_byteindex);
1615 :
1616 : // Number of recorded power cycles
1617 : // Range of powerCycles is 0 to 65535.
1618 0 : _pg_user->powerCycles = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1619 :
1620 : // Processor code indicating cause of most recent reset event
1621 : // Range of resetCode is 0 to 255.
1622 0 : _pg_user->resetCode = uint8FromBytes(_pg_data, &_pg_byteindex);
1623 :
1624 : // Range of cpuOccupancy is 0 to 255.
1625 0 : _pg_user->cpuOccupancy = uint8FromBytes(_pg_data, &_pg_byteindex);
1626 :
1627 0 : return 1;
1628 :
1629 : }// decodeServo_SystemInfoPacketStructure
1630 :
1631 : /*!
1632 : * \brief Create the Servo_SystemInfo packet
1633 : *
1634 : * Servo system info (uptime, etc)
1635 : * \param _pg_pkt points to the packet which will be created by this function
1636 : * \param msSinceReset is Time since last power cycle (milliseconds)
1637 : * \param powerCycles is Number of recorded power cycles
1638 : * \param resetCode is Processor code indicating cause of most recent reset event
1639 : * \param cpuOccupancy is
1640 : */
1641 0 : void encodeServo_SystemInfoPacket(void* _pg_pkt, uint32_t msSinceReset, uint16_t powerCycles, uint8_t resetCode, uint8_t cpuOccupancy)
1642 : {
1643 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1644 0 : int _pg_byteindex = 0;
1645 :
1646 : // Time since last power cycle (milliseconds)
1647 : // Range of msSinceReset is 0 to 4294967295.
1648 0 : uint32ToBeBytes(msSinceReset, _pg_data, &_pg_byteindex);
1649 :
1650 : // Number of recorded power cycles
1651 : // Range of powerCycles is 0 to 65535.
1652 0 : uint16ToBeBytes(powerCycles, _pg_data, &_pg_byteindex);
1653 :
1654 : // Processor code indicating cause of most recent reset event
1655 : // Range of resetCode is 0 to 255.
1656 0 : uint8ToBytes(resetCode, _pg_data, &_pg_byteindex);
1657 :
1658 : // Range of cpuOccupancy is 0 to 255.
1659 0 : uint8ToBytes(cpuOccupancy, _pg_data, &_pg_byteindex);
1660 :
1661 : // complete the process of creating the packet
1662 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_SystemInfoPacketID());
1663 :
1664 0 : }// encodeServo_SystemInfoPacket
1665 :
1666 : /*!
1667 : * \brief Decode the Servo_SystemInfo packet
1668 : *
1669 : * Servo system info (uptime, etc)
1670 : * \param _pg_pkt points to the packet being decoded by this function
1671 : * \param msSinceReset receives Time since last power cycle (milliseconds)
1672 : * \param powerCycles receives Number of recorded power cycles
1673 : * \param resetCode receives Processor code indicating cause of most recent reset event
1674 : * \param cpuOccupancy receives
1675 : * \return 0 is returned if the packet ID or size is wrong, else 1
1676 : */
1677 0 : int decodeServo_SystemInfoPacket(const void* _pg_pkt, uint32_t* msSinceReset, uint16_t* powerCycles, uint8_t* resetCode, uint8_t* cpuOccupancy)
1678 : {
1679 0 : int _pg_byteindex = 0;
1680 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
1681 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
1682 :
1683 : // Verify the packet identifier
1684 0 : if(getServoPacketID(_pg_pkt) != getServo_SystemInfoPacketID())
1685 0 : return 0;
1686 :
1687 0 : if(_pg_numbytes < getServo_SystemInfoMinDataLength())
1688 0 : return 0;
1689 :
1690 : // Time since last power cycle (milliseconds)
1691 : // Range of msSinceReset is 0 to 4294967295.
1692 0 : (*msSinceReset) = uint32FromBeBytes(_pg_data, &_pg_byteindex);
1693 :
1694 : // Number of recorded power cycles
1695 : // Range of powerCycles is 0 to 65535.
1696 0 : (*powerCycles) = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1697 :
1698 : // Processor code indicating cause of most recent reset event
1699 : // Range of resetCode is 0 to 255.
1700 0 : (*resetCode) = uint8FromBytes(_pg_data, &_pg_byteindex);
1701 :
1702 : // Range of cpuOccupancy is 0 to 255.
1703 0 : (*cpuOccupancy) = uint8FromBytes(_pg_data, &_pg_byteindex);
1704 :
1705 0 : return 1;
1706 :
1707 : }// decodeServo_SystemInfoPacket
1708 :
1709 : /*!
1710 : * \brief Create the Servo_TelemetryConfig packet
1711 : *
1712 : * Telemetry settings configuration packet
1713 : * \param _pg_pkt points to the packet which will be created by this function
1714 : * \param _pg_user points to the user data that will be encoded in _pg_pkt
1715 : */
1716 0 : void encodeServo_TelemetryConfigPacketStructure(void* _pg_pkt, const Servo_TelemetryConfig_t* _pg_user)
1717 : {
1718 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1719 0 : int _pg_byteindex = 0;
1720 0 : unsigned _pg_i = 0;
1721 :
1722 : // Servo telemetry settings
1723 0 : encodeServo_TelemetrySettings_t(_pg_data, &_pg_byteindex, &_pg_user->settings);
1724 :
1725 : // Reserved for future use
1726 0 : for(_pg_i = 0; _pg_i < 3; _pg_i++)
1727 0 : uint8ToBytes((uint8_t)(0), _pg_data, &_pg_byteindex);
1728 :
1729 : // Servo ICD revision
1730 0 : uint8ToBytes((uint8_t)(getServoApi()), _pg_data, &_pg_byteindex);
1731 :
1732 : // complete the process of creating the packet
1733 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_TelemetryConfigPacketID());
1734 :
1735 0 : }// encodeServo_TelemetryConfigPacketStructure
1736 :
1737 : /*!
1738 : * \brief Decode the Servo_TelemetryConfig packet
1739 : *
1740 : * Telemetry settings configuration packet
1741 : * \param _pg_pkt points to the packet being decoded by this function
1742 : * \param _pg_user receives the data decoded from the packet
1743 : * \return 0 is returned if the packet ID or size is wrong, else 1
1744 : */
1745 0 : int decodeServo_TelemetryConfigPacketStructure(const void* _pg_pkt, Servo_TelemetryConfig_t* _pg_user)
1746 : {
1747 : int _pg_numbytes;
1748 0 : int _pg_byteindex = 0;
1749 : const uint8_t* _pg_data;
1750 :
1751 : // Verify the packet identifier
1752 0 : if(getServoPacketID(_pg_pkt) != getServo_TelemetryConfigPacketID())
1753 0 : return 0;
1754 :
1755 : // Verify the packet size
1756 0 : _pg_numbytes = getServoPacketSize(_pg_pkt);
1757 0 : if(_pg_numbytes < getServo_TelemetryConfigMinDataLength())
1758 0 : return 0;
1759 :
1760 : // The raw data from the packet
1761 0 : _pg_data = getServoPacketDataConst(_pg_pkt);
1762 :
1763 : // Servo telemetry settings
1764 0 : if(decodeServo_TelemetrySettings_t(_pg_data, &_pg_byteindex, &_pg_user->settings) == 0)
1765 0 : return 0;
1766 :
1767 : // Reserved for future use
1768 0 : _pg_byteindex += 1*3;
1769 :
1770 : // Servo ICD revision
1771 : // Range of icdVersion is 0 to 255.
1772 0 : _pg_user->icdVersion = uint8FromBytes(_pg_data, &_pg_byteindex);
1773 :
1774 0 : return 1;
1775 :
1776 : }// decodeServo_TelemetryConfigPacketStructure
1777 :
1778 : /*!
1779 : * \brief Create the Servo_TelemetryConfig packet
1780 : *
1781 : * Telemetry settings configuration packet
1782 : * \param _pg_pkt points to the packet which will be created by this function
1783 : * \param settings is Servo telemetry settings
1784 : */
1785 0 : void encodeServo_TelemetryConfigPacket(void* _pg_pkt, const Servo_TelemetrySettings_t* settings)
1786 : {
1787 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1788 0 : int _pg_byteindex = 0;
1789 0 : unsigned _pg_i = 0;
1790 :
1791 : // Servo telemetry settings
1792 0 : encodeServo_TelemetrySettings_t(_pg_data, &_pg_byteindex, settings);
1793 :
1794 : // Reserved for future use
1795 0 : for(_pg_i = 0; _pg_i < 3; _pg_i++)
1796 0 : uint8ToBytes((uint8_t)(0), _pg_data, &_pg_byteindex);
1797 :
1798 : // Servo ICD revision
1799 0 : uint8ToBytes((uint8_t)(getServoApi()), _pg_data, &_pg_byteindex);
1800 :
1801 : // complete the process of creating the packet
1802 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_TelemetryConfigPacketID());
1803 :
1804 0 : }// encodeServo_TelemetryConfigPacket
1805 :
1806 : /*!
1807 : * \brief Decode the Servo_TelemetryConfig packet
1808 : *
1809 : * Telemetry settings configuration packet
1810 : * \param _pg_pkt points to the packet being decoded by this function
1811 : * \param settings receives Servo telemetry settings
1812 : * \param icdVersion receives Servo ICD revision
1813 : * \return 0 is returned if the packet ID or size is wrong, else 1
1814 : */
1815 0 : int decodeServo_TelemetryConfigPacket(const void* _pg_pkt, Servo_TelemetrySettings_t* settings, uint8_t* icdVersion)
1816 : {
1817 0 : int _pg_byteindex = 0;
1818 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
1819 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
1820 :
1821 : // Verify the packet identifier
1822 0 : if(getServoPacketID(_pg_pkt) != getServo_TelemetryConfigPacketID())
1823 0 : return 0;
1824 :
1825 0 : if(_pg_numbytes < getServo_TelemetryConfigMinDataLength())
1826 0 : return 0;
1827 :
1828 : // Servo telemetry settings
1829 0 : if(decodeServo_TelemetrySettings_t(_pg_data, &_pg_byteindex, settings) == 0)
1830 0 : return 0;
1831 :
1832 : // Reserved for future use
1833 0 : _pg_byteindex += 1*3;
1834 :
1835 : // Servo ICD revision
1836 : // Range of icdVersion is 0 to 255.
1837 0 : (*icdVersion) = uint8FromBytes(_pg_data, &_pg_byteindex);
1838 :
1839 0 : return 1;
1840 :
1841 : }// decodeServo_TelemetryConfigPacket
1842 :
1843 : /*!
1844 : * \brief Create the Servo_SettingsInfo packet
1845 : *
1846 : * Non-volatile settings configuration information
1847 : * \param _pg_pkt points to the packet which will be created by this function
1848 : * \param _pg_user points to the user data that will be encoded in _pg_pkt
1849 : */
1850 0 : void encodeServo_SettingsInfoPacketStructure(void* _pg_pkt, const Servo_SettingsInfo_t* _pg_user)
1851 : {
1852 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1853 0 : int _pg_byteindex = 0;
1854 :
1855 : // Set if the servo is unlocked and ready to receive settings updates
1856 0 : _pg_data[_pg_byteindex] = (uint8_t)_pg_user->eeUnlocked << 7;
1857 :
1858 : // Version of non-volatile settings configuration
1859 : // Range of eeVersion is 0 to 127.
1860 0 : _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->eeVersion;
1861 0 : _pg_byteindex += 1; // close bit field
1862 :
1863 :
1864 : // Size of non-volatile settings data
1865 : // Range of eeSize is 0 to 65535.
1866 0 : uint16ToBeBytes(_pg_user->eeSize, _pg_data, &_pg_byteindex);
1867 :
1868 : // NV settings checksum
1869 : // Range of eeChecksum is 0 to 65535.
1870 0 : uint16ToBeBytes(_pg_user->eeChecksum, _pg_data, &_pg_byteindex);
1871 :
1872 : // Range of mramVersion is 0 to 255.
1873 0 : uint8ToBytes(_pg_user->mramVersion, _pg_data, &_pg_byteindex);
1874 :
1875 : // Range of mramSize is 0 to 65535.
1876 0 : uint16ToBeBytes(_pg_user->mramSize, _pg_data, &_pg_byteindex);
1877 :
1878 : // complete the process of creating the packet
1879 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_SettingsInfoPacketID());
1880 :
1881 0 : }// encodeServo_SettingsInfoPacketStructure
1882 :
1883 : /*!
1884 : * \brief Decode the Servo_SettingsInfo packet
1885 : *
1886 : * Non-volatile settings configuration information
1887 : * \param _pg_pkt points to the packet being decoded by this function
1888 : * \param _pg_user receives the data decoded from the packet
1889 : * \return 0 is returned if the packet ID or size is wrong, else 1
1890 : */
1891 0 : int decodeServo_SettingsInfoPacketStructure(const void* _pg_pkt, Servo_SettingsInfo_t* _pg_user)
1892 : {
1893 : int _pg_numbytes;
1894 0 : int _pg_byteindex = 0;
1895 : const uint8_t* _pg_data;
1896 :
1897 : // Verify the packet identifier
1898 0 : if(getServoPacketID(_pg_pkt) != getServo_SettingsInfoPacketID())
1899 0 : return 0;
1900 :
1901 : // Verify the packet size
1902 0 : _pg_numbytes = getServoPacketSize(_pg_pkt);
1903 0 : if(_pg_numbytes < getServo_SettingsInfoMinDataLength())
1904 0 : return 0;
1905 :
1906 : // The raw data from the packet
1907 0 : _pg_data = getServoPacketDataConst(_pg_pkt);
1908 :
1909 : // Set if the servo is unlocked and ready to receive settings updates
1910 0 : _pg_user->eeUnlocked = (_pg_data[_pg_byteindex] >> 7);
1911 :
1912 : // Version of non-volatile settings configuration
1913 : // Range of eeVersion is 0 to 127.
1914 0 : _pg_user->eeVersion = ((_pg_data[_pg_byteindex]) & 0x7F);
1915 0 : _pg_byteindex += 1; // close bit field
1916 :
1917 : // Size of non-volatile settings data
1918 : // Range of eeSize is 0 to 65535.
1919 0 : _pg_user->eeSize = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1920 :
1921 : // NV settings checksum
1922 : // Range of eeChecksum is 0 to 65535.
1923 0 : _pg_user->eeChecksum = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1924 :
1925 : // Range of mramVersion is 0 to 255.
1926 0 : _pg_user->mramVersion = uint8FromBytes(_pg_data, &_pg_byteindex);
1927 :
1928 : // Range of mramSize is 0 to 65535.
1929 0 : _pg_user->mramSize = uint16FromBeBytes(_pg_data, &_pg_byteindex);
1930 :
1931 0 : return 1;
1932 :
1933 : }// decodeServo_SettingsInfoPacketStructure
1934 :
1935 : /*!
1936 : * \brief Create the Servo_SettingsInfo packet
1937 : *
1938 : * Non-volatile settings configuration information
1939 : * \param _pg_pkt points to the packet which will be created by this function
1940 : * \param eeUnlocked is Set if the servo is unlocked and ready to receive settings updates
1941 : * \param eeVersion is Version of non-volatile settings configuration
1942 : * \param eeSize is Size of non-volatile settings data
1943 : * \param eeChecksum is NV settings checksum
1944 : * \param mramVersion is
1945 : * \param mramSize is
1946 : */
1947 0 : void encodeServo_SettingsInfoPacket(void* _pg_pkt, unsigned eeUnlocked, unsigned eeVersion, uint16_t eeSize, uint16_t eeChecksum, uint8_t mramVersion, uint16_t mramSize)
1948 : {
1949 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
1950 0 : int _pg_byteindex = 0;
1951 :
1952 : // Set if the servo is unlocked and ready to receive settings updates
1953 0 : _pg_data[_pg_byteindex] = (uint8_t)eeUnlocked << 7;
1954 :
1955 : // Version of non-volatile settings configuration
1956 : // Range of eeVersion is 0 to 127.
1957 0 : _pg_data[_pg_byteindex] |= (uint8_t)eeVersion;
1958 0 : _pg_byteindex += 1; // close bit field
1959 :
1960 : // Size of non-volatile settings data
1961 : // Range of eeSize is 0 to 65535.
1962 0 : uint16ToBeBytes(eeSize, _pg_data, &_pg_byteindex);
1963 :
1964 : // NV settings checksum
1965 : // Range of eeChecksum is 0 to 65535.
1966 0 : uint16ToBeBytes(eeChecksum, _pg_data, &_pg_byteindex);
1967 :
1968 : // Range of mramVersion is 0 to 255.
1969 0 : uint8ToBytes(mramVersion, _pg_data, &_pg_byteindex);
1970 :
1971 : // Range of mramSize is 0 to 65535.
1972 0 : uint16ToBeBytes(mramSize, _pg_data, &_pg_byteindex);
1973 :
1974 : // complete the process of creating the packet
1975 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_SettingsInfoPacketID());
1976 :
1977 0 : }// encodeServo_SettingsInfoPacket
1978 :
1979 : /*!
1980 : * \brief Decode the Servo_SettingsInfo packet
1981 : *
1982 : * Non-volatile settings configuration information
1983 : * \param _pg_pkt points to the packet being decoded by this function
1984 : * \param eeUnlocked receives Set if the servo is unlocked and ready to receive settings updates
1985 : * \param eeVersion receives Version of non-volatile settings configuration
1986 : * \param eeSize receives Size of non-volatile settings data
1987 : * \param eeChecksum receives NV settings checksum
1988 : * \param mramVersion receives
1989 : * \param mramSize receives
1990 : * \return 0 is returned if the packet ID or size is wrong, else 1
1991 : */
1992 0 : int decodeServo_SettingsInfoPacket(const void* _pg_pkt, unsigned* eeUnlocked, unsigned* eeVersion, uint16_t* eeSize, uint16_t* eeChecksum, uint8_t* mramVersion, uint16_t* mramSize)
1993 : {
1994 0 : int _pg_byteindex = 0;
1995 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
1996 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
1997 :
1998 : // Verify the packet identifier
1999 0 : if(getServoPacketID(_pg_pkt) != getServo_SettingsInfoPacketID())
2000 0 : return 0;
2001 :
2002 0 : if(_pg_numbytes < getServo_SettingsInfoMinDataLength())
2003 0 : return 0;
2004 :
2005 : // Set if the servo is unlocked and ready to receive settings updates
2006 0 : (*eeUnlocked) = (_pg_data[_pg_byteindex] >> 7);
2007 :
2008 : // Version of non-volatile settings configuration
2009 : // Range of eeVersion is 0 to 127.
2010 0 : (*eeVersion) = ((_pg_data[_pg_byteindex]) & 0x7F);
2011 0 : _pg_byteindex += 1; // close bit field
2012 :
2013 : // Size of non-volatile settings data
2014 : // Range of eeSize is 0 to 65535.
2015 0 : (*eeSize) = uint16FromBeBytes(_pg_data, &_pg_byteindex);
2016 :
2017 : // NV settings checksum
2018 : // Range of eeChecksum is 0 to 65535.
2019 0 : (*eeChecksum) = uint16FromBeBytes(_pg_data, &_pg_byteindex);
2020 :
2021 : // Range of mramVersion is 0 to 255.
2022 0 : (*mramVersion) = uint8FromBytes(_pg_data, &_pg_byteindex);
2023 :
2024 : // Range of mramSize is 0 to 65535.
2025 0 : (*mramSize) = uint16FromBeBytes(_pg_data, &_pg_byteindex);
2026 :
2027 0 : return 1;
2028 :
2029 : }// decodeServo_SettingsInfoPacket
2030 :
2031 : /*!
2032 : * \brief Create the Servo_TelltaleA packet
2033 : *
2034 : * Servo telltale data
2035 : * \param _pg_pkt points to the packet which will be created by this function
2036 : * \param minTemperature is Minimum temperature seen by the servo
2037 : * \param maxTemperature is Maximum temperature seen by the servo
2038 : */
2039 0 : void encodeServo_TelltaleAPacket(void* _pg_pkt, int8_t minTemperature, int8_t maxTemperature)
2040 : {
2041 0 : uint8_t* _pg_data = getServoPacketData(_pg_pkt);
2042 0 : int _pg_byteindex = 0;
2043 :
2044 : // Minimum temperature seen by the servo
2045 : // Range of minTemperature is -128 to 127.
2046 0 : int8ToBytes(minTemperature, _pg_data, &_pg_byteindex);
2047 :
2048 : // Maximum temperature seen by the servo
2049 : // Range of maxTemperature is -128 to 127.
2050 0 : int8ToBytes(maxTemperature, _pg_data, &_pg_byteindex);
2051 :
2052 : // complete the process of creating the packet
2053 0 : finishServoPacket(_pg_pkt, _pg_byteindex, getServo_TelltaleAPacketID());
2054 :
2055 0 : }// encodeServo_TelltaleAPacket
2056 :
2057 : /*!
2058 : * \brief Decode the Servo_TelltaleA packet
2059 : *
2060 : * Servo telltale data
2061 : * \param _pg_pkt points to the packet being decoded by this function
2062 : * \param minTemperature receives Minimum temperature seen by the servo
2063 : * \param maxTemperature receives Maximum temperature seen by the servo
2064 : * \return 0 is returned if the packet ID or size is wrong, else 1
2065 : */
2066 0 : int decodeServo_TelltaleAPacket(const void* _pg_pkt, int8_t* minTemperature, int8_t* maxTemperature)
2067 : {
2068 0 : int _pg_byteindex = 0;
2069 0 : const uint8_t* _pg_data = getServoPacketDataConst(_pg_pkt);
2070 0 : int _pg_numbytes = getServoPacketSize(_pg_pkt);
2071 :
2072 : // Verify the packet identifier
2073 0 : if(getServoPacketID(_pg_pkt) != getServo_TelltaleAPacketID())
2074 0 : return 0;
2075 :
2076 0 : if(_pg_numbytes < getServo_TelltaleAMinDataLength())
2077 0 : return 0;
2078 :
2079 : // Minimum temperature seen by the servo
2080 : // Range of minTemperature is -128 to 127.
2081 0 : (*minTemperature) = int8FromBytes(_pg_data, &_pg_byteindex);
2082 :
2083 : // Maximum temperature seen by the servo
2084 : // Range of maxTemperature is -128 to 127.
2085 0 : (*maxTemperature) = int8FromBytes(_pg_data, &_pg_byteindex);
2086 :
2087 0 : return 1;
2088 :
2089 : }// decodeServo_TelltaleAPacket
2090 : // end of ServoPackets.c
|