encoder: use contructor to initialize the vector 02/23302/4
authorRomain Forlot <romain.forlot@iot.bzh>
Tue, 10 Dec 2019 09:08:15 +0000 (10:08 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 9 Jan 2020 15:25:36 +0000 (16:25 +0100)
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>
low-can-binding/can/can-encoder.cpp

index 596cc7e..8adbd88 100644 (file)
@@ -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)
                {