Unable to open a connection to an FTDI device

隐身守侯 提交于 2019-12-02 17:54:11

问题


I'm working on a small OS X app that connects to an FTDI device. I've configured my project according to the answer in this question (I've added the .dylib file as a framework, and I added the ftd2xx.h, WinTypes.h, and ftd2xx.cfg files to my project).

I'm currently able to detect if/when the FTDI device is connected over USB:

DWORD deviceCount = 0;
FT_STATUS ftdiPortStatus = FT_ListDevices(&deviceCount, NULL, FT_LIST_NUMBER_ONLY)
if (ftdiPortStatus == FT_OK) {
    // The debugger tells me the deviceCount is now 1
    ...
}

However, if I try to open a connection to the device using either of the following techniques:

ftdiPortStatus = FT_OpenEx("FT232R USB UART",FT_OPEN_BY_DESCRIPTION,deviceHandle);
// OR
ftdiPortStatus = FT_Open(0, deviceHandle);

the returned ftdiPortStatus is always 3 (FT_DEVICE_NOT_OPENED).

The answer here indicates that the problem might be a new driver that Apple added in OSX 10.9, however, if I attempt to unload that kext:

sudo kextunload -b com.apple.driver.AppleUSBFTDI

the OS indicates that no such kext was found. I'm on OSX 10.10, so maybe Apple repented of their ways and removed that driver from Yosemite(?) Either way, I'm still not able to connect... Does anyone have any idea what might be preventing the connection or have ideas for how I might track down the problem (the returned FT_STATUS isn't very helpful...)?


UPDATE:
The answer, below, solved the problem for me. If you are unsure as to whether you might have a second, non-Apple VCP driver installed, you can find the other drivers by running the following command in a terminal:

kextstat | grep FTDI

which will output something like this:

  154    0 0xffffff7f831ee000 0x8000     0x8000     com.FTDI.driver.FTDIUSBSerialDriver (2.2.18) <96 16 5 4 3 1>
  155    0 0xffffff7f831f6000 0x7000     0x7000     com.apple.driver.AppleUSBFTDI (1.0.1b12) <96 16 5 4 3>

回答1:


No, that driver is still there on Yosemite. Running

sudo kextunload -b com.apple.driver.AppleUSBFTDI

still removes the relevant kext and frees the device for access via the D2XX library on this Yosemite system I just tested. The kext may be missing if you haven't yet connected your FTDI device to the system.

It may also be blocked by another virtual comm port driver. If you've installed FTDI's virtual comm port driver, that will also take control of the port and block the D2XX library from connecting. Certain Arduino dev kits also use virtual comm port drivers for the FTDI chips they use, so they may have installed their own driver. Check for that.

Finally, the device name of "FT232R USB UART" that I use in my example code may not be the name of your device. There are many FTDI variants, and you'd need to make sure you're using the name of your specific type of device. This can be obtained from the FT_ListDevices() command with the FT_LIST_BY_INDEX|FT_OPEN_BY_DESCRIPTION options. If you use the wrong device name, FT_OpenEx() can fail.



来源:https://stackoverflow.com/questions/28461433/unable-to-open-a-connection-to-an-ftdi-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!