From bc1baf25a0844861713829c0e9e69e4a2d447cc6 Mon Sep 17 00:00:00 2001 From: Christopher Peplin Date: Tue, 24 Dec 2013 10:56:35 -0500 Subject: Initial commit, pulled from openxc/vi-firmware. --- src/canutil/read.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/canutil/read.c (limited to 'src/canutil/read.c') diff --git a/src/canutil/read.c b/src/canutil/read.c new file mode 100644 index 00000000..6b4e40aa --- /dev/null +++ b/src/canutil/read.c @@ -0,0 +1,14 @@ +#include + +float parseFloat(uint64_t data, uint8_t bitPosition, uint8_t bitSize, + float factor, float offset) { + uint64_t rawValue = getBitField(data, bitPosition, + bitSize, true); + return rawValue * factor + offset; +} + +bool parseBoolean(uint64_t data, uint8_t bitPosition, uint8_t bitSize, + float factor, float offset) { + float value = parseFloat(data, bitPosition, bitSize, factor, offset); + return value == 0.0 ? false : true; +} -- cgit 1.2.3-korg