summaryrefslogtreecommitdiffstats
path: root/libs/bitfield-c/src/canutil/write.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-23 13:39:52 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 15:55:03 +0100
commit78e8a778786bf3f9050e55d99dd2b4338e8f4a8e (patch)
tree8dde7b0f50ea497f7a79ba60909570305328cb26 /libs/bitfield-c/src/canutil/write.c
parentd76433ade0b75c8cc2b45fdae52a21d7fb28f526 (diff)
bitfield-c: use unsigned int instead of uint8_t
Use unsigned int instead of uint8_t upon destination and source array length. This is needed to handle gathered multi-frames message data which could be greater than 1 simple messages. Bug-AGL: SPEC-2988 Change-Id: I107bff383c2d0771dbc2a30770ec5c195b1c22ac Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'libs/bitfield-c/src/canutil/write.c')
-rw-r--r--libs/bitfield-c/src/canutil/write.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libs/bitfield-c/src/canutil/write.c b/libs/bitfield-c/src/canutil/write.c
index 7f3a3e04..317ccf04 100644
--- a/libs/bitfield-c/src/canutil/write.c
+++ b/libs/bitfield-c/src/canutil/write.c
@@ -14,7 +14,7 @@ uint64_t float_to_fixed_point(const float value, const float factor,
return (uint64_t)raw;
}
-uint64_t eightbyte_encode_float(float value, uint8_t bit_offset, uint8_t bit_size,
+uint64_t eightbyte_encode_float(float value, unsigned int bit_offset, unsigned int bit_size,
float factor, float offset) {
uint64_t result = 0;
if(!eightbyte_set_bitfield(float_to_fixed_point(value, factor, offset),
@@ -24,14 +24,14 @@ uint64_t eightbyte_encode_float(float value, uint8_t bit_offset, uint8_t bit_siz
return result;
}
-uint64_t eightbyte_encode_bool(const bool value, const uint8_t bit_offset,
- const uint8_t bit_size) {
+uint64_t eightbyte_encode_bool(const bool value, const unsigned int bit_offset,
+ const unsigned int bit_size) {
return eightbyte_encode_float(value, bit_offset, bit_size, 1.0, 0);
}
-bool bitfield_encode_float(const float value, const uint8_t bit_offset,
- const uint8_t bit_size, const float factor, const float offset,
- uint8_t destination[], const uint8_t destination_length) {
+bool bitfield_encode_float(const float value, const unsigned int bit_offset,
+ const unsigned int bit_size, const float factor, const float offset,
+ uint8_t destination[], const unsigned int destination_length) {
if(!set_bitfield(float_to_fixed_point(value, factor, offset), bit_offset,
bit_size, destination, destination_length)) {
// debug("%f will not fit in a %d bit field", value, bit_size);
@@ -40,9 +40,9 @@ bool bitfield_encode_float(const float value, const uint8_t bit_offset,
return true;
}
-bool bitfield_encode_bool(const bool value, const uint8_t bit_offset,
- const uint8_t bit_size, uint8_t destination[],
- const uint16_t destination_length) {
+bool bitfield_encode_bool(const bool value, const unsigned int bit_offset,
+ const unsigned int bit_size, uint8_t destination[],
+ const unsigned int destination_length) {
return bitfield_encode_float(value, bit_offset, bit_size, 1.0, 0,
destination, destination_length);
}