Make the thread function members of can_bus_t and can_bus_dev_t objects.
[apps/agl-service-can-low-level.git] / src / can-signals.cpp
index ee682f9..5f23c40 100644 (file)
 
 #include "can-signals.hpp"
 
+#include <fnmatch.h>
+
+#include "can-decoder.hpp"
+#include "low-can-binding.hpp"
+
+std::vector<std::vector<CanMessageDefinition>> CAN_MESSAGES = {
+       {{620, CanMessageFormat::STANDARD, {10, 0, nullptr}, false, (uint8_t)NULL}},
+};
+
 /**
  * @brief Dumb SIGNALS array. It is composed by CanMessageSet
  * SIGNALS[MESSAGE_SET_ID][CanSignal]
  */
-std::vector<std::vector<CanSignal>> SIGNALS {
-       {}// message set: example
+std::vector<std::vector<CanSignal>> SIGNALS {
+       {{&(CAN_MESSAGES[0][0]), "can.driver_door.open", 2, 4, 1.000000, 0.000000, 0.000000, 0.000000, {10, 0, nullptr}, false, true, nullptr, 0, false, decoder_t::booleanDecoder, nullptr, false, (float)NULL}},
 };
 
+/**
+* @brief Mutex allowing safe manipulation on subscribed_signals map.
+* @desc To ensure that the map object isn't modified when we read it, you
+*  have to set this mutex before use subscribed_signals map object.
+*/
+std::mutex subscribed_signals_mutex;
+
+std::mutex& get_subscribed_signals_mutex()
+{
+       return subscribed_signals_mutex;
+}
+
 const std::vector<CanSignal> getSignals()
 {
        return SIGNALS[MESSAGE_SET_ID];
@@ -35,7 +56,7 @@ size_t getSignalCount()
        return SIGNALS[MESSAGE_SET_ID].size();
 }
 
-std::vector<CanSignal> find_can_signals(const struct afb_binding_interface* interface, openxc_DynamicField& key)
+std::vector<CanSignal> find_can_signals(const openxc_DynamicField &key)
 {
        std::vector<CanSignal> signals;
 
@@ -57,7 +78,7 @@ std::vector<CanSignal> find_can_signals(const struct afb_binding_interface* inte
                        }
                        break;
                default:
-                       ERROR(interface, "find_can_signals: wrong openxc_DynamicField specified. Use openxc_DynamicField_Type_NUM or openxc_DynamicField_Type_STRING type only.");
+                       ERROR(binder_interface, "find_can_signals: wrong openxc_DynamicField specified. Use openxc_DynamicField_Type_NUM or openxc_DynamicField_Type_STRING type only.");
                        CanSignal cs;
                        ::memset(&cs, 0, sizeof(CanSignal));
                        signals.push_back(cs);