From 271830422aa2e05cb627357872ee28f6f2808ab9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Apr 2023 17:12:31 +0200 Subject: [PATCH 1/3] add a way to detect off devices --- linux/acs/SusPolling.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/linux/acs/SusPolling.cpp b/linux/acs/SusPolling.cpp index aea92ffe..7dfb93e5 100644 --- a/linux/acs/SusPolling.cpp +++ b/linux/acs/SusPolling.cpp @@ -95,11 +95,14 @@ ReturnValue_t SusPolling::readReceivedMessage(CookieIF* cookie, uint8_t** buffer if (susIdx < 0) { return FAILED; } + if(susDevs[susIdx].replyResult != returnvalue::OK) { + return susDevs[susIdx].replyResult; + } MutexGuard mg(ipcLock); std::memcpy(&susDevs[susIdx].readerReply, &susDevs[susIdx].ownReply, sizeof(acs::SusReply)); *buffer = reinterpret_cast(&susDevs[susIdx].readerReply); *size = sizeof(acs::SusReply); - return OK; + return susDevs[susIdx].replyResult; } ReturnValue_t SusPolling::handleSusPolling() { @@ -164,11 +167,18 @@ ReturnValue_t SusPolling::handleSusPolling() { } MutexGuard mg(ipcLock); susDevs[idx].ownReply.tempRaw = ((rawReply[0] & 0x0f) << 8) | rawReply[1]; - for (unsigned chIdx = 0; chIdx < 6; chIdx++) { - susDevs[idx].ownReply.channelsRaw[chIdx] = - (rawReply[chIdx * 2 + 2] << 8) | rawReply[chIdx * 2 + 3]; + // Reply is all ones. Sensor is probably off or faulty when + // it should not be. + if(susDevs[idx].ownReply.tempRaw == 0x0fff) { + susDevs[idx].replyResult = returnvalue::FAILED; + } else { + susDevs[idx].replyResult = returnvalue::OK; + for (unsigned chIdx = 0; chIdx < 6; chIdx++) { + susDevs[idx].ownReply.channelsRaw[chIdx] = + (rawReply[chIdx * 2 + 2] << 8) | rawReply[chIdx * 2 + 3]; + } + susDevs[idx].ownReply.dataWasSet = true; } - susDevs[idx].ownReply.dataWasSet = true; } } return OK; -- 2.43.0 From b82f19ea505a2ea0d2c0ccc8bb14a2ee38bd810b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Apr 2023 17:18:12 +0200 Subject: [PATCH 2/3] reset reply result on mode change --- linux/acs/SusPolling.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/acs/SusPolling.cpp b/linux/acs/SusPolling.cpp index 7dfb93e5..0e09b02a 100644 --- a/linux/acs/SusPolling.cpp +++ b/linux/acs/SusPolling.cpp @@ -73,6 +73,7 @@ ReturnValue_t SusPolling::sendMessage(CookieIF* cookie, const uint8_t* sendData, susDevs[susIdx].ownReply.cfgWasSet = false; susDevs[susIdx].ownReply.dataWasSet = false; } + susDevs[susIdx].replyResult = returnvalue::FAILED; susDevs[susIdx].mode = susReq->mode; } if (state == InternalState::IDLE) { -- 2.43.0 From 4e9a074e820dae0f3bb81003e43f31fb46828dcf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Apr 2023 17:19:16 +0200 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5620ec22..dc5bfc7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ will consitute of a breaking change warranting a new major release: to a regression, so commanding the SDC state machine externally lead to confusing results. - Fixed a bug in persistent TM store, where the active file was not reset of SD card switches. SD card switch from 0 to 1 and vice-versa works without errors from persistent TM stores now. +- Add a way for the SUS polling to detect broken or off devices by checking the retrieved + temperature for the all-ones value (0x0fff). ## Changed -- 2.43.0