summaryrefslogtreecommitdiffstats
path: root/CAN-binder/low-can-binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-06-01 18:18:33 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-06-01 18:40:13 +0200
commit5b992c19e04ccb3c4ba0b3314fd4152a9919d98c (patch)
tree33b54161a69b61c4de996807c0aa7142eee61308 /CAN-binder/low-can-binding
parenta1a554bd3dc19580c9b80dc6e4beb6bed4711e53 (diff)
Implement minimum and maximum subscription filters
Change-Id: I6b027cdb37e425e185b8d2278ae775f857ff96bc Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding')
-rw-r--r--CAN-binder/low-can-binding/can/can-bus.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/CAN-binder/low-can-binding/can/can-bus.cpp b/CAN-binder/low-can-binding/can/can-bus.cpp
index cc0a3d6c..9ee649cd 100644
--- a/CAN-binder/low-can-binding/can/can-bus.cpp
+++ b/CAN-binder/low-can-binding/can/can-bus.cpp
@@ -47,11 +47,15 @@ can_bus_t::can_bus_t(utils::config_parser_t conf_file)
bool can_bus_t::apply_filter(const openxc_VehicleMessage& vehicle_message, std::shared_ptr<low_can_subscription_t> can_subscription)
{
+ bool send = false;
if(is_valid(vehicle_message))
{
- return true;
+ float min = std::isnan(can_subscription->get_min()) ? -INFINITY : can_subscription->get_min();
+ float max = std::isnan(can_subscription->get_max()) ? INFINITY : can_subscription->get_max();
+ double value = get_numerical_from_DynamicField(vehicle_message);
+ send = (value < min && value > max) ? false : true;
}
- return false;
+ return send;
}
/// @brief Will make the decoding operation on a classic CAN message. It will not