From 97a08a7e37835f0e8619d22c83243bee26a2bff2 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Fri, 7 Dec 2018 17:17:43 +0100 Subject: Smalls improvements - Improve robustness reading a BCM socket Adding checks on system calls and remove the initialization of the struct that will hold the received message, not so much needed in that case. - More accurate log message at subscription/unsubscription step whether this is a FD CAN messages or not and if this a subscription or an unsubscription that is requested. - Initialize the full struct of vehicle message to avoid memory warning about conditionnal jump based on uninitialized bytes. - Memleak: Free raw pointer on active diagnostic requests Change-Id: I4bbf4d851c0fa1efdb6fa6034fac3d1dcafa1a73 Signed-off-by: Romain Forlot --- low-can-binding/can/can-bus.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'low-can-binding/can') diff --git a/low-can-binding/can/can-bus.cpp b/low-can-binding/can/can-bus.cpp index 49a6b60a..e798618d 100644 --- a/low-can-binding/can/can-bus.cpp +++ b/low-can-binding/can/can-bus.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015, 2016 "IoT.bzh" + * Copyright (C) 2015, 2018 "IoT.bzh" * Author "Romain Forlot" * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -87,12 +87,12 @@ void can_bus_t::process_can_signals(const can_message_t& can_message, std::map sig = s[subscription_id]; - if( s.find(subscription_id) != s.end() && afb_event_is_valid(s[subscription_id]->get_event())) { bool send = true; + // First we have to found which can_signal_t it is + std::shared_ptr sig = s[subscription_id]; + decoded_message = decoder_t::translate_signal(*sig->get_can_signal(), can_message, &send); openxc_SimpleMessage s_message = build_SimpleMessage(sig->get_name(), decoded_message); vehicle_message = build_VehicleMessage(s_message, can_message.get_timestamp()); -- cgit 1.2.3-korg