From 0e786385e547a247f96fce164d38712d0f59298e Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Tue, 10 Dec 2019 10:08:15 +0100 Subject: [PATCH 1/1] 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 --- low-can-binding/can/can-encoder.cpp | 8 +++----- 1 file 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 sig, std::vector 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 data_signal(new_end_byte - new_start_byte + 1); + std::vector 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(0xFF << new_start_bit); - uint8_t mask_last_v = static_cast(0xFF >> (7 - new_end_bit)); + uint8_t mask_first_v = static_cast(0xFF >> new_start_bit); + uint8_t mask_last_v = static_cast(0xFF << (7 - new_end_bit)); if(new_start_byte == new_end_byte) { -- 2.16.6