From 2408a177e8260dcda266df9993e6acd528bebbbc Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Thu, 13 Jul 2017 18:51:20 +0200 Subject: Be able to write raw frame & encode value to sent Check whether the argument is a raw frame or a Signal + Value to encode then send. 1 new class to handle encoding part of a value as well as a new method for can_signal_t which return index of a map from its value. Change-Id: I288d2aeec28ce74c9ca35750db18557c9251e1df Signed-off-by: Romain Forlot --- low-can-binding/can/can-signals.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'low-can-binding/can/can-signals.cpp') diff --git a/low-can-binding/can/can-signals.cpp b/low-can-binding/can/can-signals.cpp index 573808aa..45c54cb4 100644 --- a/low-can-binding/can/can-signals.cpp +++ b/low-can-binding/can/can-signals.cpp @@ -141,6 +141,20 @@ const std::string can_signal_t::get_states(uint8_t value) return std::string(); } +uint64_t can_signal_t::get_states(const std::string& value) const +{ + uint64_t ret = -1; + for( const auto& state: states_) + { + if(state.second == value) + { + ret = (uint64_t)state.first; + break; + } + } + return ret; +} + size_t can_signal_t::get_state_count() const { return states_.size(); -- cgit 1.2.3-korg