aboutsummaryrefslogtreecommitdiffstats
path: root/CAN-binder/low-can-binding/utils/openxc-utils.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-06-01 18:17:29 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-06-01 18:40:13 +0200
commit267e52aecd92ef7891725076bacba19d2167dac2 (patch)
tree7477e3e22fb11ff81b2aeba980dac99223b47e67 /CAN-binder/low-can-binding/utils/openxc-utils.cpp
parent71c41df6cd794b670f9a16ca060a9c4ab054200e (diff)
Methods to ease access to DynamicField members
Change-Id: I8974827340e3faf60a511900cbdcf117ce43fb53 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding/utils/openxc-utils.cpp')
-rw-r--r--CAN-binder/low-can-binding/utils/openxc-utils.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/CAN-binder/low-can-binding/utils/openxc-utils.cpp b/CAN-binder/low-can-binding/utils/openxc-utils.cpp
index 08f1c8ab..1d3cd795 100644
--- a/CAN-binder/low-can-binding/utils/openxc-utils.cpp
+++ b/CAN-binder/low-can-binding/utils/openxc-utils.cpp
@@ -269,6 +269,26 @@ const openxc_DynamicField build_DynamicField(bool value)
return d;
}
+int get_bool_from_DynamicField(const openxc_VehicleMessage& v_msg, bool* ret)
+{
+ if(v_msg.has_simple_message && v_msg.simple_message.has_value && v_msg.simple_message.value.has_boolean_value)
+ {*ret = v_msg.simple_message.value.boolean_value;}
+ else
+ {return -1;}
+}
+
+double get_numerical_from_DynamicField(const openxc_VehicleMessage& v_msg)
+{
+ return (v_msg.has_simple_message && v_msg.simple_message.has_value && v_msg.simple_message.value.has_numeric_value) ?
+ v_msg.simple_message.value.numeric_value : -1.0;
+}
+
+const std::string get_string_from_DynamicField(const openxc_VehicleMessage& v_msg)
+{
+return (v_msg.has_simple_message && v_msg.simple_message.has_value && v_msg.simple_message.value.has_string_value) ?
+ v_msg.simple_message.value.string_value : "";
+}
+
///
/// @brief Extract the simple message value from an openxc_VehicleMessage
/// and return it. If there isn't SimpleMessage in the VehicleMessage then