usart/term.py

13 lines
331 B
Python

import serial
from time import sleep
with serial.Serial('/dev/ttyUSB0', 9600, timeout=1) as ser:
ser.write(b'a')
while True:
x = ser.read() # read one byte
if x != b'':
pass
print(x.decode('utf'))
#ser.write(b'a')
#print(ser.read())
sleep(1)