From 4701b1ef76b0fd6f129e6772dd597a85d2e59069 Mon Sep 17 00:00:00 2001
From: Carl Philipp Klemm <philipp@uvos.xyz>
Date: Tue, 7 May 2024 14:25:18 +0200
Subject: [PATCH] improve psu startup checks

---
 expirament.cpp | 10 ++++++++--
 test.cpp       | 11 +++++++++--
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/expirament.cpp b/expirament.cpp
index 538967b..5689cd8 100644
--- a/expirament.cpp
+++ b/expirament.cpp
@@ -58,9 +58,15 @@ bool Expirament::preparePsu()
 	std::this_thread::sleep_for(std::chrono::seconds(2));
 
 	ret = psu->getStatus(status);
-	if(!ret || status.curent_limited)
+	if(!ret)
+	{
+		Log(Log::ERROR)<<"Unable to read psu state, abort";
+		psu->setEnabled(false);
+		return false;
+	}
+	else if(status.curent_limited)
 	{
-		Log(Log::ERROR)<<"Psu is overcurrent, abort";
+		Log(Log::ERROR)<<"Psu is overcurrent at "<<status.current<<" abort";
 		psu->setEnabled(false);
 		return false;
 	}
diff --git a/test.cpp b/test.cpp
index 51fd203..f9b4cfc 100644
--- a/test.cpp
+++ b/test.cpp
@@ -53,9 +53,16 @@ bool preparePsu(Vcpps* psu, float voltage, float current)
 	std::this_thread::sleep_for(std::chrono::seconds(2));
 
 	ret = psu->getStatus(status);
-	if(!ret || status.curent_limited)
+	ret = psu->getStatus(status);
+	if(!ret)
+	{
+		Log(Log::ERROR)<<"Unable to read psu state, abort";
+		psu->setEnabled(false);
+		return false;
+	}
+	else if(status.curent_limited)
 	{
-		Log(Log::ERROR, true, false)<<"Psu is overcurrent, abort";
+		Log(Log::ERROR)<<"Psu is overcurrent at "<<status.current<<" abort";
 		psu->setEnabled(false);
 		return false;
 	}
-- 
GitLab