summaryrefslogtreecommitdiffstats
path: root/src/canutil/write.c
diff options
context:
space:
mode:
authorChristopher Peplin <chris.peplin@rhubarbtech.com>2013-12-29 13:57:37 -0500
committerChristopher Peplin <chris.peplin@rhubarbtech.com>2013-12-29 13:57:37 -0500
commite3bb578a0b11a25b0ae4c805fb7b98b724103b6f (patch)
treeaf3993d4b3c0bfc3d605e090d746f142970984ee /src/canutil/write.c
parent50715d3d8783dd081a403c1e580b34177ffa57bf (diff)
Test all canutil functions and document in README.
Diffstat (limited to 'src/canutil/write.c')
-rw-r--r--src/canutil/write.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/canutil/write.c b/src/canutil/write.c
index 14d2a449..583c2513 100644
--- a/src/canutil/write.c
+++ b/src/canutil/write.c
@@ -9,11 +9,13 @@ uint64_t bitfield_encode_float(float value, uint8_t bit_offset, uint8_t bit_size
raw += 0.5;
}
uint64_t result = 0;
- set_bit_field(&result, (uint64_t)raw, bit_offset, bit_size);
+ if(!set_bit_field(&result, (uint64_t)raw, bit_offset, bit_size)) {
+ // debug("%f will not fit in a %d bit field", value, bit_size);
+ }
return result;
}
-uint64_t bitfield_encode_bool(bool value, uint8_t bit_offset, uint8_t bit_size,
- float factor, float offset) {
- return bitfield_encode_float(value, offset, factor, bit_offset, bit_size);
+uint64_t bitfield_encode_bool(const bool value, const uint8_t bit_offset,
+ const uint8_t bit_size) {
+ return bitfield_encode_float(value, bit_offset, bit_size, 1.0, 0);
}