In class mutex and condition variable except for subscribed_signals map
[apps/agl-service-can-low-level.git] / src / can-utils.cpp
index c6f2d57..977d344 100644 (file)
@@ -162,16 +162,33 @@ canfd_frame can_message_t::convert_to_canfd_frame()
 *********************************************************************************/
 
 can_bus_t::can_bus_t(int& conf_file)
-       :  conf_file_{conf_file}
+       : conf_file_{conf_file}
 {
 }
 
 void can_bus_t::start_threads()
 {
        th_decoding_ = std::thread(can_decode_message, std::ref(*this));
+       is_decoding_ = true;
        th_pushing_ = std::thread(can_event_push, std::ref(*this));
+       is_pushing_ = true;
 }
 
+void can_bus_t::stop_threads()
+{
+       is_decoding_ = false;
+       is_pushing_ = false;
+}
+
+bool can_bus_t::is_decoding()
+{
+       return is_decoding_;
+}
+
+bool can_bus_t::is_pushing()
+{
+       return is_pushing_;
+}
 
 int can_bus_t::init_can_dev()
 {
@@ -241,6 +258,26 @@ std::vector<std::string> can_bus_t::read_conf()
        return ret;
 }
 
+std::condition_variable& can_bus_t::get_new_can_message()
+{
+       return new_can_message_;
+}
+
+std::mutex& can_bus_t::get_can_message_mutex()
+{
+       return can_message_mutex_;
+}
+
+std::condition_variable& can_bus_t::get_new_decoded_can_message()
+{
+       return new_decoded_can_message_;
+}
+
+std::mutex& can_bus_t::get_decoded_can_message_mutex()
+{
+       return decoded_can_message_mutex_;
+}
+
 can_message_t can_bus_t::next_can_message()
 {
        can_message_t can_msg;