【发布时间】:2019-12-10 18:22:55
【问题描述】:
我正在尝试使用 PySerial 打开与 USB 设备的串行连接,并且使用以下代码我收到以下错误:
import serial
ser = serial.Serial('/dev/tty.usbserial-EN270425')
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/serial/serialposix.py", line 265, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
OSError: [Errno 16] Resource busy: '/dev/tty.usbserial-EN270425'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
ser = serial.Serial('/dev/tty.usbserial-EN270425')
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/serial/serialutil.py", line 240, in __init__
self.open()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 16] could not open port /dev/tty.usbserial-EN270425: [Errno 16] Resource busy: '/dev/tty.usbserial-EN270425'
我已检查是否有进程通过
lsof | grep "/dev/tty.usbserial-EN270425" 没有返回值。
我能够连接到另一台机器上的端口,唯一的区别是操作系统和 python 版本。 CAN 连接的机器运行 Mac OS Mojave 和 Python 3.6,不能连接的机器运行 Mac OS Catalina 和 Python 3.8。有谁知道我可以从这里继续前进吗?
【问题讨论】:
标签: python macos serial-port usb pyserial