Test parsing boolean.
[apps/agl-service-can-low-level.git] / src / canutil / read.h
1 #ifndef __READ_H__
2 #define __READ_H__
3
4 #include <stdint.h>
5 #include <stdbool.h>
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 /* Public: Parse a CAN signal from a message and apply required transformation.
12  *
13  * signal - The details of the signal to decode and forward.
14  * data   - The raw bytes of the CAN message that contains the signal, assumed
15  *      to be in big-endian byte order from CAN.
16  *
17  * Returns the final, transformed value of the signal.
18  */
19 float bitfield_parse_float(uint64_t data, uint8_t bit_offset, uint8_t bit_size,
20         float factor, float offset);
21
22 /* Public: Parse a CAN signal from a message and interpret it as a boolean.
23  *
24  * signal - The details of the signal to decode and forward.
25  * data   - The raw bytes of the CAN message that contains the signal, assumed
26  *      to be in big-endian byte order from CAN.
27  *
28  * Returns false if the value was 0, otherwise true.
29  */
30 bool bitfield_parse_bool(uint64_t data, uint8_t bit_offset, uint8_t bit_size,
31         float factor, float offset);
32
33 #ifdef __cplusplus
34 }
35 #endif
36
37 #endif // __READ_H__