X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=inline;f=CAN-binder%2Flow-can-binding%2Fcan%2Fcan-decoder.cpp;h=e01e43bb8a46812c389ff0660eb810230c539eca;hb=eb5fc27fce3d832f1f969ebb01056a69c5f4c120;hp=a6c064db166735952f8863b51b06e4f5f009e797;hpb=f0973849c4df5740ffb241a21fc08398fa741a7e;p=apps%2Flow-level-can-service.git diff --git a/CAN-binder/low-can-binding/can/can-decoder.cpp b/CAN-binder/low-can-binding/can/can-decoder.cpp index a6c064d..e01e43b 100644 --- a/CAN-binder/low-can-binding/can/can-decoder.cpp +++ b/CAN-binder/low-can-binding/can/can-decoder.cpp @@ -20,6 +20,8 @@ #include "canutil/read.h" #include "../utils/openxc-utils.hpp" +#include "../low-can-binding.hpp" + /// @brief Parse the signal's bitfield from the given data and return the raw /// value. /// @@ -145,23 +147,30 @@ openxc_DynamicField decoder_t::stateDecoder(can_signal_t& signal, /// @param[in] signal - The details of the signal to decode and forward. /// @param[in] message - The received CAN message that should contain this signal. /// @param[in] signals - an array of all active signals. +/// @param[out] send - An output parameter that will be flipped to false if the value could +/// not be decoded. /// /// The decoder returns an openxc_DynamicField, which may contain a number, /// string or boolean. /// openxc_DynamicField decoder_t::translateSignal(can_signal_t& signal, can_message_t& message, - const std::vector& signals) + const std::vector& signals, bool* send) { float value = decoder_t::parseSignalBitfield(signal, message); DEBUG(binder_interface, "%s: Decoded message from parseSignalBitfield: %f", __FUNCTION__, value); - bool send = true; // Must call the decoders every time, regardless of if we are going to // decide to send the signal or not. openxc_DynamicField decoded_value = decoder_t::decodeSignal(signal, - value, signals, &send); + value, signals, send); signal.set_received(true); + + // Don't send if they is no changes + if ((signal.get_last_value() == value && !signal.get_send_same()) || !send ) + { + *send = false; + } signal.set_last_value(value); return decoded_value; }