add a way to detect off or broken SUS devices #587

Merged
meggert merged 3 commits from bugfix_sus_fdir into develop 2023-04-11 17:24:02 +02:00
2 changed files with 18 additions and 5 deletions

View File

@ -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. 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. - 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. 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 ## Changed

View File

@ -73,6 +73,7 @@ ReturnValue_t SusPolling::sendMessage(CookieIF* cookie, const uint8_t* sendData,
susDevs[susIdx].ownReply.cfgWasSet = false; susDevs[susIdx].ownReply.cfgWasSet = false;
susDevs[susIdx].ownReply.dataWasSet = false; susDevs[susIdx].ownReply.dataWasSet = false;
} }
susDevs[susIdx].replyResult = returnvalue::FAILED;
susDevs[susIdx].mode = susReq->mode; susDevs[susIdx].mode = susReq->mode;
} }
if (state == InternalState::IDLE) { if (state == InternalState::IDLE) {
@ -95,11 +96,14 @@ ReturnValue_t SusPolling::readReceivedMessage(CookieIF* cookie, uint8_t** buffer
if (susIdx < 0) { if (susIdx < 0) {
return FAILED; return FAILED;
} }
if(susDevs[susIdx].replyResult != returnvalue::OK) {
return susDevs[susIdx].replyResult;
}
MutexGuard mg(ipcLock); MutexGuard mg(ipcLock);
std::memcpy(&susDevs[susIdx].readerReply, &susDevs[susIdx].ownReply, sizeof(acs::SusReply)); std::memcpy(&susDevs[susIdx].readerReply, &susDevs[susIdx].ownReply, sizeof(acs::SusReply));
*buffer = reinterpret_cast<uint8_t*>(&susDevs[susIdx].readerReply); *buffer = reinterpret_cast<uint8_t*>(&susDevs[susIdx].readerReply);
*size = sizeof(acs::SusReply); *size = sizeof(acs::SusReply);
return OK; return susDevs[susIdx].replyResult;
} }
ReturnValue_t SusPolling::handleSusPolling() { ReturnValue_t SusPolling::handleSusPolling() {
@ -164,11 +168,18 @@ ReturnValue_t SusPolling::handleSusPolling() {
} }
MutexGuard mg(ipcLock); MutexGuard mg(ipcLock);
susDevs[idx].ownReply.tempRaw = ((rawReply[0] & 0x0f) << 8) | rawReply[1]; susDevs[idx].ownReply.tempRaw = ((rawReply[0] & 0x0f) << 8) | rawReply[1];
for (unsigned chIdx = 0; chIdx < 6; chIdx++) { // Reply is all ones. Sensor is probably off or faulty when
susDevs[idx].ownReply.channelsRaw[chIdx] = // it should not be.
(rawReply[chIdx * 2 + 2] << 8) | rawReply[chIdx * 2 + 3]; 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; return OK;