diff options
Diffstat (limited to 'low-can-binding/utils/converter.cpp')
-rw-r--r-- | low-can-binding/utils/converter.cpp | 7 |
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)); |