diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-02-14 20:02:08 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-02-14 20:02:08 +0100 |
commit | 2d6451afed42c84fae3c056304af3b9dfb293ce9 (patch) | |
tree | 2e4b589e02f35a44af65ed43a30e1c1f71e0ebf9 /src/can-utils.cpp | |
parent | b162907a78a1846d99f0951a052d6d721eb96f08 (diff) |
Add VehicleMessage queue methods
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/can-utils.cpp')
-rw-r--r-- | src/can-utils.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/can-utils.cpp b/src/can-utils.cpp index 09f4947..f10b968 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 |