aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Guyader <arthur.guyader@iot.bzh>2019-12-16 19:19:50 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 16:25:36 +0100
commit744d95cffe1241c97d922b18f6e3723fff7d64fe (patch)
tree8210c375afd511af637956fab5a6f7eafaf5a2ce
parente28ae5f481c3a0d78bb7d6c21416dc38be541a4d (diff)
can_decoder : Move frame swap to only do it one time
This commit allows to swap only one time a data message. Change-Id: I566c6ad72e266cd59a4397ab1a5ef423d752cf75 Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh> Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--low-can-binding/binding/low-can-hat.cpp4
-rw-r--r--low-can-binding/can/can-decoder.cpp22
2 files changed, 15 insertions, 11 deletions
diff --git a/low-can-binding/binding/low-can-hat.cpp b/low-can-binding/binding/low-can-hat.cpp
index 7e0d94a4..72580744 100644
--- a/low-can-binding/binding/low-can-hat.cpp
+++ b/low-can-binding/binding/low-can-hat.cpp
@@ -74,7 +74,11 @@ int read_message(sd_event_source *event_source, int fd, uint32_t revents, void *
if (message->get_id() &&
message->get_length() &&
! (message->get_flags() & INVALID_FLAG) )
+ {
+ if(can_subscription->get_signal() != nullptr && can_subscription->get_signal()->get_message()->get_flags() & BYTE_FRAME_IS_BIG_ENDIAN)
+ message->frame_swap();
push_n_notify(message);
+ }
}
}
}
diff --git a/low-can-binding/can/can-decoder.cpp b/low-can-binding/can/can-decoder.cpp
index 160a22b1..7221d716 100644
--- a/low-can-binding/can/can-decoder.cpp
+++ b/low-can-binding/can/can-decoder.cpp
@@ -104,17 +104,6 @@ float decoder_t::parse_signal_bitfield(signal_t& signal, std::shared_ptr<message
uint8_t new_start_bit = 0;
uint8_t new_end_bit = 0;
- if(signal.get_message()->get_flags() & CONTINENTAL_BIT_POSITION)
- bit_position = converter_t::continental_bit_position_mess(message->get_length(),
- signal.get_bit_position(),
- bit_size);
- if(signal.get_message()->get_flags() & BIT_POSITION_REVERSED)
- bit_position = converter_t::bit_position_swap(message->get_length(),
- signal.get_bit_position(),
- bit_size);
- if(signal.get_message()->get_flags() & BYTE_FRAME_IS_BIG_ENDIAN)
- message->frame_swap();
-
data = message->get_data_vector();
converter_t::signal_to_bits_bytes(bit_position, bit_size, new_start_byte, new_end_byte, new_start_bit, new_end_bit);
@@ -409,6 +398,17 @@ openxc_DynamicField decoder_t::translate_signal(signal_t& signal, std::shared_pt
///
openxc_DynamicField decoder_t::decode_signal( signal_t& signal, std::shared_ptr<message_t> message, bool* send)
{
+
+
+ if(signal.get_message()->get_flags() & CONTINENTAL_BIT_POSITION)
+ signal.set_bit_position(converter_t::continental_bit_position_mess(message->get_length(),
+ signal.get_bit_position(),
+ signal.get_bit_size()));
+ if(signal.get_message()->get_flags() & BIT_POSITION_REVERSED)
+ signal.set_bit_position(converter_t::bit_position_swap(message->get_length(),
+ signal.get_bit_position(),
+ signal.get_bit_size()));
+
signal_decoder decoder = signal.get_decoder() == nullptr ?
decode_noop : signal.get_decoder();