wrote a working parser

This commit is contained in:
d3m1g0d
2019-01-09 21:30:20 +01:00
parent ee35252660
commit 045f0fc72f
2 changed files with 7 additions and 7 deletions

View File

@@ -10,17 +10,18 @@ uartpath = '/dev/ttyUSB0'
uartbaud = 115200
uarttout = 5
wl = [410, 435, 460, 485, 510, 535, 560, 585, 610, 645, 680, 705, 730, 760, 810, 860, 900, 940]
responseorder = [i for i in 'RSTUVWGHIJKLABCDEF'] # works, do NOT touch!
realorder = [i for i in 'ABCDEFGHRISJTUVWKL']
print('getcdata')
print('This utility is part of the TeraHz project')
wavelens = pd.Series([410, 435, 460, 485, 510, 535, 560, 585, 610, 645, 680, 705, 730, 760, 810, 860, 900, 940],
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'R', 'I', 'S', 'J', 'T', 'U', 'V', 'W', 'K', 'L'])
wavelens = pd.Series(realorder)
wavetable = pd.DataFrame(columns=wavelens)
with ser.Serial(uartpath, uartbaud, timeout=uarttout) as sensor:
sensor.write(b'ATCDATA\n')
response = sensor.readline()
print(response.decode())
parsed = parse('{:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f}, {:f} OK', response.decode())
print(parsed)
response = pd.Series([float (i) for i in sensor.readline().decode()[:-3].split(',')]) # works, do not touch!
print(response)