summaryrefslogtreecommitdiffstats
path: root/src/canutil/read.h
blob: 028b03a6b3ef37b8cdae0538c5eb821c9475dd53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef __READ_H__
#define __READ_H__

#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Public: Parse a CAN signal from a message and apply required transformation.
 *
 * signal - The details of the signal to decode and forward.
 * data   - The raw bytes of the CAN message that contains the signal, assumed
 *      to be in big-endian byte order from CAN.
 *
 * Returns the final, transformed value of the signal.
 */
float bitfield_parse_float(uint64_t data, uint8_t bit_offset, uint8_t bit_size,
        float factor, float offset);

/* Public: Parse a CAN signal from a message and interpret it as a boolean.
 *
 * signal - The details of the signal to decode and forward.
 * data   - The raw bytes of the CAN message that contains the signal, assumed
 *      to be in big-endian byte order from CAN.
 *
 * Returns false if the value was 0, otherwise true.
 */
bool bitfield_parse_bool(uint64_t data, uint8_t bit_offset, uint8_t bit_size,
        float factor, float offset);

#ifdef __cplusplus
}
#endif

#endif // __READ_H__