Unable to open serial port using simply python script on macOS Catalina: [Errno 16] Resource is busy

kernel-extensionspythonusb

On a brand new MacBook16 running Catalina (10.15.1) I am getting the following error trying to connect to an FTDI FT232R USB UART device.

Python 2.7.17 (v2.7.17:c2f86d86e6, Oct 19 2019, 16:07:15) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
>>> ser = serial.Serial('/dev/tty.usbserial-A106NU2I', 38400, timeout=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/cbagwell/.virtualenvs/toolbelt/lib/python2.7/site-packages/serial/serialutil.py", line 240, in __init__
    self.open()
  File "/Users/cbagwell/.virtualenvs/toolbelt/lib/python2.7/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-A106NU2I: [Errno 16] Resource busy: '/dev/tty.usbserial-A106NU2I'

I see the following events under the Console application:

006002.877344 python@(null): AppleUSBHostUserClient::openGated: could not open provider USB3.0 Hub             . provider already opened for exclusive access by a kernel client
006002.878136 python@(null): AppleUSBHostUserClient::openGated: could not open provider USB2.0 Hub             . provider already opened for exclusive access by a kernel client

So it appears that some kernel client already has the "/dev/tty.usbserial-A106NU2I" file opened with exclusive access.

My question is, how do I determine which kernel client (or kernel extension?) has this file opened?

I have tried using "sudo lsof | grep tty" and don't see anything there.

The device is visible and recognized under About this Mac -> System Report -> USB

Thanks!

Best Answer

I had the same problem, serial port resource busy and could not see which process used it.

I found this thread here: https://forums.developer.apple.com/thread/124414

They recommend installing the latest version of the FTDI driver, 2.4.2, found here: https://www.ftdichip.com/Drivers/VCP.htm

That did the trick.

Cheers