Files
edelweiss/upsmon/ups.py
Emanuele Trabattoni 6cac8b8c90 Prove upsmon
2025-05-30 10:19:36 +02:00

16 lines
433 B
Python

import string
import serial
import time
port = serial.Serial(port='COM3', baudrate=2400, bytesize=8, parity='N', stopbits=1)
for c in string.ascii_uppercase:
for n in range(100):
d = c+f"{n:02d}"
port.write((d+chr(13)).encode())
port.flush()
r = port.read_all().decode('ascii').rstrip()
print(f"{d} : {r}", sep='^H')
if 'NAK' not in r:
print()
time.sleep(0.1)