diff --git a/sensor_docs/.~lock.spektralni_odziv.ods# b/sensor_docs/.~lock.spektralni_odziv.ods# new file mode 100644 index 0000000..e671e39 --- /dev/null +++ b/sensor_docs/.~lock.spektralni_odziv.ods# @@ -0,0 +1 @@ +,root,ryzenshine-kali,09.01.2019 18:42,file:///root/.config/libreoffice/4; \ No newline at end of file diff --git a/utils/getcdata.py b/utils/getcdata.py index 95f5550..9314837 100644 --- a/utils/getcdata.py +++ b/utils/getcdata.py @@ -1,4 +1,26 @@ +# getcdata.py - fetch the calibrated data from the AS7265x module +# this program is 3-clause BSD license import serial as ser -with ser.Serial('/dev/ttyUSB0', 115200, timeout=5) as serport: - serport.write(b'ATCDATA\n') - print(serport.readline()) +from parse import * +import pandas as pd +import numpy as np + +#global variables +uartpath = '/dev/ttyUSB0' +uartbaud = 115200 +uarttout = 5 + +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']) + +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)