|
@@ -387,7 +387,6 @@ void UartTxTask (void* argument) {
|
|
|
case spSetPositonY:
|
|
|
WriteDataToBuffer (outputDataBuffer, &outputDataBufferPos, &data.values.flaotValues.value[0], sizeof (float));
|
|
|
break;
|
|
|
- break;
|
|
|
default: continue; break;
|
|
|
}
|
|
|
|
|
@@ -412,43 +411,45 @@ void UartTxTask (void* argument) {
|
|
|
slaveLastSeen[boardNumber] = 0;
|
|
|
switch (frameData.frameHeader.frameCommand) {
|
|
|
case spGetElectricalMeasurments:
|
|
|
- osMutexAcquire (resMeasurementsMutex, osWaitForever);
|
|
|
- RESMeasurements* resMeas = &resMeasurements[boardNumber];
|
|
|
- inputDataBufferPos = 0;
|
|
|
- ReadMeasSetFromBuffer (frameData.dataBuffer, &inputDataBufferPos, resMeas->voltageRMS);
|
|
|
- ReadMeasSetFromBuffer (frameData.dataBuffer, &inputDataBufferPos, resMeas->voltagePeak);
|
|
|
- ReadMeasSetFromBuffer (frameData.dataBuffer, &inputDataBufferPos, resMeas->currentRMS);
|
|
|
- ReadMeasSetFromBuffer (frameData.dataBuffer, &inputDataBufferPos, resMeas->currentPeak);
|
|
|
- ReadMeasSetFromBuffer (frameData.dataBuffer, &inputDataBufferPos, resMeas->power);
|
|
|
- osMutexRelease (resMeasurementsMutex);
|
|
|
+ if (osMutexAcquire (resMeasurementsMutex, osWaitForever) == osOK) {
|
|
|
+ RESMeasurements* resMeas = &resMeasurements[boardNumber];
|
|
|
+ inputDataBufferPos = 0;
|
|
|
+ ReadMeasSetFromBuffer (frameData.dataBuffer, &inputDataBufferPos, resMeas->voltageRMS);
|
|
|
+ ReadMeasSetFromBuffer (frameData.dataBuffer, &inputDataBufferPos, resMeas->voltagePeak);
|
|
|
+ ReadMeasSetFromBuffer (frameData.dataBuffer, &inputDataBufferPos, resMeas->currentRMS);
|
|
|
+ ReadMeasSetFromBuffer (frameData.dataBuffer, &inputDataBufferPos, resMeas->currentPeak);
|
|
|
+ ReadMeasSetFromBuffer (frameData.dataBuffer, &inputDataBufferPos, resMeas->power);
|
|
|
+ osMutexRelease (resMeasurementsMutex);
|
|
|
+ }
|
|
|
break;
|
|
|
case spGetSensorMeasurments:
|
|
|
- osMutexAcquire (sensorsInfoMutex, osWaitForever);
|
|
|
- inputDataBufferPos = 0;
|
|
|
- SesnorsInfo* sensors = &sensorsInfo[boardNumber];
|
|
|
- ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->pvTemperature[0]);
|
|
|
- ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->pvTemperature[1]);
|
|
|
- ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->fanVoltage);
|
|
|
- ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->pvEncoderX);
|
|
|
- ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->pvEncoderY);
|
|
|
- ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorXStatus);
|
|
|
- ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorYStatus);
|
|
|
- ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorXAveCurrent);
|
|
|
- ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorYAveCurrent);
|
|
|
- ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorXPeakCurrent);
|
|
|
- ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorYPeakCurrent);
|
|
|
- ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitXSwitchUp);
|
|
|
- ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitXSwitchDown);
|
|
|
- ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitXSwitchCenter);
|
|
|
- ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitYSwitchUp);
|
|
|
- ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitYSwitchDown);
|
|
|
- ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitYSwitchCenter);
|
|
|
- ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->powerSupplyFailMask);
|
|
|
- ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->currentXPosition);
|
|
|
- ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->currentYPosition);
|
|
|
- ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->positionXWeak);
|
|
|
- ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->positionYWeak);
|
|
|
- osMutexRelease (sensorsInfoMutex);
|
|
|
+ if (osMutexAcquire (sensorsInfoMutex, osWaitForever) == osOK) {
|
|
|
+ inputDataBufferPos = 0;
|
|
|
+ SesnorsInfo* sensors = &sensorsInfo[boardNumber];
|
|
|
+ ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->pvTemperature[0]);
|
|
|
+ ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->pvTemperature[1]);
|
|
|
+ ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->fanVoltage);
|
|
|
+ ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->pvEncoderX);
|
|
|
+ ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->pvEncoderY);
|
|
|
+ ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorXStatus);
|
|
|
+ ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorYStatus);
|
|
|
+ ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorXAveCurrent);
|
|
|
+ ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorYAveCurrent);
|
|
|
+ ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorXPeakCurrent);
|
|
|
+ ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->motorYPeakCurrent);
|
|
|
+ ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitXSwitchUp);
|
|
|
+ ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitXSwitchDown);
|
|
|
+ ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitXSwitchCenter);
|
|
|
+ ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitYSwitchUp);
|
|
|
+ ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitYSwitchDown);
|
|
|
+ ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->limitYSwitchCenter);
|
|
|
+ ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->powerSupplyFailMask);
|
|
|
+ ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->currentXPosition);
|
|
|
+ ReadFloatFromBuffer (frameData.dataBuffer, &inputDataBufferPos, &sensors->currentYPosition);
|
|
|
+ ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->positionXWeak);
|
|
|
+ ReadByteFromBufer (frameData.dataBuffer, &inputDataBufferPos, &sensors->positionYWeak);
|
|
|
+ osMutexRelease (sensorsInfoMutex);
|
|
|
+ }
|
|
|
break;
|
|
|
default: break;
|
|
|
}
|