auto: update RTK rover/base + config (2026-04-30 13:43:06)
This commit is contained in:
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
import serial, time, string
|
||||
from datetime import datetime
|
||||
|
||||
PORT="/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0"
|
||||
BAUD=9600
|
||||
|
||||
PRINTABLE=set(bytes(string.printable, "ascii"))
|
||||
|
||||
def classify(line: bytes):
|
||||
# strip CR/LF
|
||||
raw=line.strip(b"\r\n")
|
||||
if not raw:
|
||||
return None, None
|
||||
printable = sum(b in PRINTABLE for b in raw)
|
||||
ratio = printable / max(1, len(raw))
|
||||
try:
|
||||
txt = raw.decode("ascii", errors="replace")
|
||||
except Exception:
|
||||
txt = repr(raw)
|
||||
return ratio, txt
|
||||
|
||||
ser=serial.Serial(PORT, BAUD, timeout=0.2)
|
||||
buf=b""
|
||||
cnt=0
|
||||
try:
|
||||
while True:
|
||||
buf += ser.read(4096)
|
||||
while b"\n" in buf:
|
||||
line, buf = buf.split(b"\n", 1)
|
||||
ratio, txt = classify(line+b"\n")
|
||||
if ratio is None:
|
||||
continue
|
||||
cnt += 1
|
||||
ts=datetime.now().strftime("%H:%M:%S")
|
||||
tag="OK" if txt.startswith("Test #") else "GARBAGE"
|
||||
print(f"[{ts}] #{cnt:04d} {tag} printable_ratio={ratio:.2f} {txt}")
|
||||
time.sleep(0.01)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
ser.close()
|
||||
Reference in New Issue
Block a user