Update FSFW #13

Merged
meierj merged 26 commits from mueller/update-fsfw into eive/develop 2021-09-17 07:55:59 +02:00
Showing only changes of commit 0df8d35802 - Show all commits

View File

@ -158,7 +158,7 @@ ReturnValue_t MgmRM3100Handler::scanForReply(const uint8_t *start,
size_t len, DeviceCommandId_t *foundId,
size_t *foundLen) {
/* For SPI, ID will always be the one of the last sent command. */
// For SPI, ID will always be the one of the last sent command
*foundId = this->getPendingCommand();
*foundLen = len;
return HasReturnvaluesIF::RETURN_OK;
@ -170,7 +170,7 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const
case(RM3100::CONFIGURE_CMM):
case(RM3100::CONFIGURE_CYCLE_COUNT):
case(RM3100::CONFIGURE_TMRC): {
/* We can only check whether write was successful with read operation. */
// We can only check whether write was successful with read operation
if(mode == _MODE_START_UP) {
commandExecuted = true;
}
@ -178,14 +178,14 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const
}
case(RM3100::READ_CMM): {
uint8_t cmmValue = packet[1];
/* We clear the seventh bit in any case
* because this one is zero sometimes for some reason */
// We clear the seventh bit in any case
// because this one is zero sometimes for some reason
bitutil::bitClear(&cmmValue, 6);
if(cmmValue == cmmRegValue and internalState == InternalState::READ_CMM) {
commandExecuted = true;
}
else {
/* Attempt reconfiguration. */
// Attempt reconfiguration
internalState = InternalState::CONFIGURE_CMM;
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
}
@ -194,13 +194,13 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const
case(RM3100::READ_TMRC): {
if(packet[1] == tmrcRegValue) {
commandExecuted = true;
/* Reading TMRC was commanded. Trigger event to inform ground. */
// Reading TMRC was commanded. Trigger event to inform ground
if(mode != _MODE_START_UP) {
triggerEvent(tmrcSet, tmrcRegValue, 0);
}
}
else {
/* Attempt reconfiguration. */
// Attempt reconfiguration
internalState = InternalState::STATE_CONFIGURE_TMRC;
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
}
@ -214,7 +214,7 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const
cycleCountZ != cycleCountRegValueZ) {
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
}
/* Reading TMRC was commanded. Trigger event to inform ground. */
// Reading TMRC was commanded. Trigger event to inform ground
if(mode != _MODE_START_UP) {
uint32_t eventParam1 = (cycleCountX << 16) | cycleCountY;
triggerEvent(cycleCountersSet, eventParam1, cycleCountZ);
@ -267,7 +267,7 @@ ReturnValue_t MgmRM3100Handler::handleCycleCommand(bool oneCycleValue,
return result;
}
/* Data sheet p.30 "while noise limits the useful upper range to ~400 cycle counts." */
// Data sheet p.30 "while noise limits the useful upper range to ~400 cycle counts."
if(command.cycleCountX > 450 ) {
return DeviceHandlerIF::INVALID_COMMAND_PARAMETER;
}
@ -336,13 +336,13 @@ void MgmRM3100Handler::setToGoToNormalMode(bool enable) {
}
ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) {
/* Analyze data here. The sensor generates 24 bit signed values so we need to do some bitshift
* trickery here to calculate the raw values first */
// Analyze data here. The sensor generates 24 bit signed values so we need to do some bitshift
// trickery here to calculate the raw values first
int32_t fieldStrengthRawX = ((packet[1] << 24) | (packet[2] << 16) | (packet[3] << 8)) >> 8;
int32_t fieldStrengthRawY = ((packet[4] << 24) | (packet[5] << 16) | (packet[6] << 8)) >> 8;
int32_t fieldStrengthRawZ = ((packet[7] << 24) | (packet[8] << 16) | (packet[3] << 8)) >> 8;
/* Now scale to physical value in microtesla */
// Now scale to physical value in microtesla
float fieldStrengthX = fieldStrengthRawX * scaleFactorX;
float fieldStrengthY = fieldStrengthRawY * scaleFactorX;
float fieldStrengthZ = fieldStrengthRawZ * scaleFactorX;
@ -358,7 +358,7 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) {
}
#endif
/* TODO: Sanity check on values */
// TODO: Sanity check on values?
PoolReadGuard readGuard(&primaryDataset);
if(readGuard.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
primaryDataset.fieldStrengthX = fieldStrengthX;