1
我正在嘗試使用libft4222與FT4222芯片進行通信。當我運行由FTDI提供的以下示例代碼時,我在Windows和Linux平臺之間收到不同的響應。FT4222設備信息在Windows下正確,在Linux下不正確?
示例代碼:
FT_STATUS ftStatus;
FT_DEVICE_LIST_INFO_NODE *devInfo;
DWORD numDevs;
// create the device information list
ftStatus = FT_CreateDeviceInfoList(&numDevs);
if (ftStatus == FT_OK) {
printf("Number of devices is %d\n",numDevs);
}
if (numDevs > 0) {
// allocate storage for list based on numDevs
devInfo =
(FT_DEVICE_LIST_INFO_NODE*)malloc(sizeof(FT_DEVICE_LIST_INFO_NODE)*numDevs);
// get the device information list
ftStatus = FT_GetDeviceInfoList(devInfo,&numDevs);
if (ftStatus == FT_OK) {
for (int i = 0; i < numDevs; i++) {
printf("Dev %d:\n",i);
printf(" Flags=0x%x\n",devInfo[i].Flags);
printf(" Type=0x%x\n",devInfo[i].Type);
printf(" ID=0x%x\n",devInfo[i].ID);
printf(" LocId=0x%x\n",devInfo[i].LocId);
printf(" SerialNumber=%s\n",devInfo[i].SerialNumber);
printf(" Description=%s\n",devInfo[i].Description);
printf(" ftHandle=0x%x\n",devInfo[i].ftHandle);
}
}
}
在Windows上,我收到下面的輸出,這看起來是正確的:
Dev 0:
Flags= 0x2, (CLOSE-HS)
Type= 0xa
ID= 0x403601c
LocId= 0x1131
SerialNumber= A
Description= FT4222 A
ftHandle= 0x0
Dev 1:
Flags= 0x0, (CLOSE-FS)
Type= 0xa
ID= 0x403601c
LocId= 0x1132
SerialNumber= B
Description= FT4222 B
ftHandle= 0x0
在Linux(64位Ubuntu的,運行libft4222的i386的版本,我的測試應用程序)我收到以下輸出,看起來不正確:
Dev 0:
Flags= 0x1, (OPEN-FS)
Type= 0x3
ID= 0x0
LocId= 0x0
SerialNumber=
Description=
ftHandle= 0x0
Dev 1:
Flags= 0x1, (OPEN-FS)
Type= 0x3
ID= 0x0
LocId= 0x0
SerialNumber=
Description=
ftHandle= 0x0
我很好奇爲什麼系統之間的區別?爲什麼一個顯示爲關閉而另一個顯示爲打開?
編輯: -v的lsusb顯示該設備的以下:
Bus 001 Device 015: ID 0403:601c Future Technology Devices International, Ltd
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0403 Future Technology Devices International, Ltd
idProduct 0x601c
bcdDevice 18.00
iManufacturer 1
iProduct 2
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 55
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 2
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 2
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 0
那麼'lsusb'說什麼? – Olaf
@Olaf作爲編輯添加到主文章中 – schumacher574
您添加C++標記的任何原因?快速一瞥,代碼看起來像是純粹的C.你使用C或C++編譯器嗎? – Olaf