conitniue sus polling
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-03-01 10:47:57 +01:00
parent 11f476878d
commit 26aeb88d84
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -18,7 +18,21 @@ ReturnValue_t SusPolling::performOperation(uint8_t operationCode) {
state = InternalState::IDLE; state = InternalState::IDLE;
ipcLock->unlockMutex(); ipcLock->unlockMutex();
semaphore->acquire(); semaphore->acquire();
// TODO: Perform SUS polling here. for(auto& susDev: susDevs) {
acs::SimpleSensorMode mode;
bool doPerformStartup = false;
{
MutexGuard mg(ipcLock);
mode = susDev.mode;
doPerformStartup = susDev.performStartup;
}
if (mode == acs::SimpleSensorMode::NORMAL) {
if(doPerformStartup) {
// Startup handling.
}
// Regular sensor polling.
}
}
} }
return OK; return OK;
} }
@ -51,7 +65,14 @@ ReturnValue_t SusPolling::sendMessage(CookieIF* cookie, const uint8_t* sendData,
return FAILED; return FAILED;
} }
const auto* susReq = reinterpret_cast<const acs::SusRequest*>(sendData); const auto* susReq = reinterpret_cast<const acs::SusRequest*>(sendData);
MutexGuard mg(ipcLock);
if (susDevs[susIdx].mode != susReq->mode) { if (susDevs[susIdx].mode != susReq->mode) {
if(susReq->mode == acs::SimpleSensorMode::NORMAL) {
susDevs[susIdx].performStartup = true;
} else {
susDevs[susIdx].ownReply.dataWasSet = false;
}
susDevs[susIdx].mode = susReq->mode;
} }
return OK; return OK;
} }
@ -61,6 +82,18 @@ ReturnValue_t SusPolling::getSendSuccess(CookieIF* cookie) { return OK; }
ReturnValue_t SusPolling::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { return OK; } ReturnValue_t SusPolling::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { return OK; }
ReturnValue_t SusPolling::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { ReturnValue_t SusPolling::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
auto* spiCookie = dynamic_cast<SpiCookie*>(cookie);
if (spiCookie == nullptr) {
return FAILED;
}
int susIdx = addressToIndex(spiCookie->getSpiAddress());
if (susIdx < 0) {
return FAILED;
}
MutexGuard mg(ipcLock);
std::memcpy(&susDevs[susIdx].readerReply, &susDevs[susIdx].ownReply, sizeof(acs::SusReply));
*buffer = reinterpret_cast<uint8_t*>(&susDevs[susIdx].readerReply);
*size = sizeof(acs::SusReply);
return OK; return OK;
} }