#pragma once
-#include <map>
#include <queue>
-#include <vector>
-#include <cstdio>
-#include <string>
-#include <fcntl.h>
-#include <unistd.h>
-#include <net/if.h>
#include <thread>
-#include <sys/ioctl.h>
#include <linux/can.h>
-#include <sys/socket.h>
-#include <json-c/json.h>
-#include <linux/can/raw.h>
#include "timer.hpp"
#include "openxc.pb.h"
#include "low-can-binding.hpp"
-extern "C"
-{
- #include <afb/afb-binding.h>
-}
-
// TODO actual max is 32 but dropped to 24 for memory considerations
#define MAX_ACCEPTANCE_FILTERS 24
// TODO this takes up a ton of memory
int conf_file_; /*!< conf_file_ - configuration file handle used to initialize can_bus_dev_t objects.*/
std::thread th_decoding_; /*!< thread that'll handle decoding a can frame */
+ bool is_decoding_; /*!< boolean member controling thread while loop*/
std::thread th_pushing_; /*!< thread that'll handle pushing decoded can frame to subscribers */
+ bool is_pushing_; /*!< boolean member controling thread while loop*/
bool has_can_message_; /*!< boolean members that control whether or not there is can_message into the queue */
std::queue <can_message_t> can_message_q_; /*!< queue that'll store can_message_t to decoded */
*/
void start_threads();
+ /**
+ * @brief Will stop all threads holded by can_bus_t object
+ * which are decoding and pushing threads.
+ */
+ void stop_threads();
+
+ /**
+ * @brief Telling if the decoding thread is running.
+ * This is the boolean value on which the while loop
+ * take its condition. Set it to false will stop the
+ * according thread.
+ *
+ * @return true if decoding thread is running, false if not.
+ */
+ bool is_decoding();
+
+ /**
+ * @brief Telling if the pushing thread is running
+ * This is the boolean value on which the while loop
+ * take its condition. Set it to false will stop the
+ * according thread.
+ *
+ * @return true if pushing thread is running, false if not.
+ */
+ bool is_pushing();
+
/**
* @brief Return first can_message_t on the queue
*
* @return
*/
int open();
+
+ /**
+ * @brief Open the can socket and returning it
+ *
+ * @return
+ */
int close();
+
+ /**
+ * @brief Telling if the reading thread is running
+ * This is the boolean value on which the while loop
+ * take its condition. Set it to false will stop the
+ * according thread.
+ *
+ * @return true if reading thread is running, false if not.
+ */
bool is_running();
/**
/**
* @fn void post_initialize(can_bus_dev_t* bus, bool writable, can_bus_dev_t* buses, const int busCount);
- * @brief Post-initialize actions made after CAN bus initialization and before the
- * event loop connection.
+ * @brief Post-initialize actions made after CAN bus initialization
*
* @param[in] bus - A CanBus struct defining the bus's metadata
* @param[in] writable - configure the controller in a writable mode. If false, it will be