我尝试通过UART与FPGA通信。有一个电位器连接到FPGA的ADC引脚,我想发送到ADC输出到PC。在PC端,我尝试使用PySerial读取这些传入数据。但是,当我更改ADC输入时,我在Python上读取的传入数据不会更改。在另一个串行监控程序中,我可以同时看到更新的数据。我在Python中遗漏了什么?
下面是我正在编写的代码
import serial
ser = serial.Serial(
port='COM31',
baudrate=19200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS)
while True:
in_bin = ser.read()
in_hex = hex(int.from_bytes(in_bin,byteorder='little'))
print(in_hex,end=' ')谢谢你的帮助。
发布于 2018-09-05 14:39:26
在ser.read()或ser.readline()之前使用ser.reset_input_buffer()。
https://stackoverflow.com/questions/50305616
复制相似问题