1
0
Fork 0
mirror of https://codeberg.org/SiB64/blinkenlights.git synced 2026-05-01 06:44:23 +02:00

Compare commits

..

No commits in common. "d99e5587d16027fcc2a8b8aaaeedbd163c05b01c" and "40ca706ec8d7fe3b8318f8387047591e74356fb4" have entirely different histories.

2 changed files with 28 additions and 56 deletions

View file

@ -136,9 +136,3 @@ endif
mux_uart: mux_uart.c
gcc -Wall -O2 -g -DWITH_ARGS $< -o $@
bate%.filt: bate%.txt
./bate.py recalibrate < $< \
| awk 'NF==15 && $$6<1100 && $$6>900 {print $$2,$$4,$$6}' \
| derive.py -p3 -s60 -W30 \
> $@

View file

@ -33,7 +33,7 @@ def calibrate(Word, D):
D2 = %d
UT1 = %d
dT = %d
TEMP = %.2f °C
TEMP = %.1f °C
""" % (D[2], UT1, dT, TEMP*0.1))
OFF = C[2]*4 + ((C[4]-512)*dT)/4096
@ -47,18 +47,18 @@ def calibrate(Word, D):
OFF = %d
SENS = %d
X = %d
P = %.2f mbar
P = %.1f mbar
""" % (D[1], OFF, SENS, X, P*0.1))
return (TEMP/10, P/10)
port = "/dev/ttyUSB1"
def read_bate(port):
tty = serial.Serial(port=port, baudrate=2400)
r = b''
nx = 0
while True:
if len(sys.argv)==2:
port = sys.argv[1]
tty = serial.Serial(port=port, baudrate=2400)
r = b''
nx = 0
while True:
r += tty.read_all()
if len(r)<16:
r += tty.read(16-len(r))
@ -76,29 +76,7 @@ def read_bate(port):
r = r[16:]
T,p = calibrate(w[1:],w[5:])
t = time.time()
sys.stdout.write(f"\nPT {t:.1f} {time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(t))} {T:+5.2f} °C {p:7.2f} mbar ")
sys.stdout.write(f"\nPT {t:.1f} {time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(t))} {T:+4.1f} °C {p:6.1f} mbar ")
sys.stdout.write(" ".join([f"{x:04x}" for x in w]))
sys.stdout.flush()
nx = 0
def recalibrate(f):
for l in f.readlines():
ll = l.split()
if len(ll) != 15:
continue
if ll[0] != "PT":
continue
w = [int(lll,16) for lll in ll[-8:]]
t = float(ll[1])
T,p = calibrate(w[1:],w[5:])
sys.stdout.write(f"\nPT {t:.1f} {time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(t))} {T:+5.2f} °C {p:7.2f} mbar ")
sys.stdout.write(" ".join([f"{x:04x}" for x in w]))
if __name__ == "__main__":
if len(sys.argv) == 2:
port = sys.argv[1]
if port == "recalibrate":
recalibrate(sys.stdin)
else:
read_bate(port)
sys.stdout.write("\n")