From 23da22efcfd4ae5a6074e96c56f7039bd07b9c47 Mon Sep 17 00:00:00 2001
From: Matteo Pignataro <matteo.pignataro@skywarder.eu>
Date: Tue, 12 Sep 2023 06:57:56 +0000
Subject: [PATCH] [MAX3185] Removed from self test the thermocouple check
 feature and added new method to do so

---
 src/shared/sensors/MAX31855/MAX31855.cpp | 4 +++-
 src/shared/sensors/MAX31855/MAX31855.h   | 4 +++-
 src/shared/sensors/MAX31856/MAX31856.cpp | 4 +++-
 src/shared/sensors/MAX31856/MAX31856.h   | 4 +++-
 src/tests/sensors/test-max31855.cpp      | 4 ++--
 src/tests/sensors/test-max31856.cpp      | 2 +-
 6 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/shared/sensors/MAX31855/MAX31855.cpp b/src/shared/sensors/MAX31855/MAX31855.cpp
index f79eec3a4..955f2fbdc 100644
--- a/src/shared/sensors/MAX31855/MAX31855.cpp
+++ b/src/shared/sensors/MAX31855/MAX31855.cpp
@@ -43,7 +43,9 @@ SPIBusConfig MAX31855::getDefaultSPIConfig()
 
 bool MAX31855::init() { return true; }
 
-bool MAX31855::selfTest()
+bool MAX31855::selfTest() { return true; }
+
+bool MAX31855::checkConnected()
 {
     uint16_t sample[2];
 
diff --git a/src/shared/sensors/MAX31855/MAX31855.h b/src/shared/sensors/MAX31855/MAX31855.h
index 62be42ab1..fcfcd412d 100644
--- a/src/shared/sensors/MAX31855/MAX31855.h
+++ b/src/shared/sensors/MAX31855/MAX31855.h
@@ -50,12 +50,14 @@ public:
 
     bool init();
 
+    bool selfTest();
+
     /**
      * @brief Checks whether the thermocouple is connected or not.
      *
      * @return True if the thermocouple is connected.
      */
-    bool selfTest();
+    bool checkConnected();
 
     /**
      * @brief Read the device internal temperature (cold junction).
diff --git a/src/shared/sensors/MAX31856/MAX31856.cpp b/src/shared/sensors/MAX31856/MAX31856.cpp
index ad1d54759..c10636068 100644
--- a/src/shared/sensors/MAX31856/MAX31856.cpp
+++ b/src/shared/sensors/MAX31856/MAX31856.cpp
@@ -58,7 +58,9 @@ bool MAX31856::init()
     return true;
 }
 
-bool MAX31856::selfTest()
+bool MAX31856::selfTest() { return true; }
+
+bool MAX31856::checkConnected()
 {
     SPITransaction spi{slave};
 
diff --git a/src/shared/sensors/MAX31856/MAX31856.h b/src/shared/sensors/MAX31856/MAX31856.h
index 7e04e481a..7e329e282 100644
--- a/src/shared/sensors/MAX31856/MAX31856.h
+++ b/src/shared/sensors/MAX31856/MAX31856.h
@@ -69,12 +69,14 @@ public:
 
     bool init();
 
+    bool selfTest();
+
     /**
      * @brief Checks whether the thermocouple is connected or not.
      *
      * @return True if the thermocouple is connected.
      */
-    bool selfTest();
+    bool checkConnected();
 
     void setThermocoupleType(ThermocoupleType type);
 
diff --git a/src/tests/sensors/test-max31855.cpp b/src/tests/sensors/test-max31855.cpp
index 00171ebab..71e9022d4 100644
--- a/src/tests/sensors/test-max31855.cpp
+++ b/src/tests/sensors/test-max31855.cpp
@@ -56,9 +56,9 @@ int main()
 
     printf("Starting process verification!\n");
 
-    if (!sensor.selfTest())
+    if (!sensor.checkConnected())
     {
-        printf("Sensor self test failed!\n");
+        printf("Sensor not connected!\n");
     }
 
     while (true)
diff --git a/src/tests/sensors/test-max31856.cpp b/src/tests/sensors/test-max31856.cpp
index 6d4a3edd6..11908d34b 100644
--- a/src/tests/sensors/test-max31856.cpp
+++ b/src/tests/sensors/test-max31856.cpp
@@ -51,7 +51,7 @@ int main()
 
     sensor.init();
 
-    if (!sensor.selfTest())
+    if (!sensor.checkConnected())
     {
         printf("The thermocouple is not connected\n");
     }
-- 
GitLab