diff --git a/linux/acs/RwPollingTask.cpp b/linux/acs/RwPollingTask.cpp index d118ba69..39bc28b6 100644 --- a/linux/acs/RwPollingTask.cpp +++ b/linux/acs/RwPollingTask.cpp @@ -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;