This commit is contained in:
2026-02-25 11:54:10 +01:00
parent e7aa562c0b
commit 5c8a35440e
5 changed files with 10 additions and 15 deletions

View File

@@ -90,6 +90,13 @@ class BuzzerConnection:
with open(filepath, 'rb') as f:
while bytes_sent < file_size:
# NEU: Prüfe, ob der Controller VORZEITIG abgebrochen hat (z.B. ERR)
if self.serial.in_waiting > 0:
line = self.serial.readline().decode('utf-8', errors='ignore').strip()
if line.startswith("ERR"):
raise BuzzerError(f"Controller hat Transfer abgebrochen: {line}")
chunk = f.read(chunk_size)
if not chunk:
break
@@ -97,10 +104,8 @@ class BuzzerConnection:
self.serial.flush()
bytes_sent += len(chunk)
# Callback aufrufen, falls vorhanden
if progress_callback:
progress_callback(len(chunk))
# 3. Warte auf das finale OK (oder ERR bei CRC/Schreib-Fehlern)
start_time = time.time()
while (time.time() - start_time) < timeout: