⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libusb.h

📁 最新的libusb库
💻 H
📖 第 1 页 / 共 3 页
字号:
 */struct libusb_interface_descriptor {	/** Size of this descriptor (in bytes) */	uint8_t  bLength;	/** Descriptor type. Will have value	 * \ref libusb_descriptor_type::LIBUSB_DT_INTERFACE LIBUSB_DT_INTERFACE	 * in this context. */	uint8_t  bDescriptorType;	/** Number of this interface */	uint8_t  bInterfaceNumber;	/** Value used to select this alternate setting for this interface */	uint8_t  bAlternateSetting;	/** Number of endpoints used by this interface (excluding the control	 * endpoint). */	uint8_t  bNumEndpoints;		/** USB-IF class code for this interface. See \ref libusb_class_code. */	uint8_t  bInterfaceClass;	/** USB-IF subclass code for this interface, qualified by the	 * bInterfaceClass value */	uint8_t  bInterfaceSubClass;	/** USB-IF protocol code for this interface, qualified by the	 * bInterfaceClass and bInterfaceSubClass values */	uint8_t  bInterfaceProtocol;	/** Index of string descriptor describing this interface */	uint8_t  iInterface;	/** Array of endpoint descriptors. This length of this array is determined	 * by the bNumEndpoints field. */	const struct libusb_endpoint_descriptor *endpoint;	/** Extra descriptors. If libusb encounters unknown interface descriptors,	 * it will store them here, should you wish to parse them. */	const unsigned char *extra;	/** Length of the extra descriptors, in bytes. */	int extra_length;};/** \ingroup desc * A collection of alternate settings for a particular USB interface. */struct libusb_interface {	/** Array of interface descriptors. The length of this array is determined	 * by the num_altsetting field. */	const struct libusb_interface_descriptor *altsetting;	/** The number of alternate settings that belong to this interface */	int num_altsetting;};/** \ingroup desc * A structure representing the standard USB configuration descriptor. This * descriptor is documented in section 9.6.3 of the USB 2.0 specification. * All multiple-byte fields are represented in host-endian format. */struct libusb_config_descriptor {	/** Size of this descriptor (in bytes) */	uint8_t  bLength;	/** Descriptor type. Will have value	 * \ref libusb_descriptor_type::LIBUSB_DT_CONFIG LIBUSB_DT_CONFIG	 * in this context. */	uint8_t  bDescriptorType;	/** Total length of data returned for this configuration */	uint16_t wTotalLength;	/** Number of interfaces supported by this configuration */	uint8_t  bNumInterfaces;	/** Identifier value for this configuration */	uint8_t  bConfigurationValue;	/** Index of string descriptor describing this configuration */	uint8_t  iConfiguration;	/** Configuration characteristics */	uint8_t  bmAttributes;	/** Maximum power consumption of the USB device from this bus in this	 * configuration when the device is fully opreation. Expressed in units	 * of 2 mA. */	uint8_t  MaxPower;	/** Array of interfaces supported by this configuration. The length of	 * this array is determined by the bNumInterfaces field. */	const struct libusb_interface *interface;	/** Extra descriptors. If libusb encounters unknown configuration	 * descriptors, it will store them here, should you wish to parse them. */	const unsigned char *extra;	/** Length of the extra descriptors, in bytes. */	int extra_length;};/** \ingroup asyncio * Setup packet for control transfers. */struct libusb_control_setup {	/** Request type. Bits 0:4 determine recipient, see	 * \ref libusb_request_recipient. Bits 5:6 determine type, see	 * \ref libusb_request_type. Bit 7 determines data transfer direction, see	 * \ref libusb_endpoint_direction.	 */	uint8_t  bmRequestType;	/** Request. If the type bits of bmRequestType are equal to	 * \ref libusb_request_type::LIBUSB_REQUEST_TYPE_STANDARD	 * "LIBUSB_REQUEST_TYPE_STANDARD" then this field refers to	 * \ref libusb_standard_request. For other cases, use of this field is	 * application-specific. */	uint8_t  bRequest;	/** Value. Varies according to request */	uint16_t wValue;	/** Index. Varies according to request, typically used to pass an index	 * or offset */	uint16_t wIndex;	/** Number of bytes to transfer */	uint16_t wLength;};#define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup))/* libusb */struct libusb_context;struct libusb_device;struct libusb_device_handle;/** \ingroup lib * Structure representing a libusb session. The concept of individual libusb * sessions allows for your program to use two libraries (or dynamically * load two modules) which both independently use libusb. This will prevent * interference between the individual libusb users - for example * libusb_set_debug() will not affect the other user of the library, and * libusb_exit() will not destroy resources that the other user is still * using. * * Sessions are created by libusb_init() and destroyed through libusb_exit(). * If your application is guaranteed to only ever include a single libusb * user (i.e. you), you do not have to worry about contexts: pass NULL in * every function call where a context is required. The default context * will be used. * * For more information, see \ref contexts. */typedef struct libusb_context libusb_context;/** \ingroup dev * Structure representing a USB device detected on the system. This is an * opaque type for which you are only ever provided with a pointer, usually * originating from libusb_get_device_list(). * * Certain operations can be performed on a device, but in order to do any * I/O you will have to first obtain a device handle using libusb_open(). * * Devices are reference counted with libusb_device_ref() and * libusb_device_unref(), and are freed when the reference count reaches 0. * New devices presented by libusb_get_device_list() have a reference count of * 1, and libusb_free_device_list() can optionally decrease the reference count * on all devices in the list. libusb_open() adds another reference which is * later destroyed by libusb_close(). */typedef struct libusb_device libusb_device;/** \ingroup dev * Structure representing a handle on a USB device. This is an opaque type for * which you are only ever provided with a pointer, usually originating from * libusb_open(). * * A device handle is used to perform I/O and other operations. When finished * with a device handle, you should call libusb_close(). */typedef struct libusb_device_handle libusb_device_handle;/** \ingroup misc * Error codes. Most libusb functions return 0 on success or one of these * codes on failure. */enum libusb_error {	/** Success (no error) */	LIBUSB_SUCCESS = 0,	/** Input/output error */	LIBUSB_ERROR_IO = -1,	/** Invalid parameter */	LIBUSB_ERROR_INVALID_PARAM = -2,	/** Access denied (insufficient permissions) */	LIBUSB_ERROR_ACCESS = -3,	/** No such device (it may have been disconnected) */	LIBUSB_ERROR_NO_DEVICE = -4,	/** Entity not found */	LIBUSB_ERROR_NOT_FOUND = -5,	/** Resource busy */	LIBUSB_ERROR_BUSY = -6,	/** Operation timed out */	LIBUSB_ERROR_TIMEOUT = -7,	/** Overflow */	LIBUSB_ERROR_OVERFLOW = -8,	/** Pipe error */	LIBUSB_ERROR_PIPE = -9,	/** System call interrupted (perhaps due to signal) */	LIBUSB_ERROR_INTERRUPTED = -10,	/** Insufficient memory */	LIBUSB_ERROR_NO_MEM = -11,	/** Operation not supported or unimplemented on this platform */	LIBUSB_ERROR_NOT_SUPPORTED = -12,	/** Other error */	LIBUSB_ERROR_OTHER = -99,};/** \ingroup asyncio * Transfer status codes */enum libusb_transfer_status {	/** Transfer completed without error. Note that this does not indicate	 * that the entire amount of requested data was transferred. */	LIBUSB_TRANSFER_COMPLETED,	/** Transfer failed */	LIBUSB_TRANSFER_ERROR,	/** Transfer timed out */	LIBUSB_TRANSFER_TIMED_OUT,	/** Transfer was cancelled */	LIBUSB_TRANSFER_CANCELLED,	/** For bulk/interrupt endpoints: halt condition detected (endpoint	 * stalled). For control endpoints: control request not supported. */	LIBUSB_TRANSFER_STALL,	/** Device was disconnected */	LIBUSB_TRANSFER_NO_DEVICE,	/** Device sent more data than requested */	LIBUSB_TRANSFER_OVERFLOW,};/** \ingroup asyncio * libusb_transfer.flags values */enum libusb_transfer_flags {	/** Report short frames as errors */	LIBUSB_TRANSFER_SHORT_NOT_OK = 1<<0,	/** Automatically free() transfer buffer during libusb_free_transfer() */	LIBUSB_TRANSFER_FREE_BUFFER = 1<<1,	/** Automatically call libusb_free_transfer() after callback returns.	 * If this flag is set, it is illegal to call libusb_free_transfer() 	 * from your transfer callback, as this will result in a double-free	 * when this flag is acted upon. */	LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2,};/** \ingroup asyncio * Isochronous packet descriptor. */struct libusb_iso_packet_descriptor {	/** Length of data to request in this packet */	unsigned int length;	/** Amount of data that was actually transferred */	unsigned int actual_length;	/** Status code for this packet */	enum libusb_transfer_status status;};struct libusb_transfer;typedef void (*libusb_transfer_cb_fn)(struct libusb_transfer *transfer);/** \ingroup asyncio * The generic USB transfer structure. */struct libusb_transfer {	/** Handle of the device that this transfer will be submitted to */	libusb_device_handle *dev_handle;	/** A bitwise OR combination of \ref libusb_transfer_flags. */	uint8_t flags;	/** Address of the endpoint where this transfer will be sent. */	unsigned char endpoint;	/** Type of the endpoint from \ref libusb_transfer_type */	unsigned char type;	/** Timeout for this transfer in millseconds. A value of 0 indicates no	 * timeout. */	unsigned int timeout;	/** The status of the transfer. Read-only, and only for use within	 * transfer callback function.	 *	 * If this is an isochronous transfer, this field may read COMPLETED even	 * if there were errors in the frames. Use the	 * \ref libusb_iso_packet_descriptor::status "status" field in each packet	 * to determine if errors occurred. */	enum libusb_transfer_status status;	/** Length of the data buffer */	int length;	/** Actual length of data that was transferred. Read-only, and only for	 * use within transfer callback function. Not valid for isochronous	 * endpoint transfers. */	int actual_length;	/** Callback function. This will be invoked when the transfer completes,	 * fails, or is cancelled. */	libusb_transfer_cb_fn callback;	/** User context data to pass to the callback function. */	void *user_data;	/** Data buffer */	unsigned char *buffer;	/** Number of isochronous packets. Only used for I/O with isochronous	 * endpoints. */	int num_iso_packets;	/** Isochronous packet descriptors, for isochronous transfers only. */	struct libusb_iso_packet_descriptor iso_packet_desc[0];};int libusb_init(libusb_context **ctx);void libusb_exit(libusb_context *ctx);void libusb_set_debug(libusb_context *ctx, int level);ssize_t libusb_get_device_list(libusb_context *ctx,	libusb_device ***list);void libusb_free_device_list(libusb_device **list, int unref_devices);libusb_device *libusb_ref_device(libusb_device *dev);void libusb_unref_device(libusb_device *dev);int libusb_get_device_descriptor(libusb_device *dev,	struct libusb_device_descriptor *desc);int libusb_get_active_config_descriptor(libusb_device *dev,	struct libusb_config_descriptor **config);int libusb_get_config_descriptor(libusb_device *dev, uint8_t config_index,	struct libusb_config_descriptor **config);int libusb_get_config_descriptor_by_value(libusb_device *dev,	uint8_t bConfigurationValue, struct libusb_config_descriptor **config);void libusb_free_config_descriptor(struct libusb_config_descriptor *config);uint8_t libusb_get_bus_number(libusb_device *dev);uint8_t libusb_get_device_address(libusb_device *dev);int libusb_get_max_packet_size(libusb_device *dev, unsigned char endpoint);int libusb_open(libusb_device *dev, libusb_device_handle **handle);void libusb_close(libusb_device_handle *dev_handle);libusb_device *libusb_get_device(libusb_device_handle *dev_handle);int libusb_set_configuration(libusb_device_handle *dev, int configuration);int libusb_claim_interface(libusb_device_handle *dev, int iface);int libusb_release_interface(libusb_device_handle *dev, int iface);libusb_device_handle *libusb_open_device_with_vid_pid(libusb_context *ctx,	uint16_t vendor_id, uint16_t product_id);int libusb_set_interface_alt_setting(libusb_device_handle *dev,	int interface_number, int alternate_setting);int libusb_clear_halt(libusb_device_handle *dev, unsigned char endpoint);int libusb_reset_device(libusb_device_handle *dev);int libusb_kernel_driver_active(libusb_device_handle *dev, int interface);int libusb_detach_kernel_driver(libusb_device_handle *dev, int interface);/* async I/O *//** \ingroup asyncio * Get the data section of a control transfer. This convenience function is here * to remind you that the data does not start until 8 bytes into the actual * buffer, as the setup packet comes first.  *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -