summaryrefslogtreecommitdiffstats
path: root/low-can-binding/utils/converter.cpp
diff options
context:
space:
mode:
authorCorentin Le Gall <corentin.legall@iot.bzh>2019-11-18 16:48:20 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 14:40:41 +0100
commit77a19477d3cb63b5af519853489cc90ead0a111b (patch)
tree9c1b34399e45a8870e3b2d01058e9a6c3481c7e8 /low-can-binding/utils/converter.cpp
parent6cc152447e74b1ce7fab6c7aa1f9b4e5e8232444 (diff)
decoder: Fix bit_position swapping
-Added an attribute to signals that tells if the bit_position has been swapped. -Test if bit_size and bit_position gives an "out of range" data Bug-AGL: SPEC-3022 Change-Id: I589565ca923ec807da2d4f0db7c4c92fb737b579 Signed-off-by: Corentin Le Gall <corentin.legall@iot.bzh> Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/utils/converter.cpp')
-rw-r--r--low-can-binding/utils/converter.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/low-can-binding/utils/converter.cpp b/low-can-binding/utils/converter.cpp
index f790fc00..9e70bc95 100644
--- a/low-can-binding/utils/converter.cpp
+++ b/low-can-binding/utils/converter.cpp
@@ -69,6 +69,13 @@ uint32_t converter_t::bit_position_swap(uint32_t bit_position,uint32_t bit_size)
{
uint32_t start_byte_position = (uint32_t)(bit_position/8);
uint32_t bit_size_rest = bit_size;
+
+ if((int)(bit_size-(8 + start_byte_position*8-bit_position%8))>0)
+ {
+ AFB_ERROR("Error: bit_position and bit_size getting out of range");
+ return bit_position;
+ }
+
if(bit_size<=8 && ((bit_position+bit_size)%8==bit_size || (bit_position+bit_size)%8==0))
{
return (uint32_t)(start_byte_position*8 + (8-bit_size));