summaryrefslogtreecommitdiffstats
path: root/src/can-utils.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/can-utils.hpp')
-rw-r--r--src/can-utils.hpp117
1 files changed, 54 insertions, 63 deletions
diff --git a/src/can-utils.hpp b/src/can-utils.hpp
index 8b64cb3b..db97b4bf 100644
--- a/src/can-utils.hpp
+++ b/src/can-utils.hpp
@@ -62,6 +62,55 @@ typedef openxc_DynamicField (*SignalDecoder)(struct CanSignal* signal,
typedef uint64_t (*SignalEncoder)(struct CanSignal* signal,
openxc_DynamicField* value, bool* send);
+/* Public: The ID format for a CAN message.
+ *
+ * STANDARD - standard 11-bit CAN arbitration ID.
+ * EXTENDED - an extended frame, with a 29-bit arbitration ID.
+ */
+enum CanMessageFormat {
+ STANDARD,
+ EXTENDED,
+};
+typedef enum CanMessageFormat CanMessageFormat;
+
+/* A compact representation of a single CAN message, meant to be used in in/out
+ * buffers.
+ *
+ * id - The ID of the message.
+ * format - the format of the message's ID.
+ * data - The message's data field.
+ * length - the length of the data array (max 8).
+struct CanMessage {
+ uint32_t id;
+ CanMessageFormat format;
+ uint8_t data[CAN_MESSAGE_SIZE];
+ uint8_t length;
+};
+typedef struct CanMessage CanMessage;
+*/
+class can_message_t {
+ private:
+ afb_binding_interface interface_;
+ uint32_t id_;
+ CanMessageFormat format_;
+ uint8_t data_[CAN_MESSAGE_SIZE];
+ uint8_t length_;
+
+ public:
+ uint32_t get_id() const;
+ int get_format() const;
+ uint8_t get_data() const;
+ uint8_t get_lenght() const;
+
+ void set_id(uint32_t id);
+ void set_format(CanMessageFormat format);
+ void set_data(uint8_t data);
+ void set_lenght(uint8_t length);
+
+ void convert_from_canfd_frame(canfd_frame frame);
+ canfd_frame convert_to_canfd_frame();
+};
+
/**
* @brief Object representing a can device. Handle opening, closing and reading on the
* socket. This is the low level object to be use by can_bus_t.
@@ -91,8 +140,7 @@ class can_bus_dev_t {
can_message_t* next_can_message();
void push_new_can_message(const can_message_t& can_msg);
bool has_can_message() const;
-}
-
+};
/**
* @brief Object used to handle decoding and manage event queue to be pushed.
@@ -112,11 +160,11 @@ class can_bus_t {
std::queue <openxc_VehicleMessage> vehicle_message_q_;
public:
+ int init_can_dev();
+ std::vector<std::string> read_conf();
+
void start_threads();
- void init_can_dev(std::ifstream& conf_file);
- std::vector<std::string> read_conf()
-
int send_can_message(can_message_t can_msg);
openxc_VehicleMessage& next_vehicle_message();
@@ -124,57 +172,6 @@ class can_bus_t {
bool has_vehicle_message() const;
};
-/* A compact representation of a single CAN message, meant to be used in in/out
- * buffers.
- *
- * id - The ID of the message.
- * format - the format of the message's ID.
- * data - The message's data field.
- * length - the length of the data array (max 8).
-struct CanMessage {
- uint32_t id;
- CanMessageFormat format;
- uint8_t data[CAN_MESSAGE_SIZE];
- uint8_t length;
-};
-typedef struct CanMessage CanMessage;
-*/
-class can_message_t {
- private:
- afb_binding_interface interface_;
- uint32_t id_;
- CanMessageFormat format_;
- uint8_t data_[CAN_MESSAGE_SIZE];
- uint8_t length_;
-
- public:
- uint32_t get_id() const;
- int get_format() const;
- uint8_t get_data() const;
- uint8_t get_lenght() const;
-
- void set_id(uint32_t id);
- void set_format(CanMessageFormat format);
- void set_data(uint8_t data);
- void set_lenght(uint8_t length);
-
- void convert_from_canfd_frame(canfd_frame frame);
- canfd_frame convert_to_canfd_frame();
-};
-
-QUEUE_DECLARE(can_message_t, 8);
-
-/* Public: The ID format for a CAN message.
- *
- * STANDARD - standard 11-bit CAN arbitration ID.
- * EXTENDED - an extended frame, with a 29-bit arbitration ID.
- */
-enum CanMessageFormat {
- STANDARD,
- EXTENDED,
-};
-typedef enum CanMessageFormat CanMessageFormat;
-
/* Public: A state encoded (SED) signal's mapping from numerical values to
* OpenXC state names.
*
@@ -346,17 +343,11 @@ typedef void (*CommandHandler)(const char* name, openxc_DynamicField* value,
* genericName - The name of the command.
* handler - An function to process the received command's data and perform some
* action.
+ */
typedef struct {
const char* genericName;
CommandHandler handler;
} CanCommand;
- */
-
-class CanCommand_c {
- private:
- const char* genericName;
- CommandHandler handler;
-};
/* Pre initialize actions made before CAN bus initialization
*