Change way signaling end of queue for can messages
authorRomain Forlot <romain.forlot@iot.bzh>
Thu, 16 Feb 2017 17:57:10 +0000 (17:57 +0000)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 16 Feb 2017 17:57:10 +0000 (17:57 +0000)
and vehicle messages

Change-Id: I98fbc5995ff08facc5430cce92830aa878dc3dc9
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
src/can-utils.cpp
src/can-utils.h

index 4646a34..e978cae 100644 (file)
@@ -185,8 +185,15 @@ can_message_t* can_bus_t::next_can_message()
                can_message_q_.pop()
                return &can_msg;
        }
+       has_can_message_ = false;
+}
 
-       return nullptr;
+/**
+ * @return has_can_message_ bool
+ */
+bool can_bus_t::has_can_message() const
+{
+       return has_can_message_;
 }
 
 void can_bus_t::insert_new_can_message(can_message_t &can_msg)
@@ -209,13 +216,23 @@ openxc_VehicleMessage* can_bus_t::next_vehicle_message()
                return &v_msg;
        }
 
-       return nullptr;
+       has_vehicle_message_ = false;
 }
 
 void can_bus_t::insert_new_vehicle_message(openxc_VehicleMessage *v_msg)
 {
        vehicle_message_q_.push(v_msg);
+       has_vehicle_message_ = true;
 }
+
+/*
+ * Return has_can_message_ bool
+ */
+bool can_bus_t::has_vehicle_message() const
+{
+       return has_vehicle_message_;
+}
+
 /********************************************************************************
 *
 *              CanMessage method implementation
index 71c0fcc..1676392 100644 (file)
@@ -115,9 +115,11 @@ class can_bus_t {
 
                can_message_t* next_can_message();
                void insert_new_can_message(can_message_t &can_msg);
+               bool has_can_message_;
 
                openxc_VehicleMessage* next_vehicle_message();
                void insert_new_vehicle_message(openxc_VehicleMessage *v_msg);
+               bool has_vehicle_message_;
 };
 
 /* A compact representation of a single CAN message, meant to be used in in/out