From 9ca2842b0e37c419ebc1490de98c154f88ae0791 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 15 Sep 2017 15:58:29 -0400 Subject: [PATCH] unary operation made safe in error handler for Thermocouple unary & is used with 32 bits operands. If the operand literal is not explicitly expressed as 32bits, it can create random casting errors depending on the Python version and the underlying implementation. --- lib/max31855.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/max31855.py b/lib/max31855.py index 38ac170..69334d2 100644 --- a/lib/max31855.py +++ b/lib/max31855.py @@ -68,9 +68,9 @@ def checkErrors(self, data_32 = None): if data_32 is None: data_32 = self.data anyErrors = (data_32 & 0x10000) != 0 # Fault bit, D16 - noConnection = (data_32 & 1) != 0 # OC bit, D0 - shortToGround = (data_32 & 2) != 0 # SCG bit, D1 - shortToVCC = (data_32 & 4) != 0 # SCV bit, D2 + noConnection = (data_32 & 0x00000001) != 0 # OC bit, D0 + shortToGround = (data_32 & 0x00000002) != 0 # SCG bit, D1 + shortToVCC = (data_32 & 0x00000004) != 0 # SCV bit, D2 if anyErrors: if noConnection: raise MAX31855Error("No Connection")