2
我只是想知道缓冲区如何在com端口上工作..下面的代码是我如何阅读com端口的片段。我想知道如果通过做serial_connection.close()
和serial_connection.open()
我会丢失任何数据,或将它保留在缓冲区?你可能会问为什么我关闭并打开comport ..原因是它实际上是一个虚拟端口,并且因为什么原因当我保持连接它的时间长度的数据停止传输时...用Python读取串口。缓冲区如何工作?
import serial
serial_connection = serial.Serial(
port = self.SERIAL_PORT,
baudrate = self.BAUD_RATE,
timeout = 10
)
while true:
serial_connection.close()
serial_connection.open()
line = serial_connection.readline()
print line