Files
odo_STM32/usb-cbc.py
dd060606 0886376b84 tests
2025-05-13 17:49:49 +02:00

14 lines
476 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import serial
SERIAL_PORT = 'COM8' # Change selon ton port
BAUDRATE = 115200 # Peu importe ici, cest USB, mais ça évite des bugs parfois
try:
with serial.Serial(SERIAL_PORT, BAUDRATE, timeout=1) as ser:
print(f"Écoute sur {SERIAL_PORT}...")
while True:
line = ser.readline().decode(errors='ignore').strip()
if line:
print(f"[STM32] {line}")
except serial.SerialException as e:
print(f"Erreur : {e}")