diff options
Diffstat (limited to 'low-can-binding/utils')
-rw-r--r-- | low-can-binding/utils/openxc-utils.cpp | 11 | ||||
-rw-r--r-- | low-can-binding/utils/openxc-utils.hpp | 3 |
2 files changed, 9 insertions, 5 deletions
diff --git a/low-can-binding/utils/openxc-utils.cpp b/low-can-binding/utils/openxc-utils.cpp index b88c45d9..e2cf8d59 100644 --- a/low-can-binding/utils/openxc-utils.cpp +++ b/low-can-binding/utils/openxc-utils.cpp @@ -434,20 +434,23 @@ bool jsonify_simple(const openxc_SimpleMessage& s_msg, json_object* json) /// /// @param[in] v_msg - const reference to an openxc_VehicleMessage /// struct to convert into a json object. +/// @param[in] sig - signal reference to the subscription of openxc_VehicleMessage, +/// to get more informations about it /// @param[out] json - pointer with the DynamicField converted into json object /// /// @return True if VehicleMessage has been transformed into json object /// and false if not. In such case, a json object is returned { "error": "error msg"} /// -bool jsonify_vehicle(const openxc_VehicleMessage& v_msg, json_object* json) +bool jsonify_vehicle(const openxc_VehicleMessage& v_msg, std::shared_ptr<signal_t> sig, json_object* json) { if(jsonify_simple(get_simple_message(v_msg), json)) { + if(sig != nullptr && sig->get_unit() != "") + json_object_object_add(json, "unit", json_object_new_string(sig->get_unit().c_str())); + if(v_msg.has_timestamp) - { json_object_object_add(json, "timestamp", json_object_new_int64(v_msg.timestamp)); - return true; - } + return true; } json_object_object_add(json, "error", json_object_new_string("openxc_SimpleMessage doesn't have name'")); diff --git a/low-can-binding/utils/openxc-utils.hpp b/low-can-binding/utils/openxc-utils.hpp index 61f365b0..675dc2f1 100644 --- a/low-can-binding/utils/openxc-utils.hpp +++ b/low-can-binding/utils/openxc-utils.hpp @@ -23,6 +23,7 @@ #include <sys/timeb.h> #include "openxc.pb.h" +#include "../can/signals.hpp" #include "../diagnostic/active-diagnostic-request.hpp" const openxc_VehicleMessage build_VehicleMessage(active_diagnostic_request_t* request, const DiagnosticResponse& response, float parsed_value); @@ -48,4 +49,4 @@ void jsonify_DynamicField(const openxc_DynamicField& field, json_object* value); bool jsonify_simple(const openxc_SimpleMessage& s_msg, json_object* json); -bool jsonify_vehicle(const openxc_VehicleMessage& v_msg, json_object* json); +bool jsonify_vehicle(const openxc_VehicleMessage& v_msg, std::shared_ptr<signal_t> sig, json_object* json); |