zhm@Ubuntu:~/Jetson/StructLight/CyUSBSerial_SDK_Linux/linux/library$ lsusb Bus001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus001 Device 002: ID 0bda:8771 Realtek Semiconductor Corp. Bluetooth Radio Bus001 Device 003: ID 0000:3825 USB OPTICAL MOUSE Bus001 Device 004: ID 1c4f:0026 SiGma Micro Keyboard Bus001 Device 005: ID 05e3:0608 Genesys Logic, Inc. Hub Bus001 Device 018: ID 04b4:000a Cypress Semiconductor Corp. USB-Serial (Dual Channel) Bus002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
/* Summary This API retrieves number of USB devices connected to the host.
Description This API retrieves the number of devices connected to the host. In Windows family of operating systems the API retrieves only the number of devices that are attached to CyUSB3.SYS driver. For other operating systems, it retrieves the total number of USB devices present on the bus. It includes both USB Serial device as well as other devices.
Note: In case of Linux and Mac apart from providing number of devices connected, it builds the device list which is used for opening the device and obtaining device handle. Thus the API should be called during device discovery in the application.
Return Value * CY_SUCCESS on success * CY_ERROR_DEVICE_NOT_FOUND if there are no devices attached. * CY_ERROR_REQUEST_FAILED if library was not initialized.
See Also * CyGetDeviceInfo * CyGetDeviceInfoVidPid * CyOpen * CyClose */ CYWINEXPORT CY_RETURN_STATUS CyGetListofDevices( UINT8* numDevices /*Number of Devices connected*/ );
定位到这里CY_ERROR_REQUEST_FAILED if library was not initialized.出现的原因是,因为library没有初始化。修改GetCyI2CHandle(CY_HANDLE* Handle)代码,添加初始化函数: