forked from tanchou/Verilog
Refactor UART testbench and top-level modules; remove old testbench files, enhance UART communication in top_ultrason_uart, and implement LED control via UART in top_led_uart. Add Python scripts for UART communication and data reading.
This commit is contained in:
15
Semaine 1/Python_UART/read_rx.py
Normal file
15
Semaine 1/Python_UART/read_rx.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import serial
|
||||
import time
|
||||
|
||||
ser = serial.Serial('COM6', 115200)
|
||||
ser.timeout = 1
|
||||
|
||||
# Boucle pour lire les données du port série
|
||||
while True:
|
||||
if ser.in_waiting > 0:
|
||||
data = ser.read(1)
|
||||
|
||||
distance = int.from_bytes(data, byteorder='little')
|
||||
print(f'Distance reçue : {distance} cm')
|
||||
|
||||
ser.close()
|
Reference in New Issue
Block a user