a bit more thread safety
This commit is contained in:
parent
353b9bd322
commit
9960fc8ce7
@ -49,14 +49,13 @@ ReturnValue_t RwPollingTask::performOperation(uint8_t operationCode) {
|
||||
}
|
||||
acs::SimpleSensorMode currentMode;
|
||||
rws::SpecialRwRequest specialRequest;
|
||||
bool doSetSpeed;
|
||||
|
||||
for (unsigned idx = 0; idx < rwCookies.size(); idx++) {
|
||||
{
|
||||
MutexGuard mg(ipcLock);
|
||||
currentMode = rwRequests[idx].mode;
|
||||
specialRequest = rwRequests[idx].specialRequest;
|
||||
doSetSpeed = rwRequests[idx].setSpeed;
|
||||
skipSetSpeedReply[idx] = rwRequests[idx].setSpeed;
|
||||
}
|
||||
if (currentMode == acs::SimpleSensorMode::OFF) {
|
||||
skipCommandingForRw[idx] = true;
|
||||
@ -65,7 +64,7 @@ ReturnValue_t RwPollingTask::performOperation(uint8_t operationCode) {
|
||||
// No point in commanding that specific RW for the cycle.
|
||||
skipCommandingForRw[idx] = true;
|
||||
writeOneRwCmd(idx, fd);
|
||||
} else if (doSetSpeed) {
|
||||
} else if (skipSetSpeedReply[idx]) {
|
||||
prepareSetSpeedCmd(idx);
|
||||
if (writeOneRwCmd(idx, fd) != returnvalue::OK) {
|
||||
continue;
|
||||
@ -329,7 +328,7 @@ ReturnValue_t RwPollingTask::writeOneRwCmd(uint8_t rwIdx, int fd) {
|
||||
ReturnValue_t RwPollingTask::readAllRws(DeviceCommandId_t id) {
|
||||
// SPI dev will be opened in readNextReply on demand.
|
||||
for (unsigned idx = 0; idx < rwCookies.size(); idx++) {
|
||||
if (((id == rws::SET_SPEED) and !rwRequests[idx].setSpeed) or skipCommandingForRw[idx]) {
|
||||
if (((id == rws::SET_SPEED) and !skipSetSpeedReply[idx]) or skipCommandingForRw[idx]) {
|
||||
continue;
|
||||
}
|
||||
uint8_t* replyBuf;
|
||||
|
@ -47,6 +47,7 @@ class RwPollingTask : public SystemObject, public ExecutableObjectIF, public Dev
|
||||
const char* spiDev;
|
||||
GpioIF& gpioIF;
|
||||
std::array<bool, 4> skipCommandingForRw;
|
||||
std::array<bool, 4> skipSetSpeedReply;
|
||||
std::array<DeviceCommandId_t, 4> specialRequestIds;
|
||||
std::array<RwCookie*, 4> rwCookies;
|
||||
std::array<rws::RwRequest, 4> rwRequests{};
|
||||
|
Loading…
Reference in New Issue
Block a user