gusimplewhiteboard
wb_sensors_body_sensors.c
Go to the documentation of this file.
1/*
2 * file wb_sensors_body_sensors.c
3 *
4 * This file was generated by classgenerator from sensors_body_sensors.gen.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Carl Lusty. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials
19 * provided with the distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgement:
23 *
24 * This product includes software developed by Carl Lusty.
25 *
26 * 4. Neither the name of the author nor the names of contributors
27 * may be used to endorse or promote products derived from this
28 * software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
34 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
37 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
38 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
39 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 * -----------------------------------------------------------------------
43 * This program is free software; you can redistribute it and/or
44 * modify it under the above terms or under the terms of the GNU
45 * General Public License as published by the Free Software Foundation;
46 * either version 2 of the License, or (at your option) any later version.
47 *
48 * This program is distributed in the hope that it will be useful,
49 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51 * GNU General Public License for more details.
52 *
53 * You should have received a copy of the GNU General Public License
54 * along with this program; if not, see http://www.gnu.org/licenses/
55 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
56 * Fifth Floor, Boston, MA 02110-1301, USA.
57 *
58 */
59
60#ifndef WHITEBOARD_POSTER_STRING_CONVERSION
61#define WHITEBOARD_POSTER_STRING_CONVERSION
62#endif // WHITEBOARD_POSTER_STRING_CONVERSION
63
65#include <stdio.h>
66#include <string.h>
67#include <stdlib.h>
68#include <ctype.h>
69#include <limits.h>
70
71/* Network byte order functions */
72#pragma clang diagnostic push
73#pragma clang diagnostic ignored "-Wunused-macros"
74#if defined(__linux)
75# include <endian.h>
76# include <byteswap.h>
77#elif defined(__APPLE__)
78# include <machine/endian.h> //Needed for __BYTE_ORDER
79# include <architecture/byte_order.h> //Needed for byte swap functions
80# define bswap_16(x) NXSwapShort(x)
81# define bswap_32(x) NXSwapInt(x)
82# define bswap_64(x) NXSwapLongLong(x)
83#elif defined(ESP8266)
84# define bswap_16(x) __builtin_bswap16(x)
85# define bswap_32(x) __builtin_bswap32(x)
86# define bswap_64(x) __builtin_bswap64(x)
87#else
88 //Manually define swap macros?
89#endif
90
91#if (!defined(__BYTE_ORDER) && !defined(__LITTLE_ENDIAN)) || (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN)
92# if !defined(htonll) && !defined(ntohll)
93# define htonll(x) bswap_64(x)
94# define ntohll(x) bswap_64(x)
95# endif
96# if !defined(htonl) && !defined(ntohl)
97# define htonl(x) bswap_32(x)
98# define ntohl(x) bswap_32(x)
99# endif
100# if !defined(htons) && !defined(ntohs)
101# define htons(x) bswap_16(x)
102# define ntohs(x) bswap_16(x)
103# endif
104#else
105# if !defined(htonll) && !defined(ntohll)
106# define htonll(x) (x)
107# define ntohll(x) (x)
108# endif
109# if !defined(htonl) && !defined(ntohl)
110# define htonl(x) (x)
111# define ntohl(x) (x)
112# endif
113# if !defined(htons) && !defined(ntohs)
114# define htons(x) (x)
115# define ntohs(x) (x)
116# endif
117#endif
118#pragma clang diagnostic pop
119
120
121
125const char* wb_sensors_body_sensors_description(const struct wb_sensors_body_sensors* self, char* descString, size_t bufferSize)
126{
127#pragma clang diagnostic push
128#pragma clang diagnostic ignored "-Wunused-variable"
129 size_t len = 0;
130 if (len >= bufferSize) {
131 return descString;
132 }
133 len += snprintf(descString + len, bufferSize - len, "DCM_Time=%d", self->DCM_Time);
134 if (len >= bufferSize) {
135 return descString;
136 }
137 len = gu_strlcat(descString, ", ", bufferSize);
138 if (len >= bufferSize) {
139 return descString;
140 }
141 len += snprintf(descString + len, bufferSize - len, "InertialSensor_AccX=%lf", (double) self->InertialSensor_AccX);
142 if (len >= bufferSize) {
143 return descString;
144 }
145 len = gu_strlcat(descString, ", ", bufferSize);
146 if (len >= bufferSize) {
147 return descString;
148 }
149 len += snprintf(descString + len, bufferSize - len, "InertialSensor_AccY=%lf", (double) self->InertialSensor_AccY);
150 if (len >= bufferSize) {
151 return descString;
152 }
153 len = gu_strlcat(descString, ", ", bufferSize);
154 if (len >= bufferSize) {
155 return descString;
156 }
157 len += snprintf(descString + len, bufferSize - len, "InertialSensor_AccZ=%lf", (double) self->InertialSensor_AccZ);
158 if (len >= bufferSize) {
159 return descString;
160 }
161 len = gu_strlcat(descString, ", ", bufferSize);
162 if (len >= bufferSize) {
163 return descString;
164 }
165 len += snprintf(descString + len, bufferSize - len, "InertialSensor_GyrX=%lf", (double) self->InertialSensor_GyrX);
166 if (len >= bufferSize) {
167 return descString;
168 }
169 len = gu_strlcat(descString, ", ", bufferSize);
170 if (len >= bufferSize) {
171 return descString;
172 }
173 len += snprintf(descString + len, bufferSize - len, "InertialSensor_GyrY=%lf", (double) self->InertialSensor_GyrY);
174 if (len >= bufferSize) {
175 return descString;
176 }
177 len = gu_strlcat(descString, ", ", bufferSize);
178 if (len >= bufferSize) {
179 return descString;
180 }
181 len += snprintf(descString + len, bufferSize - len, "InertialSensor_GyrZ=%lf", (double) self->InertialSensor_GyrZ);
182 if (len >= bufferSize) {
183 return descString;
184 }
185 len = gu_strlcat(descString, ", ", bufferSize);
186 if (len >= bufferSize) {
187 return descString;
188 }
189 len += snprintf(descString + len, bufferSize - len, "InertialSensor_AngleX=%lf", (double) self->InertialSensor_AngleX);
190 if (len >= bufferSize) {
191 return descString;
192 }
193 len = gu_strlcat(descString, ", ", bufferSize);
194 if (len >= bufferSize) {
195 return descString;
196 }
197 len += snprintf(descString + len, bufferSize - len, "InertialSensor_AngleY=%lf", (double) self->InertialSensor_AngleY);
198 if (len >= bufferSize) {
199 return descString;
200 }
201 len = gu_strlcat(descString, ", ", bufferSize);
202 if (len >= bufferSize) {
203 return descString;
204 }
205 len += snprintf(descString + len, bufferSize - len, "InertialSensor_AngleZ=%lf", (double) self->InertialSensor_AngleZ);
206 if (len >= bufferSize) {
207 return descString;
208 }
209 len = gu_strlcat(descString, ", ", bufferSize);
210 if (len >= bufferSize) {
211 return descString;
212 }
213 len += snprintf(descString + len, bufferSize - len, "InertialSensor_AccelerometerX=%lf", (double) self->InertialSensor_AccelerometerX);
214 if (len >= bufferSize) {
215 return descString;
216 }
217 len = gu_strlcat(descString, ", ", bufferSize);
218 if (len >= bufferSize) {
219 return descString;
220 }
221 len += snprintf(descString + len, bufferSize - len, "InertialSensor_AccelerometerY=%lf", (double) self->InertialSensor_AccelerometerY);
222 if (len >= bufferSize) {
223 return descString;
224 }
225 len = gu_strlcat(descString, ", ", bufferSize);
226 if (len >= bufferSize) {
227 return descString;
228 }
229 len += snprintf(descString + len, bufferSize - len, "InertialSensor_AccelerometerZ=%lf", (double) self->InertialSensor_AccelerometerZ);
230 if (len >= bufferSize) {
231 return descString;
232 }
233 len = gu_strlcat(descString, ", ", bufferSize);
234 if (len >= bufferSize) {
235 return descString;
236 }
237 len += snprintf(descString + len, bufferSize - len, "InertialSensor_GyroscopeX=%lf", (double) self->InertialSensor_GyroscopeX);
238 if (len >= bufferSize) {
239 return descString;
240 }
241 len = gu_strlcat(descString, ", ", bufferSize);
242 if (len >= bufferSize) {
243 return descString;
244 }
245 len += snprintf(descString + len, bufferSize - len, "InertialSensor_GyroscopeY=%lf", (double) self->InertialSensor_GyroscopeY);
246 if (len >= bufferSize) {
247 return descString;
248 }
249 len = gu_strlcat(descString, ", ", bufferSize);
250 if (len >= bufferSize) {
251 return descString;
252 }
253 len += snprintf(descString + len, bufferSize - len, "InertialSensor_GyroscopeZ=%lf", (double) self->InertialSensor_GyroscopeZ);
254 if (len >= bufferSize) {
255 return descString;
256 }
257 len = gu_strlcat(descString, ", ", bufferSize);
258 if (len >= bufferSize) {
259 return descString;
260 }
261 len += snprintf(descString + len, bufferSize - len, "Battery_Charge=%u", self->Battery_Charge);
262 if (len >= bufferSize) {
263 return descString;
264 }
265 len = gu_strlcat(descString, ", ", bufferSize);
266 if (len >= bufferSize) {
267 return descString;
268 }
269 len += snprintf(descString + len, bufferSize - len, "Battery_Current=%u", self->Battery_Current);
270 if (len >= bufferSize) {
271 return descString;
272 }
273 len = gu_strlcat(descString, ", ", bufferSize);
274 if (len >= bufferSize) {
275 return descString;
276 }
277 len += snprintf(descString + len, bufferSize - len, "US=%lf", (double) self->US);
278 if (len >= bufferSize) {
279 return descString;
280 }
281 len = gu_strlcat(descString, ", ", bufferSize);
282 if (len >= bufferSize) {
283 return descString;
284 }
285 len = gu_strlcat(descString, self->ChestBoard_Button ? "ChestBoard_Button=true" : "ChestBoard_Button=false", bufferSize);
286 return descString;
287#pragma clang diagnostic pop
288}
289
293const char* wb_sensors_body_sensors_to_string(const struct wb_sensors_body_sensors* self, char* toString, size_t bufferSize)
294{
295#pragma clang diagnostic push
296#pragma clang diagnostic ignored "-Wunused-variable"
297 size_t len = 0;
298 if (len >= bufferSize) {
299 return toString;
300 }
301 len += snprintf(toString + len, bufferSize - len, "%d", self->DCM_Time);
302 if (len >= bufferSize) {
303 return toString;
304 }
305 len = gu_strlcat(toString, ", ", bufferSize);
306 if (len >= bufferSize) {
307 return toString;
308 }
309 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_AccX);
310 if (len >= bufferSize) {
311 return toString;
312 }
313 len = gu_strlcat(toString, ", ", bufferSize);
314 if (len >= bufferSize) {
315 return toString;
316 }
317 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_AccY);
318 if (len >= bufferSize) {
319 return toString;
320 }
321 len = gu_strlcat(toString, ", ", bufferSize);
322 if (len >= bufferSize) {
323 return toString;
324 }
325 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_AccZ);
326 if (len >= bufferSize) {
327 return toString;
328 }
329 len = gu_strlcat(toString, ", ", bufferSize);
330 if (len >= bufferSize) {
331 return toString;
332 }
333 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_GyrX);
334 if (len >= bufferSize) {
335 return toString;
336 }
337 len = gu_strlcat(toString, ", ", bufferSize);
338 if (len >= bufferSize) {
339 return toString;
340 }
341 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_GyrY);
342 if (len >= bufferSize) {
343 return toString;
344 }
345 len = gu_strlcat(toString, ", ", bufferSize);
346 if (len >= bufferSize) {
347 return toString;
348 }
349 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_GyrZ);
350 if (len >= bufferSize) {
351 return toString;
352 }
353 len = gu_strlcat(toString, ", ", bufferSize);
354 if (len >= bufferSize) {
355 return toString;
356 }
357 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_AngleX);
358 if (len >= bufferSize) {
359 return toString;
360 }
361 len = gu_strlcat(toString, ", ", bufferSize);
362 if (len >= bufferSize) {
363 return toString;
364 }
365 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_AngleY);
366 if (len >= bufferSize) {
367 return toString;
368 }
369 len = gu_strlcat(toString, ", ", bufferSize);
370 if (len >= bufferSize) {
371 return toString;
372 }
373 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_AngleZ);
374 if (len >= bufferSize) {
375 return toString;
376 }
377 len = gu_strlcat(toString, ", ", bufferSize);
378 if (len >= bufferSize) {
379 return toString;
380 }
381 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_AccelerometerX);
382 if (len >= bufferSize) {
383 return toString;
384 }
385 len = gu_strlcat(toString, ", ", bufferSize);
386 if (len >= bufferSize) {
387 return toString;
388 }
389 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_AccelerometerY);
390 if (len >= bufferSize) {
391 return toString;
392 }
393 len = gu_strlcat(toString, ", ", bufferSize);
394 if (len >= bufferSize) {
395 return toString;
396 }
397 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_AccelerometerZ);
398 if (len >= bufferSize) {
399 return toString;
400 }
401 len = gu_strlcat(toString, ", ", bufferSize);
402 if (len >= bufferSize) {
403 return toString;
404 }
405 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_GyroscopeX);
406 if (len >= bufferSize) {
407 return toString;
408 }
409 len = gu_strlcat(toString, ", ", bufferSize);
410 if (len >= bufferSize) {
411 return toString;
412 }
413 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_GyroscopeY);
414 if (len >= bufferSize) {
415 return toString;
416 }
417 len = gu_strlcat(toString, ", ", bufferSize);
418 if (len >= bufferSize) {
419 return toString;
420 }
421 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->InertialSensor_GyroscopeZ);
422 if (len >= bufferSize) {
423 return toString;
424 }
425 len = gu_strlcat(toString, ", ", bufferSize);
426 if (len >= bufferSize) {
427 return toString;
428 }
429 len += snprintf(toString + len, bufferSize - len, "%u", self->Battery_Charge);
430 if (len >= bufferSize) {
431 return toString;
432 }
433 len = gu_strlcat(toString, ", ", bufferSize);
434 if (len >= bufferSize) {
435 return toString;
436 }
437 len += snprintf(toString + len, bufferSize - len, "%u", self->Battery_Current);
438 if (len >= bufferSize) {
439 return toString;
440 }
441 len = gu_strlcat(toString, ", ", bufferSize);
442 if (len >= bufferSize) {
443 return toString;
444 }
445 len += snprintf(toString + len, bufferSize - len, "%lf", (double) self->US);
446 if (len >= bufferSize) {
447 return toString;
448 }
449 len = gu_strlcat(toString, ", ", bufferSize);
450 if (len >= bufferSize) {
451 return toString;
452 }
453 len = gu_strlcat(toString, self->ChestBoard_Button ? "true" : "false", bufferSize);
454 return toString;
455#pragma clang diagnostic pop
456}
457
462{
463 size_t temp_length = strlen(str);
464 int length = (temp_length <= INT_MAX) ? ((int)((ssize_t)temp_length)) : -1;
465 if (length < 1 || length > SENSORS_BODY_SENSORS_DESC_BUFFER_SIZE) {
466 return self;
467 }
468 char var_str_buffer[SENSORS_BODY_SENSORS_DESC_BUFFER_SIZE + 1];
469 char* var_str = &var_str_buffer[0];
470 char key_buffer[30];
471 char* key = &key_buffer[0];
472 int bracecount = 0;
473 int startVar = 0;
474 int index = 0;
475 int startKey = 0;
476 int endKey = -1;
477 int varIndex = 0;
478 if (index == 0 && str[0] == '{') {
479 index = 1;
480 }
481 startVar = index;
482 startKey = startVar;
483 do {
484 for (int i = index; i < length; i++) {
485 index = i + 1;
486 if (bracecount == 0 && str[i] == '=') {
487 endKey = i - 1;
488 startVar = index;
489 continue;
490 }
491 if (bracecount == 0 && isspace(str[i])) {
492 startVar = index;
493 if (endKey == -1) {
494 startKey = index;
495 }
496 continue;
497 }
498 if (bracecount == 0 && str[i] == ',') {
499 index = i - 1;
500 break;
501 }
502 if (str[i] == '{') {
503 bracecount++;
504 continue;
505 }
506 if (str[i] == '}') {
507 bracecount--;
508 if (bracecount < 0) {
509 index = i - 1;
510 break;
511 }
512 }
513 if (i == length - 1) {
514 index = i;
515 }
516 }
517 if (endKey >= startKey && endKey - startKey < length) {
518 strncpy(key, str + startKey, ((size_t)(endKey - startKey) + 1));
519 key[(endKey - startKey) + 1] = 0;
520 } else {
521 key[0] = 0;
522 }
523 strncpy(var_str, str + startVar, ((size_t)(index - startVar) + 1));
524 var_str[(index - startVar) + 1] = 0;
525 bracecount = 0;
526 index += 2;
527 startVar = index;
528 startKey = startVar;
529 endKey = -1;
530 if (strlen(key) > 0) {
531 if (0 == strcmp("DCM_Time", key)) {
532 varIndex = 0;
533 } else if (0 == strcmp("InertialSensor_AccX", key)) {
534 varIndex = 1;
535 } else if (0 == strcmp("InertialSensor_AccY", key)) {
536 varIndex = 2;
537 } else if (0 == strcmp("InertialSensor_AccZ", key)) {
538 varIndex = 3;
539 } else if (0 == strcmp("InertialSensor_GyrX", key)) {
540 varIndex = 4;
541 } else if (0 == strcmp("InertialSensor_GyrY", key)) {
542 varIndex = 5;
543 } else if (0 == strcmp("InertialSensor_GyrZ", key)) {
544 varIndex = 6;
545 } else if (0 == strcmp("InertialSensor_AngleX", key)) {
546 varIndex = 7;
547 } else if (0 == strcmp("InertialSensor_AngleY", key)) {
548 varIndex = 8;
549 } else if (0 == strcmp("InertialSensor_AngleZ", key)) {
550 varIndex = 9;
551 } else if (0 == strcmp("InertialSensor_AccelerometerX", key)) {
552 varIndex = 10;
553 } else if (0 == strcmp("InertialSensor_AccelerometerY", key)) {
554 varIndex = 11;
555 } else if (0 == strcmp("InertialSensor_AccelerometerZ", key)) {
556 varIndex = 12;
557 } else if (0 == strcmp("InertialSensor_GyroscopeX", key)) {
558 varIndex = 13;
559 } else if (0 == strcmp("InertialSensor_GyroscopeY", key)) {
560 varIndex = 14;
561 } else if (0 == strcmp("InertialSensor_GyroscopeZ", key)) {
562 varIndex = 15;
563 } else if (0 == strcmp("Battery_Charge", key)) {
564 varIndex = 16;
565 } else if (0 == strcmp("Battery_Current", key)) {
566 varIndex = 17;
567 } else if (0 == strcmp("US", key)) {
568 varIndex = 18;
569 } else if (0 == strcmp("ChestBoard_Button", key)) {
570 varIndex = 19;
571 } else {
572 varIndex = -1;
573 }
574 }
575 switch (varIndex) {
576 case -1: { break; }
577 case 0:
578 {
579 self->DCM_Time = ((signed int)atoi(var_str));
580 break;
581 }
582 case 1:
583 {
584 self->InertialSensor_AccX = ((float)atof(var_str));
585 break;
586 }
587 case 2:
588 {
589 self->InertialSensor_AccY = ((float)atof(var_str));
590 break;
591 }
592 case 3:
593 {
594 self->InertialSensor_AccZ = ((float)atof(var_str));
595 break;
596 }
597 case 4:
598 {
599 self->InertialSensor_GyrX = ((float)atof(var_str));
600 break;
601 }
602 case 5:
603 {
604 self->InertialSensor_GyrY = ((float)atof(var_str));
605 break;
606 }
607 case 6:
608 {
609 self->InertialSensor_GyrZ = ((float)atof(var_str));
610 break;
611 }
612 case 7:
613 {
614 self->InertialSensor_AngleX = ((float)atof(var_str));
615 break;
616 }
617 case 8:
618 {
619 self->InertialSensor_AngleY = ((float)atof(var_str));
620 break;
621 }
622 case 9:
623 {
624 self->InertialSensor_AngleZ = ((float)atof(var_str));
625 break;
626 }
627 case 10:
628 {
629 self->InertialSensor_AccelerometerX = ((float)atof(var_str));
630 break;
631 }
632 case 11:
633 {
634 self->InertialSensor_AccelerometerY = ((float)atof(var_str));
635 break;
636 }
637 case 12:
638 {
639 self->InertialSensor_AccelerometerZ = ((float)atof(var_str));
640 break;
641 }
642 case 13:
643 {
644 self->InertialSensor_GyroscopeX = ((float)atof(var_str));
645 break;
646 }
647 case 14:
648 {
649 self->InertialSensor_GyroscopeY = ((float)atof(var_str));
650 break;
651 }
652 case 15:
653 {
654 self->InertialSensor_GyroscopeZ = ((float)atof(var_str));
655 break;
656 }
657 case 16:
658 {
659 self->Battery_Charge = ((uint8_t)atoi(var_str));
660 break;
661 }
662 case 17:
663 {
664 self->Battery_Current = ((uint8_t)atoi(var_str));
665 break;
666 }
667 case 18:
668 {
669 self->US = ((float)atof(var_str));
670 break;
671 }
672 case 19:
673 {
674 self->ChestBoard_Button = strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0;
675 break;
676 }
677 }
678 if (varIndex >= 0) {
679 varIndex++;
680 }
681 } while(index < length);
682 return self;
683}
684
685/*#ifdef WHITEBOARD_SERIALISATION*/
686
691{
692 uint16_t bit_offset = 0;
693 signed int DCM_Time_nbo = htonl(self->DCM_Time);
694 do {
695 int8_t b;
696 for (b = (32 - 1); b >= 0; b--) {
697 do {
698 uint16_t byte = bit_offset / 8;
699 uint16_t bit = 7 - (bit_offset % 8);
700 unsigned long newbit = !!((DCM_Time_nbo >> b) & 1U);
701 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
702 bit_offset = bit_offset + 1;
703 } while(false);
704 }
705 } while(false);
706
707 //The class generator does not support float types for network conversion.
708
709 //The class generator does not support float types for network conversion.
710
711 //The class generator does not support float types for network conversion.
712
713 //The class generator does not support float types for network conversion.
714
715 //The class generator does not support float types for network conversion.
716
717 //The class generator does not support float types for network conversion.
718
719 //The class generator does not support float types for network conversion.
720
721 //The class generator does not support float types for network conversion.
722
723 //The class generator does not support float types for network conversion.
724
725 //The class generator does not support float types for network conversion.
726
727 //The class generator does not support float types for network conversion.
728
729 //The class generator does not support float types for network conversion.
730
731 //The class generator does not support float types for network conversion.
732
733 //The class generator does not support float types for network conversion.
734
735 //The class generator does not support float types for network conversion.
736
737 uint8_t Battery_Charge_nbo = (self->Battery_Charge);
738 do {
739 int8_t b;
740 for (b = (8 - 1); b >= 0; b--) {
741 do {
742 uint16_t byte = bit_offset / 8;
743 uint16_t bit = 7 - (bit_offset % 8);
744 unsigned long newbit = !!((Battery_Charge_nbo >> b) & 1U);
745 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
746 bit_offset = bit_offset + 1;
747 } while(false);
748 }
749 } while(false);
750
751 uint8_t Battery_Current_nbo = (self->Battery_Current);
752 do {
753 int8_t b;
754 for (b = (8 - 1); b >= 0; b--) {
755 do {
756 uint16_t byte = bit_offset / 8;
757 uint16_t bit = 7 - (bit_offset % 8);
758 unsigned long newbit = !!((Battery_Current_nbo >> b) & 1U);
759 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
760 bit_offset = bit_offset + 1;
761 } while(false);
762 }
763 } while(false);
764
765 //The class generator does not support float types for network conversion.
766
767 do {
768 uint16_t byte = bit_offset / 8;
769 uint16_t bit = 7 - (bit_offset % 8);
770 unsigned long newbit = !!(self->ChestBoard_Button ? 1U : 0U);
771 dst[byte] ^= (-newbit ^ dst[byte]) & (1UL << bit);
772 bit_offset = bit_offset + 1;
773 } while(false);
774 //avoid unused variable warnings when you try to use an empty gen file or a gen file with no supported serialisation types.
775 (void)self;
776 (void)dst;
777 return bit_offset;
778}
779
784{
785 uint16_t bit_offset = 0;
786 do {
787 int8_t b;
788 for (b = (32 - 1); b >= 0; b--) {
789 do {
790 uint16_t byte = bit_offset / 8;
791 uint16_t bit = 7 - (bit_offset % 8);
792 char dataByte = src[byte];
793 unsigned char bitValue = (dataByte >> bit) & 1U;
794 dst->DCM_Time ^= (-bitValue ^ dst->DCM_Time) & (1UL << b);
795 bit_offset = bit_offset + 1;
796 } while(false);
797 }
798 } while(false);
799 dst->DCM_Time = ntohl(dst->DCM_Time);
800
801 //The class generator does not support float types for network conversion.
802
803 //The class generator does not support float types for network conversion.
804
805 //The class generator does not support float types for network conversion.
806
807 //The class generator does not support float types for network conversion.
808
809 //The class generator does not support float types for network conversion.
810
811 //The class generator does not support float types for network conversion.
812
813 //The class generator does not support float types for network conversion.
814
815 //The class generator does not support float types for network conversion.
816
817 //The class generator does not support float types for network conversion.
818
819 //The class generator does not support float types for network conversion.
820
821 //The class generator does not support float types for network conversion.
822
823 //The class generator does not support float types for network conversion.
824
825 //The class generator does not support float types for network conversion.
826
827 //The class generator does not support float types for network conversion.
828
829 //The class generator does not support float types for network conversion.
830
831 do {
832 int8_t b;
833 for (b = (8 - 1); b >= 0; b--) {
834 do {
835 uint16_t byte = bit_offset / 8;
836 uint16_t bit = 7 - (bit_offset % 8);
837 char dataByte = src[byte];
838 unsigned char bitValue = (dataByte >> bit) & 1U;
839 dst->Battery_Charge ^= (-bitValue ^ dst->Battery_Charge) & (1UL << b);
840 bit_offset = bit_offset + 1;
841 } while(false);
842 }
843 } while(false);
844 dst->Battery_Charge = (dst->Battery_Charge);
845
846 do {
847 int8_t b;
848 for (b = (8 - 1); b >= 0; b--) {
849 do {
850 uint16_t byte = bit_offset / 8;
851 uint16_t bit = 7 - (bit_offset % 8);
852 char dataByte = src[byte];
853 unsigned char bitValue = (dataByte >> bit) & 1U;
854 dst->Battery_Current ^= (-bitValue ^ dst->Battery_Current) & (1UL << b);
855 bit_offset = bit_offset + 1;
856 } while(false);
857 }
858 } while(false);
859 dst->Battery_Current = (dst->Battery_Current);
860
861 //The class generator does not support float types for network conversion.
862
863 do {
864 uint16_t byte = bit_offset / 8;
865 uint16_t bit = 7 - (bit_offset % 8);
866 char dataByte = src[byte];
867 unsigned char bitValue = (dataByte >> bit) & 1U;
868 dst->ChestBoard_Button = bitValue != 0;
869 bit_offset = bit_offset + 1;
870 } while(false);
871 //avoid unused variable warnings when you try to use an empty gen file or a gen file with no supported serialisation types.
872 (void)src;
873 (void)dst;
874 return bit_offset;
875}
876
877/*#endif // WHITEBOARD_SERIALISATION*/
WHITEBOARD_POSTER_STRING_CONVERSION.
bool ChestBoard_Button
state of the chest button, on / off.
signed int DCM_Time
Absolute time used for all timed commands in the DCM, an integer (signed), with 1 ms precision.
struct wb_sensors_body_sensors * wb_sensors_body_sensors_from_string(struct wb_sensors_body_sensors *self, const char *str)
Convert from a string.
size_t wb_sensors_body_sensors_from_network_serialised(const char *src, struct wb_sensors_body_sensors *dst)
Convert from a compressed, serialised, network byte order byte stream.
size_t wb_sensors_body_sensors_to_network_serialised(const struct wb_sensors_body_sensors *self, char *dst)
Convert to a compressed, serialised, network byte order byte stream.
const char * wb_sensors_body_sensors_description(const struct wb_sensors_body_sensors *self, char *descString, size_t bufferSize)
Convert to a description string.
#define ntohl(x)
const char * wb_sensors_body_sensors_to_string(const struct wb_sensors_body_sensors *self, char *toString, size_t bufferSize)
Convert to a string.
#define htonl(x)
#define SENSORS_BODY_SENSORS_DESC_BUFFER_SIZE