Commit 5a50f942 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

sw: Started work on changing output of therm_id.py

parent 431d5050
......@@ -227,6 +227,9 @@ class CDS18B20:
temp = temp/16.0
return temp
def crc(self, val):
ret = 0
for i in range(64):
##-------------------------------------------------------------------------------------------------
## main --
......@@ -250,11 +253,14 @@ def main(bus,tname,inf,log):
# Reading of unique ID
unique_id = ds18b20.read_serial_number()
family_code = unique_id & 0xff
crc = (unique_id & 0xff00000000000000) >> 56
if(unique_id == -1):
msg = "ERROR: TempID IC22: Unable to read 1-wire thermometer"
pel.set(msg)
else:
inf.write("Unique ID: %.12X\n" % (unique_id))
unique_id &= 0x00ffffffffffff00
inf.write("Unique ID: %012X\n" % (unique_id))
# Reading of temperature
temp = ds18b20.read_temp(unique_id)
......@@ -267,7 +273,8 @@ def main(bus,tname,inf,log):
if((unique_id & 0xFF) != FAMILY_CODE):
family_code = unique_id & 0xFF
msg = "ERROR: TempID IC22: Invalid family code: 0x%.8X\n" % (family_code)
msg = "ERROR: TempID IC22: Invalid family code (0x%02X)\n" %
(family_code, FAMILY_CODE)
pel.set(msg)
return pel.get()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment