thermocouple: Report fault information in fault field

Send the fault information explicitly in the query_thermocouple fault
field for max6675, max31855, and max31865.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2022-09-19 13:28:45 -04:00
parent ddb59440a8
commit 4e930294b8
2 changed files with 12 additions and 18 deletions

View file

@ -193,11 +193,11 @@ class MAX31855(SensorBase):
def __init__(self, config):
SensorBase.__init__(self, config, "MAX31855", spi_mode=0)
def calc_temp(self, adc, fault):
if adc & 0x1:
if fault & 0x1:
self.fault("MAX31855 : Open Circuit")
if adc & 0x2:
if fault & 0x2:
self.fault("MAX31855 : Short to GND")
if adc & 0x4:
if fault & 0x4:
self.fault("MAX31855 : Short to Vcc")
adc = adc >> MAX31855_SCALE
# Fix sign bit:
@ -222,9 +222,9 @@ class MAX6675(SensorBase):
def __init__(self, config):
SensorBase.__init__(self, config, "MAX6675", spi_mode=0)
def calc_temp(self, adc, fault):
if adc & 0x02:
if fault & 0x02:
self.fault("Max6675 : Device ID error")
if adc & 0x04:
if fault & 0x04:
self.fault("Max6675 : Thermocouple Open Fault")
adc = adc >> MAX6675_SCALE
# Fix sign bit:
@ -293,7 +293,7 @@ class MAX31865(SensorBase):
self.fault("Max31865 VRTD- is less than 0.85 * VBIAS, FORCE- open")
if fault & 0x04:
self.fault("Max31865 Overvoltage or undervoltage fault")
if fault & 0x03:
if not fault & 0xfc:
self.fault("Max31865 Unspecified error")
adc = adc >> 1 # remove fault bit
R_div_nominal = adc * self.adc_to_resist_div_nominal