converter: Improve the continental bit calcul 90/23390/3
authorRomain Forlot <romain.forlot@iot.bzh>
Sun, 15 Dec 2019 11:12:56 +0000 (12:12 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 9 Jan 2020 15:25:36 +0000 (16:25 +0100)
This is an improvment of the bit_position computing. This now operate only
on full bytes to get the position.

Change-Id: Idb4993a3c9922d50d02379139e7cbbe5a2cb501b
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
low-can-binding/utils/converter.cpp

index 5662574..6c9cedb 100644 (file)
@@ -99,5 +99,5 @@ uint32_t converter_t::bit_position_swap(unsigned int msg_length, unsigned int bi
  */
 uint32_t converter_t::continental_bit_position_mess(unsigned int msg_length, unsigned int bit_position, unsigned int bit_size)
 {
-       return bit_position + (CHAR_BIT - bit_position % CHAR_BIT) - bit_size;
+       return bit_position + CHAR_BIT - 2 * (bit_position % CHAR_BIT) - bit_size;
 }