openusb_get_device_data,openusb_free_device_data

Name

openusb_get_device_data,openusb_free_device_data  -- Get a device's data, Free the device data

Synopsis

int32_t openusb_get_device_data(openusb_handle_t handle , openusb_devid_t devid , uint32_t flags , openusb_dev_data_t **data);

void openusb_free_device_data(openusb_dev_data_t *data);

Parameters

handle - Libusb handle.

devid - Device's devid.

flags - Reserved.

data - Data returned by openusb of type openusb_dev_data_t

Description

openusb_get_device_data() will return data of the specified device. Application doesn't have to open the device before calling this function.The data is stored in the openusb_dev_data_t structure, which has such members:

    
            openusb_busid_t          busid; /* busid of the bus this device is on */
            openusb_devid_t          devid; /* devid of this device */
    
            /* bus address of the bus the device is on */
            uint8_t                 bus_address;
    
            /* parent device id, 0 for root-hub */
            openusb_devid_t          pdevid;
    
            /* parent port the device is connected to */
            uint8_t                 pport;
    
            /* number of ports on the device, 0 for non-hub device */
            uint8_t                 nports;
    
            /* descriptive path such as /dev/bus/usb/xxx */
            char                    *sys_path;
    
            /* topological path such as 1.2.1 */
            char                    *bus_path;
    
            usb_device_desc_t       dev_desc; /* device descriptor */
            usb_config_desc_t       cfg_desc; /* configuration descriptors */
    
            /* raw configuration desc cloud */
            uint8_t                 *raw_cfg_desc;
    
            /* string descriptors with the first langid */
            usb_string_desc_t       *manufacturer;
            usb_string_desc_t       *product;
            usb_string_desc_t       *serialnumber;
    
            /* max transfer size for each request, 0 if not supported */
            uint32_t                ctrl_max_xfer_size;
            uint32_t                intr_max_xfer_size;
            uint32_t                bulk_max_xfer_size;
            uint32_t                isoc_max_xfer_size;
    	

Application should call openusb_free_device_data to free memory space allocated in openusb_get_device_data.

Return Value

openusb_get_device_data() may have such return values:

OPENUSB_SUCCESS - Success.

OPENUSB_NO_RESOURCES - Memory allocation failure.

OPENUSB_UNKNOWN_DEVICE - Can't find the device specified by devid.

OPENUSB_PARSE_ERROR - Libusb fails to get device, configuration or string descriptors of this device.

OPENUSB_INVALID_HANDLE - Libusb handle is invalid.

See Also

openusb_init, openusb_fini