summaryrefslogtreecommitdiffstats
path: root/low-can-binding/can/can-signals.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-07-13 18:51:20 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-07-21 12:02:11 +0200
commit2408a177e8260dcda266df9993e6acd528bebbbc (patch)
tree32fbc74e96659d701496a3687ef9c0496dd4fd07 /low-can-binding/can/can-signals.cpp
parent0dc8b87f5d8a03183c1b947640f6315545e4207b (diff)
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 <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/can/can-signals.cpp')
-rw-r--r--low-can-binding/can/can-signals.cpp14
1 files changed, 14 insertions, 0 deletions
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();