Python Pyserial,设备无响应
我正在尝试与一个使用Python3.5在Win7上使用pyserial的设备通信。我能够连接到正确的端口“COM4”,但忽略所有其他通信。我所做的是:Python Pyserial,设备无响应,python,pyserial,Python,Pyserial,我正在尝试与一个使用Python3.5在Win7上使用pyserial的设备通信。我能够连接到正确的端口“COM4”,但忽略所有其他通信。我所做的是: from serial import * s = Serial('COM4', stopbits=2) # All other settings are default 到目前为止没有错误。但我收到了一个错误,错误如下: >> s.write('REM') # Should put the device in 'Remote'
from serial import *
s = Serial('COM4', stopbits=2) # All other settings are default
到目前为止没有错误。但我收到了一个错误,错误如下:
>> s.write('REM') # Should put the device in 'Remote' mode
TypeError: unicode strings are not supported, please encode to bytes.
所以我把它改成:
>> s.write(b'REM')
3
然后它返回我试图发送到设备的字符串的字符数。例如,如果我尝试“S1”,它将返回2。该设备不响应该命令,也不会给出错误。我认为缺少通信是由于将字符串更改为字节造成的,但我不确定。有人有什么好主意能解开我的谜团吗