diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-04 10:51:16 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-04 10:52:42 -0500 |
commit | 08db5c9eb826f7aa0dba36cbef8011d7bc6b55a5 (patch) | |
tree | b2875552387f00191c772bc6da08dcaa7e6d2e87 /src/canutil/read.h | |
parent | 6f3a81ed8287357b54aad16bff27495c6eaca6df (diff) |
Add a get_bitfield function for byte arrays.
Diffstat (limited to 'src/canutil/read.h')
-rw-r--r-- | src/canutil/read.h | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/canutil/read.h b/src/canutil/read.h index bf6c0ade..733e3509 100644 --- a/src/canutil/read.h +++ b/src/canutil/read.h @@ -10,7 +10,7 @@ extern "C" { /* Public: Parse a CAN signal from a message and apply required transformation. * - * data - the payload containing the signal. + * source - the payload containing the signal. * bit_offset - the starting bit for the signal. * bit_size - the width of the signal. * factor - the transformation factor for the signal value, applied after @@ -20,16 +20,30 @@ extern "C" { * * Returns the decoded and transformed value of the signal. */ -float eightbyte_parse_float(const uint64_t data, const uint8_t bit_offset, +float eightbyte_parse_float(const uint64_t source, const uint8_t bit_offset, const uint8_t bit_size, const float factor, const float offset); -float bitfield_parse_float(const uint8_t data[], const uint16_t size, +/* Public: Parse a CAN signal from a message storage as a byte array and apply + * required transformation. + * + * source - the payload containing the signal. + * source_size - the size of the payload in bytes. + * bit_offset - the starting bit for the signal. + * bit_size - the width of the signal. + * factor - the transformation factor for the signal value, applied after + * pulling out the bit field. Use 1.0 for no factor. + * offset - the transformation offset for the signal value, applied after + * pulling out the bit field. Use 0 for no offset. + * + * Returns the decoded and transformed value of the signal. + */ +float bitfield_parse_float(const uint8_t source[], const uint16_t source_size, const uint8_t bit_offset, const uint8_t bit_size, const float factor, const float offset); /* Public: Parse a CAN signal from a message and interpret it as a boolean. * - * data - the payload containing the signal. + * source - the payload containing the signal. * bit_offset - the starting bit for the signal. * bit_size - the width of the signal. * factor - the transformation factor for the signal value, applied after @@ -39,9 +53,27 @@ float bitfield_parse_float(const uint8_t data[], const uint16_t size, * * Returns false if the value was 0, otherwise true. */ -bool eightbyte_parse_bool(uint64_t data, uint8_t bit_offset, uint8_t bit_size, +bool eightbyte_parse_bool(uint64_t source, uint8_t bit_offset, uint8_t bit_size, float factor, float offset); +/* Public: Parse a CAN signal from a message storage as a byte array and + * interpret it as a boolean. + * + * source - the payload containing the signal. + * source_size - the size of the payload in bytes. + * bit_offset - the starting bit for the signal. + * bit_size - the width of the signal. + * factor - the transformation factor for the signal value, applied after + * pulling out the bit field. Use 1.0 for no factor. + * offset - the transformation offset for the signal value, applied after + * pulling out the bit field. Use 0 for no offset. + * + * Returns false if the value was 0, otherwise true. + */ +float bitfield_parse_float(const uint8_t source[], const uint16_t source_size, + const uint8_t bit_offset, const uint8_t bit_size, const float factor, + const float offset); + #ifdef __cplusplus } #endif |