some more rtd tweaks
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-05-13 10:27:26 +02:00
parent 706e3d458b
commit f3b473ea99
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 29 additions and 20 deletions

View File

@ -362,7 +362,7 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
break; break;
} }
case (MAX31865::REQUEST_HIGH_THRESHOLD): { case (MAX31865::REQUEST_HIGH_THRESHOLD): {
uint16_t readHighThreshold = packet[1] << 8 | packet[2]; uint16_t readHighThreshold = (packet[1] << 8) | packet[2];
if (readHighThreshold != HIGH_THRESHOLD) { if (readHighThreshold != HIGH_THRESHOLD) {
#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
@ -381,11 +381,11 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
} }
case (MAX31865::REQUEST_RTD): { case (MAX31865::REQUEST_RTD): {
// first bit of LSB reply byte is the fault bit // first bit of LSB reply byte is the fault bit
uint8_t faultBit = packet[2] & 0b0000'0001; bool faultBit = packet[2] & 0b0000'0001;
if (resetFaultBit) { if (resetFaultBit) {
internalState = InternalState::CLEAR_FAULT_BYTE; internalState = InternalState::CLEAR_FAULT_BYTE;
resetFaultBit = false; resetFaultBit = false;
} else if (faultBit == 1) { } else if (shouldFaultStatusBeRequested(faultBit)) {
// Maybe we should attempt to restart it? // Maybe we should attempt to restart it?
internalState = InternalState::REQUEST_FAULT_BYTE; internalState = InternalState::REQUEST_FAULT_BYTE;
resetFaultBit = true; resetFaultBit = true;
@ -440,16 +440,17 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
break; break;
} }
case (MAX31865::REQUEST_FAULT_BYTE): { case (MAX31865::REQUEST_FAULT_BYTE): {
faultByte = packet[1]; currentFaultStatus = packet[1];
bool faultStatusChanged = (faultByte != lastFaultStatus); bool faultStatusChanged = (currentFaultStatus != lastFaultStatus);
// Spam protection // Spam protection
if (faultStatusChanged or ((faultByte == lastFaultStatus) and (sameFaultStatusCounter < 3))) { if (faultStatusChanged or
((currentFaultStatus == lastFaultStatus) and (sameFaultStatusCounter < 3))) {
// TODO: Think about triggering an event here // TODO: Think about triggering an event here
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex
<< this->getObjectId() << ": Fault byte is: 0b" << std::bitset<8>(faultByte) << this->getObjectId() << ": Fault byte is: 0b"
<< std::endl; << std::bitset<8>(currentFaultStatus) << std::endl;
#else #else
sif::printWarning( sif::printWarning(
"Max31865PT1000Handler::interpretDeviceReply: Fault byte" "Max31865PT1000Handler::interpretDeviceReply: Fault byte"
@ -463,7 +464,10 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
sameFaultStatusCounter++; sameFaultStatusCounter++;
} }
} }
lastFaultStatus = faultByte; if (faultStatusChanged) {
lastFaultStatus = currentFaultStatus;
}
PoolReadGuard pg(&sensorDataset); PoolReadGuard pg(&sensorDataset);
auto result = pg.getReadResult(); auto result = pg.getReadResult();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
@ -478,12 +482,12 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
} }
if (faultStatusChanged) { if (faultStatusChanged) {
sensorDataset.lastErrorByte.setValid(true); sensorDataset.lastErrorByte.setValid(true);
sensorDataset.lastErrorByte = faultByte; sensorDataset.lastErrorByte = lastFaultStatus;
} }
sensorDataset.errorByte.setValid(true); sensorDataset.errorByte.setValid(true);
sensorDataset.errorByte = faultByte; sensorDataset.errorByte = currentFaultStatus;
if (faultByte != 0) { if (currentFaultStatus != 0) {
sensorDataset.temperatureCelcius.setValid(false); sensorDataset.temperatureCelcius.setValid(false);
} }
break; break;
@ -494,11 +498,8 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
void Max31865PT1000Handler::debugInterface(uint8_t positionTracker, object_id_t objectId,
uint32_t parameter) {}
uint32_t Max31865PT1000Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { uint32_t Max31865PT1000Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
return 25000; return 5000;
} }
ReturnValue_t Max31865PT1000Handler::getSwitches(const uint8_t **switches, ReturnValue_t Max31865PT1000Handler::getSwitches(const uint8_t **switches,
@ -524,6 +525,9 @@ void Max31865PT1000Handler::setInstantNormal(bool instantNormal) {
void Max31865PT1000Handler::modeChanged() { void Max31865PT1000Handler::modeChanged() {
if (mode == MODE_OFF) { if (mode == MODE_OFF) {
lastFaultStatus = 0;
currentFaultStatus = 0;
sameFaultStatusCounter = 0;
internalState = InternalState::NONE; internalState = InternalState::NONE;
} }
} }
@ -534,3 +538,10 @@ void Max31865PT1000Handler::setDeviceInfo(uint8_t idx, std::string locString_) {
} }
void Max31865PT1000Handler::setDebugMode(bool enable) { this->debugMode = enable; } void Max31865PT1000Handler::setDebugMode(bool enable) { this->debugMode = enable; }
bool Max31865PT1000Handler::shouldFaultStatusBeRequested(bool faultBit) {
if ((sameFaultStatusCounter < 3) and faultBit) {
return true;
}
return false;
}

View File

@ -77,12 +77,10 @@ class Max31865PT1000Handler : public DeviceHandlerBase {
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override;
void debugInterface(uint8_t positionTracker = 0, object_id_t objectId = 0,
uint32_t parameter = 0) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override; LocalDataPoolManager &poolManager) override;
void modeChanged() override; void modeChanged() override;
bool shouldFaultStatusBeRequested(bool faultBit);
private: private:
uint8_t switchId = 0; uint8_t switchId = 0;
@ -110,10 +108,10 @@ class Max31865PT1000Handler : public DeviceHandlerBase {
bool resetFaultBit = false; bool resetFaultBit = false;
dur_millis_t startTime = 0; dur_millis_t startTime = 0;
uint8_t currentCfg = 0; uint8_t currentCfg = 0;
uint8_t currentFaultStatus = 0;
uint8_t lastFaultStatus = 0; uint8_t lastFaultStatus = 0;
uint16_t sameFaultStatusCounter = 0; uint16_t sameFaultStatusCounter = 0;
std::string locString; std::string locString;
uint8_t faultByte = 0;
uint8_t deviceIdx = 0; uint8_t deviceIdx = 0;
std::array<uint8_t, 3> commandBuffer{0}; std::array<uint8_t, 3> commandBuffer{0};