|
|
|
@ -3,7 +3,7 @@ from math import inf
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
import binascii
|
|
|
|
import binascii
|
|
|
|
|
|
|
|
|
|
|
|
def crap_to_number(num, unit, acdc):
|
|
|
|
def crap_to_number(num, unit, acdc, include_unit):
|
|
|
|
number_str = ""
|
|
|
|
number_str = ""
|
|
|
|
|
|
|
|
|
|
|
|
if(num[0]&0x10):
|
|
|
|
if(num[0]&0x10):
|
|
|
|
@ -29,42 +29,44 @@ def crap_to_number(num, unit, acdc):
|
|
|
|
}
|
|
|
|
}
|
|
|
|
number_str+=switch.get(elem&0xEF, "-")
|
|
|
|
number_str+=switch.get(elem&0xEF, "-")
|
|
|
|
|
|
|
|
|
|
|
|
if (unit[0] & 0x1):
|
|
|
|
|
|
|
|
number_str+="µ"
|
|
|
|
if(include_unit):
|
|
|
|
if (unit[0] & 0x2):
|
|
|
|
if (unit[0] & 0x1):
|
|
|
|
number_str+="n"
|
|
|
|
number_str+="µ"
|
|
|
|
if (unit[0] & 0x4):
|
|
|
|
if (unit[0] & 0x2):
|
|
|
|
number_str+="k"
|
|
|
|
number_str+="n"
|
|
|
|
if (unit[1] & 0x1):
|
|
|
|
if (unit[0] & 0x4):
|
|
|
|
number_str+="m"
|
|
|
|
number_str+="k"
|
|
|
|
if (unit[1] & 0x2):
|
|
|
|
if (unit[1] & 0x1):
|
|
|
|
number_str+="%"
|
|
|
|
number_str+="m"
|
|
|
|
if (unit[1] & 0x4):
|
|
|
|
if (unit[1] & 0x2):
|
|
|
|
number_str+="M"
|
|
|
|
number_str+="%"
|
|
|
|
if (unit[2] & 0x1):
|
|
|
|
if (unit[1] & 0x4):
|
|
|
|
number_str+="F"
|
|
|
|
number_str+="M"
|
|
|
|
if (unit[2] & 0x2):
|
|
|
|
if (unit[2] & 0x1):
|
|
|
|
number_str+="Ω"
|
|
|
|
number_str+="F"
|
|
|
|
if (unit[3] & 0x1):
|
|
|
|
if (unit[2] & 0x2):
|
|
|
|
number_str+="A"
|
|
|
|
number_str+="Ω"
|
|
|
|
if (unit[3] & 0x2):
|
|
|
|
if (unit[3] & 0x1):
|
|
|
|
number_str+="V"
|
|
|
|
number_str+="A"
|
|
|
|
if (unit[3] & 0x4):
|
|
|
|
if (unit[3] & 0x2):
|
|
|
|
number_str+="Hz"
|
|
|
|
number_str+="V"
|
|
|
|
if (unit[4] & 0x2):
|
|
|
|
if (unit[3] & 0x4):
|
|
|
|
number_str+="°C"
|
|
|
|
number_str+="Hz"
|
|
|
|
if (unit[4] & 0x1):
|
|
|
|
if (unit[4] & 0x2):
|
|
|
|
number_str+="°F"
|
|
|
|
number_str+="°C"
|
|
|
|
|
|
|
|
if (unit[4] & 0x1):
|
|
|
|
if(acdc&0xb == 0x0a):
|
|
|
|
number_str+="°F"
|
|
|
|
number_str+=" DC"
|
|
|
|
|
|
|
|
if(acdc&0xb == 0x09):
|
|
|
|
if(acdc&0xb == 0x0a):
|
|
|
|
number_str+=" AC"
|
|
|
|
number_str+=" DC"
|
|
|
|
|
|
|
|
if(acdc&0xb == 0x09):
|
|
|
|
|
|
|
|
number_str+=" AC"
|
|
|
|
|
|
|
|
|
|
|
|
return number_str
|
|
|
|
return number_str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read_peaktech( ser ):
|
|
|
|
def read_peaktech(ser, include_unit=True):
|
|
|
|
|
|
|
|
|
|
|
|
line = ser.read_until( b'\xf1' )
|
|
|
|
line = ser.read_until( b'\xf1' )
|
|
|
|
#print(binascii.hexlify(line))
|
|
|
|
#print(binascii.hexlify(line))
|
|
|
|
@ -117,7 +119,7 @@ def read_peaktech( ser ):
|
|
|
|
#if line[0:2] == b'\x18\x2e':
|
|
|
|
#if line[0:2] == b'\x18\x2e':
|
|
|
|
# print("Temp")
|
|
|
|
# print("Temp")
|
|
|
|
|
|
|
|
|
|
|
|
return crap_to_number(num, unit, acdc)
|
|
|
|
return crap_to_number(num, unit, acdc, include_unit)
|
|
|
|
#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") )
|
|
|
|
@ -167,7 +169,7 @@ def read_peaktech( ser ):
|
|
|
|
|
|
|
|
|
|
|
|
def read():
|
|
|
|
def read():
|
|
|
|
ser = Serial("/dev/ttyUSB0", 2400)
|
|
|
|
ser = Serial("/dev/ttyUSB0", 2400)
|
|
|
|
res = read_peaktech(ser)
|
|
|
|
res = read_peaktech(ser, False)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
res = int(res)
|
|
|
|
res = int(res)
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
|