aboutsummaryrefslogtreecommitdiffstats
path: root/src/can-signals.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-02 22:32:53 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-02 22:32:53 +0100
commit17710741242f40c91edb28f29d6e5ef943a4c41b (patch)
treef062ead4681a8428960c5eb3a5bbacce51bf90c5 /src/can-signals.cpp
parentdff88d0ddd9054add5b8f0760e8e12c27c65c8eb (diff)
Fix: multiple subscription and maintain subscribed_signals coherence
across usage. - Transmission of a reference instead of copy. - Don't use anymore iterator on subscribed_signals map Change-Id: I5e5b7b0bb8598be3bb0ec59c29418ee937ddcc9e Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/can-signals.cpp')
-rw-r--r--src/can-signals.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/can-signals.cpp b/src/can-signals.cpp
index 82ee0dea..3832c331 100644
--- a/src/can-signals.cpp
+++ b/src/can-signals.cpp
@@ -34,6 +34,16 @@ 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 Can signal event map making access to afb_event
+ * externaly to an openxc existing structure.
+ *
+ * @desc Event map is making relation between CanSignal generic name
+ * and the afb_event struct used by application framework to pushed
+ * to the subscriber.
+ */
+std::map<std::string, struct afb_event> subscribed_signals;
+
/**
* @brief Mutex allowing safe manipulation on subscribed_signals map.
* @desc To ensure that the map object isn't modified when we read it, you
@@ -46,7 +56,13 @@ std::mutex& get_subscribed_signals_mutex()
return subscribed_signals_mutex;
}
-const std::vector<CanSignal> getSignals()
+std::map<std::string, struct afb_event>& get_subscribed_signals()
+{
+ DEBUG(binder_interface, "Here are the first subscribed_signals: %s", subscribed_signals.begin()->first.c_str() );
+ return subscribed_signals;
+}
+
+const std::vector<CanSignal>& getSignals()
{
return SIGNALS[MESSAGE_SET_ID];
}
@@ -88,9 +104,4 @@ std::vector<CanSignal> find_can_signals(const openxc_DynamicField &key)
inline uint32_t get_CanSignal_id(const CanSignal& sig)
{
return sig.message->id;
-}
-
-const std::map<std::string, struct afb_event> get_subscribed_signals()
-{
- return subscribed_signals;
} \ No newline at end of file