add some thread safety
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-04-07 17:10:30 +02:00
parent 014ac8b8c2
commit 353b9bd322
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -47,15 +47,25 @@ ReturnValue_t RwPollingTask::performOperation(uint8_t operationCode) {
if (result != returnvalue::OK) {
continue;
}
acs::SimpleSensorMode currentMode;
rws::SpecialRwRequest specialRequest;
bool doSetSpeed;
for (unsigned idx = 0; idx < rwCookies.size(); idx++) {
if (rwRequests[idx].mode == acs::SimpleSensorMode::OFF) {
{
MutexGuard mg(ipcLock);
currentMode = rwRequests[idx].mode;
specialRequest = rwRequests[idx].specialRequest;
doSetSpeed = rwRequests[idx].setSpeed;
}
if (currentMode == acs::SimpleSensorMode::OFF) {
skipCommandingForRw[idx] = true;
} else if (rwRequests[idx].specialRequest == rws::SpecialRwRequest::RESET_MCU) {
} else if (specialRequest == rws::SpecialRwRequest::RESET_MCU) {
prepareSimpleCommand(rws::RESET_MCU);
// No point in commanding that specific RW for the cycle.
skipCommandingForRw[idx] = true;
writeOneRwCmd(idx, fd);
} else if (rwRequests[idx].setSpeed) {
} else if (doSetSpeed) {
prepareSetSpeedCmd(idx);
if (writeOneRwCmd(idx, fd) != returnvalue::OK) {
continue;