aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding/can/can-encoder.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-11-08 09:55:23 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-11-08 09:55:23 +0100
commitba16f23513b14ee591e372e564401cedd644e45b (patch)
tree529c5eac4276c051df51ed0e3eab8d646a1034d8 /low-can-binding/can/can-encoder.cpp
parent0108faa54fa3c257103d56f90f3189551870dac0 (diff)
Send entire CAN message rather than CAN signal.
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>
Diffstat (limited to 'low-can-binding/can/can-encoder.cpp')
-rw-r--r--low-can-binding/can/can-encoder.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/low-can-binding/can/can-encoder.cpp b/low-can-binding/can/can-encoder.cpp
index 9ba85317..5cb1f244 100644
--- a/low-can-binding/can/can-encoder.cpp
+++ b/low-can-binding/can/can-encoder.cpp
@@ -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;
}