相关疑难解决方法(0)

Python中的虚拟串行设备?

我知道我可以使用例如pySerial与串口设备通信,但如果我现在没有设备但仍需要为它编写客户端怎么办?如何在Python中编写"虚拟串行设备"并与pySerial通信,就像我会说,运行本地Web服务器?也许我只是不好好搜索,但我一直无法找到有关此主题的任何信息.

python serial-port virtual-serial-port pyserial

41
推荐指数
5
解决办法
3万
查看次数

无法在 Pyserial 中打开串行连接:“termios.error:(22,'无效参数')”

我在执行以下代码时遇到问题:

import serial

ser = serial.Serial(
    port='/dev/tty.FireFly-16CB-SPP',
    baudrate=115200,
    #parity=serial.PARITY_ODD,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS
)

ser.open()
ser.isOpen()
Run Code Online (Sandbox Code Playgroud)

昨天还有效,我不知道我改变了什么。现在我收到以下错误消息:

    Traceback (most recent call last):
  File "main.py", line 32, in <module>
    bytesize=serial.EIGHTBITS
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/serial/serialutil.py", line 260, in __init__
    self.open()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/serial/serialposix.py", line 280, in open
    self._reconfigurePort()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/serial/serialposix.py", line 409, in _reconfigurePort
    termios.tcsetattr(self.fd, TERMIOS.TCSANOW, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
termios.error: (22, 'Invalid argument')
Run Code Online (Sandbox Code Playgroud)

我是 Python 的初学者,无法解读上面的错误消息。我尝试重新安装 Pyserial,但这并没有解决错误。怎么了?

python pyserial

5
推荐指数
1
解决办法
1万
查看次数