diff options
-rw-r--r-- | src/can-utils.cpp | 24 | ||||
-rw-r--r-- | src/can-utils.h | 3 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/can-utils.cpp b/src/can-utils.cpp index 09f49476..f10b9689 100644 --- a/src/can-utils.cpp +++ b/src/can-utils.cpp @@ -143,7 +143,7 @@ CanMessage_c* CanBus_c::next_can_message() return &can_msg; } - return NULL; + return nullptr; } void CanBus_c::insert_new_can_message(CanMessage_c *can_msg) @@ -151,6 +151,28 @@ void CanBus_c::insert_new_can_message(CanMessage_c *can_msg) can_message_q.push(can_msg); } +/* + * Get a VehicleMessage from vehicle_message_q and return it + * then point to the next VehicleMessage in queue. + * + * Return the next queue element or NULL if queue is empty. + */ +openxc_VehicleMessage* CanBus_c::next_vehicle_message() +{ + if(! vehicle_message_q.empty()) + { + openxc_VehicleMessage v_msg = vehicle_message_q.front(); + vehicle_message_q.pop() + return &v_msg; + } + + return nullptr; +} + +void CanBus_c::insert_new_vehicle_message(openxc_VehicleMessage *v_msg) +{ + vehicle_message_q.push(v_msg); +} /******************************************************************************** * * CanMessage method implementation diff --git a/src/can-utils.h b/src/can-utils.h index a760af14..e0f6c64f 100644 --- a/src/can-utils.h +++ b/src/can-utils.h @@ -112,6 +112,9 @@ class CanBus_c { CanMessage_c* next_can_message(); void insert_new_can_message(CanMessage_c *can_msg); + + openxc_VehicleMessage* next_vehicle_message(); + void insert_new_vehicle_message(openxc_VehicleMessage *v_msg); }; /* A compact representation of a single CAN message, meant to be used in in/out |