Send entire CAN message rather than CAN signal.
authorRomain Forlot <romain.forlot@iot.bzh>
Wed, 8 Nov 2017 08:55:23 +0000 (09:55 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Wed, 8 Nov 2017 08:55:23 +0000 (09:55 +0100)
Old behavior send only the CAN signal, now we retrieve
the CAN message value instead and send the CAN message with
all CAN signals composing the message.

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

index 9ba8531..5cb1f24 100644 (file)
@@ -37,13 +37,19 @@ const can_frame encoder_t::build_frame(const std::shared_ptr<can_signal_t>& sign
 
        cf.can_id = signal->get_message()->get_id();
        cf.can_dlc = CAN_MAX_DLEN;
-       bitfield_encode_float((float)value,
-                                               signal->get_bit_position(),
-                                               signal->get_bit_size(),
-                                               signal->get_factor(),
-                                               signal->get_offset(),
-                                               cf.data,
-                                               CAN_MAX_DLEN);
+
+       signal->set_last_value((float)value);
+
+       for(const auto& sig: signal->get_message()->get_can_signals())
+       {
+               bitfield_encode_float((float)value,
+                                                       signal->get_bit_position(),
+                                                       signal->get_bit_size(),
+                                                       signal->get_factor(),
+                                                       signal->get_offset(),
+                                                       cf.data,
+                                                       CAN_MAX_DLEN);
+       }
 
        return cf;
 }