lab1: implement UART reader alongside with the file writer usage example

This commit is contained in:
2026-02-24 12:48:48 +02:00
parent 35af3bbabb
commit 092130dfab
2 changed files with 84 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
from UARTReader import UARTReader
import os
PORT = os.environ.get("PORT", None) or "/dev/ttyUSB0"
FILE = os.environ.get("FILE", None) or "savefile.csv"
r = UARTReader(PORT)
with open(FILE, "w") as f:
f.write("x,y,z\n")
for i in range(500):
v = r.read_next()
f.write(",".join(tuple(map(str, v))) + "\n")
r.close()