reading onewire sensors now works

This commit is contained in:
Senad Uka
2016-10-29 17:30:28 +02:00
parent 971ca889fc
commit 16bf8c8f3e

View File

@@ -5,8 +5,15 @@ def read_one_thermo(filename):
textfile = open(filename, 'r')
filetext = textfile.read()
textfile.close()
matches = re.findall("t=(\d+)", filetext)
return int(matches[0][0:-NO_OF_DECIMALS]) + (int(matches[0][-NO_OF_DECIMALS:]) / 1000.0)
matches = re.findall("t=(\-?)(\d+)", filetext)
sign = -1 if matches[0][0] == '-' else 1
whole_reading = matches[0][1]
first_part = matches[0][1][0:-NO_OF_DECIMALS]
second_part = matches[0][1][-NO_OF_DECIMALS:]
first_part = '0' if first_part == '' else first_part
return (int(first_part) + (int(second_part) / (10.0 ** NO_OF_DECIMALS) )) * sign
def read_many_thermo(filenames):
result = []