PySerial API认为在write()期间com端口仍处于打开状态,为什么?

| 我正在使用PySerial(用于串行通信的Python API)通过蓝牙将AT命令发送到诺基亚手机。
import serial
com = serial.Serial()
com.port = 19
com.timeout = 0 #also tried a timeout value greater than 0.
try:
    com.open()
    # at this point I turn off the phone.
    com.write(\"AT\\r\\n\")
    print com.readlines()
except SerialException, e:
    print e
打开()通信后,我就关闭了电话。然后,我写(\“ AT \\ r \\ n \”)。此时,功能块和运行时挂起。 你有什么解决办法吗?     
已邀请:
        将超时设置为“ 1”时,您将禁用超时参数,则“ 2”将成为阻塞调用。呼叫者将被阻止,直到设备应答为止。 尝试为串行连接serial3ѭ设置一个非零的超时值。 如果仍然挂起,则问题应该出在蓝牙堆栈中。     
        实际上,您要查找的是writeTimeout而不是timeout参数。我知道较晚的答案,但我仍然需要它,我想我不是唯一的一个。     

要回复问题请先登录注册