您好我想用两个设备FT232进行RS-485传输(它们通过USB与Raspberry Pi 3连接,但也与RJ45连接 - 我只想检查传输是否正常。我试图使用PySerial与RS485功能从https://github.com/pyserial/pyserial/blob/master/serial/rs485.py
我试图创建自己的读取但是可能写入和读取传输没有工作(程序没有显示接收数据)。有读功能:
def read(self,n):
print(n)
if self._alternate_rs485_settings is not None:
self.setRTS(self._alternate_rs485_settings.rts_level_for_rx)
if self._alternate_rs485_settings.delay_before_rx is not None:
time.sleep(self._alternate_rs485_settings.delay_before_rx)
response = super(RS485, self).read(size=n)
super(RS485, self).flush()
if self._alternate_rs485_settings.delay_before_tx is not None:
time.sleep(self._alternate_rs485_settings.delay_before_tx)
self.setRTS(self._alternate_rs485_settings.rts_level_for_tx)
else:
super(RS485, self).read()
return response
我使用setRTS来改变发送和接收端口(因为我想制作RS-485,半双工传输)
如何正确地写入和读取数据?