From b8f53788615395ca132a663d69989b2ca67abd98 Mon Sep 17 00:00:00 2001
From: Sergi Hernandez <shernand@iri.upc.edu>
Date: Mon, 22 Feb 2021 15:16:53 +0100
Subject: [PATCH] Solved a bug: the timestamp value was not updated. The
 get_last_timestamp() function has been moved to the protected section.

---
 include/model_car_driver_base.h | 2 +-
 src/model_car_driver_base.cpp   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/model_car_driver_base.h b/include/model_car_driver_base.h
index 5688226..b42af69 100644
--- a/include/model_car_driver_base.h
+++ b/include/model_car_driver_base.h
@@ -66,13 +66,13 @@ class CModelCarDriverBase
     void process_data(THeader & header, TDataUnion & data_union, TCRCUnion & crc_union);
     virtual void process_data_frame(uint8_t id,TDataUnion data_union)=0;
     uint16_t fletcher16(uint8_t *data, uint8_t bytes);
+    uint32_t get_last_timestamp(void);
   public:
     CModelCarDriverBase(std::string name, ARDUINO_ID arduino_id);
     void open(void);
     uint8_t get_id(void);
     void set_rx_timeout(double time_s);
     double get_rx_timeout(void);
-    uint32_t get_last_timestamp(void);
     void close(void);
     std::string get_new_data_event_id(void);
     virtual ~CModelCarDriverBase(void);
diff --git a/src/model_car_driver_base.cpp b/src/model_car_driver_base.cpp
index e089b00..c914a7b 100644
--- a/src/model_car_driver_base.cpp
+++ b/src/model_car_driver_base.cpp
@@ -320,6 +320,7 @@ void CModelCarDriverBase::process_data(THeader & header, TDataUnion & data_union
         break;
       default:
         this->data_mutex.enter();
+        this->timestamp=header.time_stamp;
         this->process_data_frame(header.id, data_union);
         this->data_mutex.exit();
       break;
-- 
GitLab