|
|
|
@ -19,14 +19,10 @@ def crap_to_number(crap):
|
|
|
|
0xeb:"0"
|
|
|
|
0xeb:"0"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
number_str+=switch.get(elem, "-")
|
|
|
|
number_str+=switch.get(elem, "-")
|
|
|
|
print(number_str)
|
|
|
|
return number_str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read_peaktech( port ):
|
|
|
|
def read_peaktech( ser ):
|
|
|
|
try:
|
|
|
|
|
|
|
|
with Serial( port , 2400) as ser:
|
|
|
|
|
|
|
|
print(ser.name)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
|
|
|
line = ser.read_until( b'\xf1' )
|
|
|
|
line = ser.read_until( b'\xf1' )
|
|
|
|
#print(binascii.hexlify(line))
|
|
|
|
#print(binascii.hexlify(line))
|
|
|
|
|
|
|
|
|
|
|
|
@ -50,7 +46,6 @@ def read_peaktech( port ):
|
|
|
|
num3 = (bytearr[5]<<4) | bytearr[6]
|
|
|
|
num3 = (bytearr[5]<<4) | bytearr[6]
|
|
|
|
num4 = (bytearr[7]<<4) | bytearr[8]
|
|
|
|
num4 = (bytearr[7]<<4) | bytearr[8]
|
|
|
|
|
|
|
|
|
|
|
|
crap_to_number([num1, num2, num3, num4])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if line[0:2] == b'\x1C\x20':
|
|
|
|
if line[0:2] == b'\x1C\x20':
|
|
|
|
print("Ohm")
|
|
|
|
print("Ohm")
|
|
|
|
@ -65,6 +60,7 @@ def read_peaktech( port ):
|
|
|
|
if line[0:2] == b'\x18\x2e':
|
|
|
|
if line[0:2] == b'\x18\x2e':
|
|
|
|
print("Temp")
|
|
|
|
print("Temp")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return crap_to_number([num1, num2, num3, num4])
|
|
|
|
#if (len(line) == 14) and (line[5] == 0x20):
|
|
|
|
#if (len(line) == 14) and (line[5] == 0x20):
|
|
|
|
# try:
|
|
|
|
# try:
|
|
|
|
# value = float( line[0:5].decode("ascii") )
|
|
|
|
# value = float( line[0:5].decode("ascii") )
|
|
|
|
@ -111,10 +107,6 @@ def read_peaktech( port ):
|
|
|
|
# unit = ""
|
|
|
|
# unit = ""
|
|
|
|
|
|
|
|
|
|
|
|
# print( f"{value}{prefix}{unit}" )
|
|
|
|
# print( f"{value}{prefix}{unit}" )
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
|
|
|
print( "Exception:", ex )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
port = "/dev/ttyUSB0"
|
|
|
|
port = "/dev/ttyUSB0"
|
|
|
|
@ -122,4 +114,14 @@ if __name__ == "__main__":
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
port = sys.argv[1]
|
|
|
|
port = sys.argv[1]
|
|
|
|
|
|
|
|
|
|
|
|
read_peaktech( port )
|
|
|
|
try:
|
|
|
|
|
|
|
|
with Serial( port , 2400) as ser:
|
|
|
|
|
|
|
|
print(ser.name)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
|
|
|
print(read_peaktech(ser))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
|
|
|
print( "Exception:", ex )
|
|
|
|
|
|
|
|
|
|
|
|
|