From 01bf5f11b2ebd98c6568fac75b6e40a80280b3eb Mon Sep 17 00:00:00 2001
From: Emilio Corigliano <emilio.corigliano@skywarder.eu>
Date: Thu, 3 Oct 2024 18:45:46 +0200
Subject: [PATCH] [HIL] Fixed getSampleCounter in Main, Payload and Motor

simulationPeriod was used in ms while ts and tsSensorData was used in ns (i'm retarded lol)
---
 src/boards/Main/Sensors/HILSensors.h    | 5 ++++-
 src/boards/Motor/Sensors/HILSensors.h   | 5 ++++-
 src/boards/Payload/Sensors/HILSensors.h | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/boards/Main/Sensors/HILSensors.h b/src/boards/Main/Sensors/HILSensors.h
index 4b5d478a3..09fa66912 100644
--- a/src/boards/Main/Sensors/HILSensors.h
+++ b/src/boards/Main/Sensors/HILSensors.h
@@ -101,7 +101,10 @@ private:
     {
         auto ts           = miosix::getTime();
         auto tsSensorData = getModule<MainHIL>()->getTimestampSimulatorData();
-        auto simulationPeriod = getModule<MainHIL>()->getSimulationPeriod();
+        long long simulationPeriod =
+            static_cast<long long>(
+                getModule<MainHIL>()->getSimulationPeriod()) *
+            1e6;
 
         assert(ts >= tsSensorData &&
                "Actual timestamp is lesser then the packet timestamp");
diff --git a/src/boards/Motor/Sensors/HILSensors.h b/src/boards/Motor/Sensors/HILSensors.h
index 25d964507..ac16b6482 100644
--- a/src/boards/Motor/Sensors/HILSensors.h
+++ b/src/boards/Motor/Sensors/HILSensors.h
@@ -57,7 +57,10 @@ private:
     {
         auto ts           = miosix::getTime();
         auto tsSensorData = getModule<MotorHIL>()->getTimestampSimulatorData();
-        auto simulationPeriod = getModule<MotorHIL>()->getSimulationPeriod();
+        long long simulationPeriod =
+            static_cast<long long>(
+                getModule<MotorHIL>()->getSimulationPeriod()) *
+            1e6;
 
         assert(ts >= tsSensorData &&
                "Actual timestamp is lesser then the packet timestamp");
diff --git a/src/boards/Payload/Sensors/HILSensors.h b/src/boards/Payload/Sensors/HILSensors.h
index 46b2dae87..b2d39e8c8 100644
--- a/src/boards/Payload/Sensors/HILSensors.h
+++ b/src/boards/Payload/Sensors/HILSensors.h
@@ -80,7 +80,10 @@ private:
         auto ts = miosix::getTime();
         auto tsSensorData =
             getModule<PayloadHIL>()->getTimestampSimulatorData();
-        auto simulationPeriod = getModule<PayloadHIL>()->getSimulationPeriod();
+        long long simulationPeriod =
+            static_cast<long long>(
+                getModule<PayloadHIL>()->getSimulationPeriod()) *
+            1e6;
 
         assert(ts >= tsSensorData &&
                "Actual timestamp is lesser then the packet timestamp");
-- 
GitLab