aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-12-10 10:08:15 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 16:25:36 +0100
commit0e786385e547a247f96fce164d38712d0f59298e (patch)
tree13dc576cc4c0dc1e3f8c58c43d135398bd06082e /low-can-binding
parentfe780799e8117ac30f9c05bcd43616638f35e66a (diff)
encoder: use contructor to initialize the vector
Instead of initilizing using a for loop... Also fixes a wrong watched bit using a bcm socket Change-Id: Ib65a3da06dbd249c97b8ec11823247120505d545 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding')
-rw-r--r--low-can-binding/can/can-encoder.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/low-can-binding/can/can-encoder.cpp b/low-can-binding/can/can-encoder.cpp
index 596cc7e2..8adbd884 100644
--- a/low-can-binding/can/can-encoder.cpp
+++ b/low-can-binding/can/can-encoder.cpp
@@ -44,14 +44,12 @@ void encoder_t::encode_data(std::shared_ptr<signal_t> sig, std::vector<uint8_t>
uint8_t new_end_bit = 0;
converter_t::signal_to_bits_bytes(bit_position, bit_size, new_start_byte, new_end_byte, new_start_bit, new_end_bit);
- std::vector<uint8_t> data_signal(new_end_byte - new_start_byte + 1);
+ std::vector<uint8_t> data_signal(new_end_byte - new_start_byte + 1, 0xFF);
if(filter)
{
- for (auto& elt: data_signal)
- elt = 0xFF;
- uint8_t mask_first_v = static_cast<uint8_t>(0xFF << new_start_bit);
- uint8_t mask_last_v = static_cast<uint8_t>(0xFF >> (7 - new_end_bit));
+ uint8_t mask_first_v = static_cast<uint8_t>(0xFF >> new_start_bit);
+ uint8_t mask_last_v = static_cast<uint8_t>(0xFF << (7 - new_end_bit));
if(new_start_byte == new_end_byte)
{