some more rtd tweaks
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
parent
706e3d458b
commit
f3b473ea99
@ -362,7 +362,7 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
break;
|
||||
}
|
||||
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 FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
@ -381,11 +381,11 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
}
|
||||
case (MAX31865::REQUEST_RTD): {
|
||||
// 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) {
|
||||
internalState = InternalState::CLEAR_FAULT_BYTE;
|
||||
resetFaultBit = false;
|
||||
} else if (faultBit == 1) {
|
||||
} else if (shouldFaultStatusBeRequested(faultBit)) {
|
||||
// Maybe we should attempt to restart it?
|
||||
internalState = InternalState::REQUEST_FAULT_BYTE;
|
||||
resetFaultBit = true;
|
||||
@ -440,16 +440,17 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
break;
|
||||
}
|
||||
case (MAX31865::REQUEST_FAULT_BYTE): {
|
||||
faultByte = packet[1];
|
||||
bool faultStatusChanged = (faultByte != lastFaultStatus);
|
||||
currentFaultStatus = packet[1];
|
||||
bool faultStatusChanged = (currentFaultStatus != lastFaultStatus);
|
||||
// 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
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex
|
||||
<< this->getObjectId() << ": Fault byte is: 0b" << std::bitset<8>(faultByte)
|
||||
<< std::endl;
|
||||
<< this->getObjectId() << ": Fault byte is: 0b"
|
||||
<< std::bitset<8>(currentFaultStatus) << std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"Max31865PT1000Handler::interpretDeviceReply: Fault byte"
|
||||
@ -463,7 +464,10 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
sameFaultStatusCounter++;
|
||||
}
|
||||
}
|
||||
lastFaultStatus = faultByte;
|
||||
if (faultStatusChanged) {
|
||||
lastFaultStatus = currentFaultStatus;
|
||||
}
|
||||
|
||||
PoolReadGuard pg(&sensorDataset);
|
||||
auto result = pg.getReadResult();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -478,12 +482,12 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
}
|
||||
if (faultStatusChanged) {
|
||||
sensorDataset.lastErrorByte.setValid(true);
|
||||
sensorDataset.lastErrorByte = faultByte;
|
||||
sensorDataset.lastErrorByte = lastFaultStatus;
|
||||
}
|
||||
sensorDataset.errorByte.setValid(true);
|
||||
sensorDataset.errorByte = faultByte;
|
||||
sensorDataset.errorByte = currentFaultStatus;
|
||||
|
||||
if (faultByte != 0) {
|
||||
if (currentFaultStatus != 0) {
|
||||
sensorDataset.temperatureCelcius.setValid(false);
|
||||
}
|
||||
break;
|
||||
@ -494,11 +498,8 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
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) {
|
||||
return 25000;
|
||||
return 5000;
|
||||
}
|
||||
|
||||
ReturnValue_t Max31865PT1000Handler::getSwitches(const uint8_t **switches,
|
||||
@ -524,6 +525,9 @@ void Max31865PT1000Handler::setInstantNormal(bool instantNormal) {
|
||||
|
||||
void Max31865PT1000Handler::modeChanged() {
|
||||
if (mode == MODE_OFF) {
|
||||
lastFaultStatus = 0;
|
||||
currentFaultStatus = 0;
|
||||
sameFaultStatusCounter = 0;
|
||||
internalState = InternalState::NONE;
|
||||
}
|
||||
}
|
||||
@ -534,3 +538,10 @@ void Max31865PT1000Handler::setDeviceInfo(uint8_t idx, std::string locString_) {
|
||||
}
|
||||
|
||||
void Max31865PT1000Handler::setDebugMode(bool enable) { this->debugMode = enable; }
|
||||
|
||||
bool Max31865PT1000Handler::shouldFaultStatusBeRequested(bool faultBit) {
|
||||
if ((sameFaultStatusCounter < 3) and faultBit) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -77,12 +77,10 @@ class Max31865PT1000Handler : public DeviceHandlerBase {
|
||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
|
||||
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) 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,
|
||||
LocalDataPoolManager &poolManager) override;
|
||||
void modeChanged() override;
|
||||
bool shouldFaultStatusBeRequested(bool faultBit);
|
||||
|
||||
private:
|
||||
uint8_t switchId = 0;
|
||||
@ -110,10 +108,10 @@ class Max31865PT1000Handler : public DeviceHandlerBase {
|
||||
bool resetFaultBit = false;
|
||||
dur_millis_t startTime = 0;
|
||||
uint8_t currentCfg = 0;
|
||||
uint8_t currentFaultStatus = 0;
|
||||
uint8_t lastFaultStatus = 0;
|
||||
uint16_t sameFaultStatusCounter = 0;
|
||||
std::string locString;
|
||||
uint8_t faultByte = 0;
|
||||
uint8_t deviceIdx = 0;
|
||||
std::array<uint8_t, 3> commandBuffer{0};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user