mirror of
https://github.com/modelec/odo_STM32.git
synced 2026-01-18 16:27:25 +01:00
14 lines
476 B
Python
14 lines
476 B
Python
import serial
|
||
|
||
SERIAL_PORT = 'COM8' # Change selon ton port
|
||
BAUDRATE = 115200 # Peu importe ici, c’est 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}") |