summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-02-14 20:02:08 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-02-14 20:02:08 +0100
commit2d6451afed42c84fae3c056304af3b9dfb293ce9 (patch)
tree2e4b589e02f35a44af65ed43a30e1c1f71e0ebf9 /src
parentb162907a78a1846d99f0951a052d6d721eb96f08 (diff)
Add VehicleMessage queue methods
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r--src/can-utils.cpp24
-rw-r--r--src/can-utils.h3
2 files changed, 26 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
diff --git a/src/can-utils.h b/src/can-utils.h
index a760af1..e0f6c64 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