From 2c55a6c0eded3338688e554448f9c0f900c4a5e3 Mon Sep 17 00:00:00 2001 From: davehutz Date: Sat, 16 Sep 2023 21:41:03 -0600 Subject: [PATCH] KILN-008 - handle read errors for mcp9600 --- lib/mcp9600.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/mcp9600.py b/lib/mcp9600.py index ff6edff..9db4ba7 100644 --- a/lib/mcp9600.py +++ b/lib/mcp9600.py @@ -39,13 +39,17 @@ class OvenMCP9600(object): def read(self): '''Reads temperature from thermocouple and code junction''' - # Save data - self.tempC = self.mcp.temperature - self.referenceTempC = self.mcp.ambient_temperature + try: + # Save data + self.tempC = self.mcp.temperature + self.referenceTempC = self.mcp.ambient_temperature + self.noConnection = False + except: + self.noConnection = True def checkErrors(self, data_32 = None): '''Checks error bits to see if there are any SCV, SCG, or OC faults''' - self.noConnection = self.shortToGround = self.shortToVCC = self.unknownError = False + self.shortToGround = self.shortToVCC = self.unknownError = False def data_to_rj_temperature(self, data_32 = None): '''Returns reference junction temperature in C.'''