clear fault bit for max31865 devies
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
@ -91,6 +91,10 @@ ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand(
|
||||
*id = Max31865Definitions::REQUEST_FAULT_BYTE;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
else if(internalState == InternalState::CLEAR_FAULT_BYTE) {
|
||||
*id = Max31865Definitions::CLEAR_FAULT_BYTE;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
else {
|
||||
return DeviceHandlerBase::NOTHING_TO_SEND;
|
||||
}
|
||||
@ -155,6 +159,13 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(
|
||||
return DeviceHandlerIF::NO_COMMAND_DATA;
|
||||
}
|
||||
}
|
||||
case(Max31865Definitions::CLEAR_FAULT_BYTE): {
|
||||
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::CONFIG_CMD);
|
||||
commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL;
|
||||
DeviceHandlerBase::rawPacketLen = 2;
|
||||
DeviceHandlerBase::rawPacket = commandBuffer.data();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case(Max31865Definitions::REQUEST_CONFIG): {
|
||||
commandBuffer[0] = static_cast<uint8_t>(
|
||||
Max31865Definitions::REQUEST_CONFIG);
|
||||
@ -233,6 +244,7 @@ void Max31865PT1000Handler::fillCommandAndReplyMap() {
|
||||
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3,
|
||||
&sensorDataset);
|
||||
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3);
|
||||
insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3);
|
||||
}
|
||||
|
||||
ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
|
||||
@ -290,6 +302,11 @@ ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
|
||||
*foundLen = 2;
|
||||
internalState = InternalState::RUNNING;
|
||||
}
|
||||
else if(internalState == InternalState::CLEAR_FAULT_BYTE) {
|
||||
*foundId = Max31865Definitions::CLEAR_FAULT_BYTE;
|
||||
*foundLen = 2;
|
||||
internalState = InternalState::RUNNING;
|
||||
}
|
||||
else {
|
||||
*foundId = Max31865Definitions::REQUEST_CONFIG;
|
||||
*foundLen = configReplySize;
|
||||
@ -360,9 +377,14 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
|
||||
case(Max31865Definitions::REQUEST_RTD): {
|
||||
// first bit of LSB reply byte is the fault bit
|
||||
uint8_t faultBit = packet[2] & 0b0000'0001;
|
||||
if(faultBit == 1) {
|
||||
if(resetFaultBit) {
|
||||
internalState = InternalState::CLEAR_FAULT_BYTE;
|
||||
resetFaultBit = false;
|
||||
}
|
||||
else if(faultBit == 1) {
|
||||
// Maybe we should attempt to restart it?
|
||||
internalState = InternalState::REQUEST_FAULT_BYTE;
|
||||
resetFaultBit = true;
|
||||
}
|
||||
|
||||
// RTD value consists of last seven bits of the LSB reply byte and
|
||||
|
@ -96,12 +96,14 @@ private:
|
||||
REQUEST_LOW_THRESHOLD,
|
||||
REQUEST_CONFIG,
|
||||
RUNNING,
|
||||
REQUEST_FAULT_BYTE
|
||||
REQUEST_FAULT_BYTE,
|
||||
CLEAR_FAULT_BYTE
|
||||
};
|
||||
|
||||
InternalState internalState = InternalState::NONE;
|
||||
bool commandExecuted = false;
|
||||
|
||||
bool resetFaultBit = false;
|
||||
dur_millis_t startTime = 0;
|
||||
uint8_t faultByte = 0;
|
||||
std::array<uint8_t, 3> commandBuffer { 0 };
|
||||
|
@ -17,13 +17,17 @@ enum PoolIds: lp_id_t {
|
||||
static constexpr DeviceCommandId_t CONFIG_CMD = 0x80;
|
||||
static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83;
|
||||
static constexpr DeviceCommandId_t WRITE_LOW_THRESHOLD = 0x85;
|
||||
|
||||
static constexpr DeviceCommandId_t REQUEST_CONFIG = 0x00;
|
||||
static constexpr DeviceCommandId_t REQUEST_RTD = 0x01;
|
||||
static constexpr DeviceCommandId_t REQUEST_HIGH_THRESHOLD = 0x03;
|
||||
static constexpr DeviceCommandId_t REQUEST_LOW_THRESHOLD = 0x05;
|
||||
static constexpr DeviceCommandId_t REQUEST_FAULT_BYTE = 0x07;
|
||||
|
||||
static constexpr DeviceCommandId_t CLEAR_FAULT_BYTE = 0x08;
|
||||
|
||||
static constexpr uint32_t MAX31865_SET_ID = REQUEST_RTD;
|
||||
static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010;
|
||||
|
||||
static constexpr size_t MAX_REPLY_SIZE = 5;
|
||||
|
||||
|
Reference in New Issue
Block a user