我正在尝试以波特率 3750000 但在 OSX 上与连接到 EasySync USB2-H-5004-M USB 到 RS485 转换器的 USB 设备通话。
我有一些在 Windows 上运行的 c++ 代码,并且刚刚设法让它在 OSX 上编译(使用 D2XX dylib 而不是 dll),但是我在某处的通信有问题,我不确定从哪里开始以及如何解决这个问题。
我正在使用 openFrameworks/c++,列出设备的方法如下所示:
int FTDI::enumerateDevices(){
DWORD numDevs;
FT_STATUS ftStatus = FT_CreateDeviceInfoList(&numDevs);
numPortsFound = 0;
if (ftStatus == FT_OK) {
ofLog(OF_LOG_NOTICE, "Number of FTDI devices is %d",numDevs);
devicesList = (FT_DEVICE_LIST_INFO_NODE*)malloc(sizeof(FT_DEVICE_LIST_INFO_NODE)*numDevs);
ftStatus = FT_GetDeviceInfoList(devicesList, &numDevs);
if (ftStatus == FT_OK) {
printf("\n");
for (int i = 0; i < numDevs; i++) {
ofLog(OF_LOG_VERBOSE, "Dev %d:",i);
ofLog(OF_LOG_VERBOSE, " Flags=0x%x",devicesList[i].Flags);
ofLog(OF_LOG_VERBOSE, " Type=0x%x",devicesList[i].Type);
ofLog(OF_LOG_VERBOSE, " ID=0x%x",devicesList[i].ID);
ofLog(OF_LOG_VERBOSE, " LocId=0x%x",devicesList[i].LocId);
ofLog(OF_LOG_VERBOSE, " SerialNumber=%s",devicesList[i].SerialNumber);
ofLog(OF_LOG_VERBOSE, " Description=%s",devicesList[i].Description);
ofLog(OF_LOG_VERBOSE, " ftHandle=0x%x\n",devicesList[i].ftHandle);
}
numPortsFound = numDevs;
} else {
ofLog(OF_LOG_ERROR, "FTD2XX::FT_GetDeviceInfoList() failed");
}
} else {
ofLog(OF_LOG_ERROR, "FTD2XX::FT_CreateDeviceInfoList() failed");
}
return numPortsFound;
}
问题出在 OSX 上,我得到以下输出:
[notice ] Number of FTDI devices is 4
[verbose] Dev 0:
[verbose] Flags=0x1
[verbose] Type=0x3
[verbose] ID=0x0
[verbose] LocId=0x0
[verbose] SerialNumber=
[verbose] Description=
[verbose] ftHandle=0x0
[verbose] Dev 1:
[verbose] Flags=0x1
[verbose] Type=0x3
[verbose] ID=0x0
[verbose] LocId=0x0
[verbose] SerialNumber=
[verbose] Description=
[verbose] ftHandle=0x0
[verbose] Dev 2:
[verbose] Flags=0x1
[verbose] Type=0x3
[verbose] ID=0x0
[verbose] LocId=0x0
[verbose] SerialNumber=
[verbose] Description=
[verbose] ftHandle=0x0
[verbose] Dev 3:
[verbose] Flags=0x1
[verbose] Type=0x3
[verbose] ID=0x0
[verbose] LocId=0x0
[verbose] SerialNumber=
[verbose] Description=
[verbose] ftHandle=0x0
[ error ] failed to register FTDI device with serial FTWVZVEBA in internal register
[ error ] error opening port with serial: FTWVZVEBA
这看起来不对。例如在 Windows 上,在端口 A/通道 1/设备索引 0 上,我看到:
[verbose] Dev 0:
[verbose] Flags=0x2
[verbose] Type=0x7
[verbose] ID=0x4036011
[verbose] LocId=0x02111
[verbose] SerialNumber=FTWVZVEBA
[verbose] Description=USB2-H-5004-M A
[verbose] ftHandle=0x0
快速查看 /dev 看起来还不错:
ls /dev/tty.*
/dev/tty.Bluetooth-Incoming-Port /dev/tty.usbserial-FTWVZVEBB
/dev/tty.Bluetooth-Modem /dev/tty.usbserial-FTWVZVEBC
/dev/tty.usbmodemfa131 /dev/tty.usbserial-FTWVZVEBD
并通过系统信息我得到:
USB2-H-5004-M:
Product ID: 0x6011
Vendor ID: 0x0403 (Future Technology Devices International Limited)
Version: 8.00
Serial Number: FTWVZVEB
Speed: Up to 480 Mb/sec
Manufacturer: FTDI
Location ID: 0xfd120000 / 4
Current Available (mA): 500
Current Required (mA): 200
我已按照FTDI OSX 安装指南(pdf 链接)中的说明安装了 D2XX 驱动程序,但我不确定我缺少什么/做错了什么。
如何使用 FTDI D2XX 库与设备正确通信?