Update doc revision and pdf cover.
[apps/low-level-can-service.git] / libs / bitfield-c / 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  * source - the payload containing the signal.
14  * bit_offset - the starting bit for the signal.
15  * bit_size - the width of the signal.
16  * factor - the transformation factor for the signal value, applied after
17  *      pulling out the bit field. Use 1.0 for no factor.
18  * offset - the transformation offset for the signal value, applied after
19  *      pulling out the bit field. Use 0 for no offset.
20  *
21  * Returns the decoded and transformed value of the signal.
22  */
23 float eightbyte_parse_float(const uint64_t source, const uint8_t bit_offset,
24         const uint8_t bit_size, const float factor, const float offset);
25
26 /* Public: Parse a CAN signal from a message storage as a byte array and apply
27  * required transformation.
28  *
29  * source - the payload containing the signal.
30  * source_size - the size of the payload in bytes.
31  * bit_offset - the starting bit for the signal.
32  * bit_size - the width of the signal.
33  * factor - the transformation factor for the signal value, applied after
34  *      pulling out the bit field. Use 1.0 for no factor.
35  * offset - the transformation offset for the signal value, applied after
36  *      pulling out the bit field. Use 0 for no offset.
37  *
38  * Returns the decoded and transformed value of the signal.
39  */
40 float bitfield_parse_float(const uint8_t source[], const uint16_t source_size,
41         const uint8_t bit_offset, const uint8_t bit_size, const float factor,
42         const float offset);
43
44 /* Public: Parse a CAN signal from a message and interpret it as a boolean.
45  *
46  * source - the payload containing the signal.
47  * bit_offset - the starting bit for the signal.
48  * bit_size - the width of the signal.
49  * factor - the transformation factor for the signal value, applied after
50  *      pulling out the bit field. Use 1.0 for no factor.
51  * offset - the transformation offset for the signal value, applied after
52  *      pulling out the bit field. Use 0 for no offset.
53  *
54  * Returns false if the value was 0, otherwise true.
55  */
56 bool eightbyte_parse_bool(uint64_t source, uint8_t bit_offset, uint8_t bit_size,
57         float factor, float offset);
58
59 /* Public: Parse a CAN signal from a message storage as a byte array and
60  * interpret it as a boolean.
61  *
62  * source - the payload containing the signal.
63  * source_size - the size of the payload in bytes.
64  * bit_offset - the starting bit for the signal.
65  * bit_size - the width of the signal.
66  * factor - the transformation factor for the signal value, applied after
67  *      pulling out the bit field. Use 1.0 for no factor.
68  * offset - the transformation offset for the signal value, applied after
69  *      pulling out the bit field. Use 0 for no offset.
70  *
71  * Returns false if the value was 0, otherwise true.
72  */
73 bool bitfield_parse_bool(const uint8_t source[], const uint16_t source_size,
74         const uint8_t bit_offset, const uint8_t bit_size, const float factor,
75         const float offset);
76
77 #ifdef __cplusplus
78 }
79 #endif
80
81 #endif // __READ_H__