summaryrefslogtreecommitdiffstats
path: root/src/can-bus.hpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-02-28 21:09:26 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-02-28 21:45:49 +0100
commitca998f6733e3de11886ac6c3ee6525dbaaf3b525 (patch)
tree6298de2bd40417297129680a994135282ac5a3b5 /src/can-bus.hpp
parentabded1a649deb14f7e7fbc67d34d02ff4a9b5fa6 (diff)
Fix: can bus object life is now expanded and don't
die prematuraly. can_bus_handler object is now a pointer living forever. can_bus_dev_t object is now stored as a shared pointer into a variable member into can_bus_t. So everyone survive now. Change-Id: I52768dd7fe3c203a5f679f59afd1bcf330f3af35 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/can-bus.hpp')
-rw-r--r--src/can-bus.hpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/can-bus.hpp b/src/can-bus.hpp
index 302514d..83b104b 100644
--- a/src/can-bus.hpp
+++ b/src/can-bus.hpp
@@ -36,6 +36,8 @@
#define CAN_ACTIVE_TIMEOUT_S 30
+class can_bus_dev_t;
+
/**
* @class can_bus_t
* @brief Object used to handle decoding and manage event queue to be pushed.
@@ -81,6 +83,8 @@ class can_bus_t {
bool has_vehicle_message_; /*!< boolean members that control whether or not there is openxc_VehicleMessage into the queue */
std::queue <openxc_VehicleMessage> vehicle_message_q_; /*!< queue that'll store openxc_VehicleMessage to pushed */
+ std::map<std::string, std::shared_ptr<can_bus_dev_t>> can_devices_m_; /*!< Can device map containing all can_bus_dev_t objects initialized during init_can_dev function*/
+
public:
/**
* @brief Class constructor
@@ -88,7 +92,7 @@ class can_bus_t {
* @param struct afb_binding_interface *interface between daemon and binding
* @param int file handle to the json configuration file.
*/
- can_bus_t(int& conf_file);
+ can_bus_t(int conf_file);
/**
* @brief Will initialize can_bus_dev_t objects after reading
@@ -152,11 +156,17 @@ class can_bus_t {
void push_new_can_message(const can_message_t& can_msg);
/**
- * @brief Return a boolean telling if there is any can_message into the queue
+ * @brief return can_message_mutex_ member
*
- * @return true if there is at least a can_message_t, false if not.
+ * @return return can_message_mutex_ member
*/
std::mutex& get_can_message_mutex();
+
+ /**
+ * @brief return new_can_message_ member
+ *
+ * @return return new_can_message_ member
+ */
std::condition_variable& get_new_can_message();
@@ -175,6 +185,7 @@ class can_bus_t {
void push_new_vehicle_message(const openxc_VehicleMessage& v_msg);
};
+
/**
* @class can_bus_dev_t
*