Terminalausgabe Testprogramm



  • @Timo_R

    und weiter im Text:

    
    #define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup))
    
    /* libusb */
    
    struct libusb_context;
    struct libusb_device;
    struct libusb_device_handle;
    
    /** \ingroup libusb_lib
     * Structure providing the version of the libusb runtime
     */
    struct libusb_version {
    	/** Library major version. */
    	const uint16_t major;
    
    	/** Library minor version. */
    	const uint16_t minor;
    
    	/** Library micro version. */
    	const uint16_t micro;
    
    	/** Library nano version. */
    	const uint16_t nano;
    
    	/** Library release candidate suffix string, e.g. "-rc4". */
    	const char *rc;
    
    	/** For ABI compatibility only. */
    	const char* describe;
    };
    
    /** \ingroup libusb_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_option() 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 libusb_contexts.
     */
    typedef struct libusb_context libusb_context;
    
    /** \ingroup libusb_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_ref_device() and
     * libusb_unref_device(), 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 libusb_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 libusb_dev
     * Speed codes. Indicates the speed at which the device is operating.
     */
    enum libusb_speed {
    	/** The OS doesn't report or know the device speed. */
    	LIBUSB_SPEED_UNKNOWN = 0,
    
    	/** The device is operating at low speed (1.5MBit/s). */
    	LIBUSB_SPEED_LOW = 1,
    
    	/** The device is operating at full speed (12MBit/s). */
    	LIBUSB_SPEED_FULL = 2,
    
    	/** The device is operating at high speed (480MBit/s). */
    	LIBUSB_SPEED_HIGH = 3,
    
    	/** The device is operating at super speed (5000MBit/s). */
    	LIBUSB_SPEED_SUPER = 4,
    
    	/** The device is operating at super speed plus (10000MBit/s). */
    	LIBUSB_SPEED_SUPER_PLUS = 5,
    };
    
    /** \ingroup libusb_dev
     * Supported speeds (wSpeedSupported) bitfield. Indicates what
     * speeds the device supports.
     */
    enum libusb_supported_speed {
    	/** Low speed operation supported (1.5MBit/s). */
    	LIBUSB_LOW_SPEED_OPERATION   = 1,
    
    	/** Full speed operation supported (12MBit/s). */
    	LIBUSB_FULL_SPEED_OPERATION  = 2,
    
    	/** High speed operation supported (480MBit/s). */
    	LIBUSB_HIGH_SPEED_OPERATION  = 4,
    
    	/** Superspeed operation supported (5000MBit/s). */
    	LIBUSB_SUPER_SPEED_OPERATION = 8,
    };
    
    /** \ingroup libusb_dev
     * Masks for the bits of the
     * \ref libusb_usb_2_0_extension_descriptor::bmAttributes "bmAttributes" field
     * of the USB 2.0 Extension descriptor.
     */
    enum libusb_usb_2_0_extension_attributes {
    	/** Supports Link Power Management (LPM) */
    	LIBUSB_BM_LPM_SUPPORT = 2,
    };
    
    /** \ingroup libusb_dev
     * Masks for the bits of the
     * \ref libusb_ss_usb_device_capability_descriptor::bmAttributes "bmAttributes" field
     * field of the SuperSpeed USB Device Capability descriptor.
     */
    enum libusb_ss_usb_device_capability_attributes {
    	/** Supports Latency Tolerance Messages (LTM) */
    	LIBUSB_BM_LTM_SUPPORT = 2,
    };
    
    /** \ingroup libusb_dev
     * USB capability types
     */
    enum libusb_bos_type {
    	/** Wireless USB device capability */
    	LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY	= 1,
    
    	/** USB 2.0 extensions */
    	LIBUSB_BT_USB_2_0_EXTENSION			= 2,
    
    	/** SuperSpeed USB device capability */
    	LIBUSB_BT_SS_USB_DEVICE_CAPABILITY		= 3,
    
    	/** Container ID type */
    	LIBUSB_BT_CONTAINER_ID				= 4,
    };
    
    /** \ingroup libusb_misc
     * Error codes. Most libusb functions return 0 on success or one of these
     * codes on failure.
     * You can call libusb_error_name() to retrieve a string representation of an
     * error code or libusb_strerror() to get an end-user suitable description of
     * an error code.
     */
    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,
    
    	/* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the
    	   message strings in strerror.c when adding new error codes here. */
    
    	/** Other error */
    	LIBUSB_ERROR_OTHER = -99,
    };
    
    /* Total number of error codes in enum libusb_error */
    #define LIBUSB_ERROR_COUNT 14
    
    /** \ingroup libusb_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,
    
    	/* NB! Remember to update libusb_error_name()
    	   when adding new status codes here. */
    };
    
    /** \ingroup libusb_asyncio
     * libusb_transfer.flags values */
    enum libusb_transfer_flags {
    	/** Report short frames as errors */
    	LIBUSB_TRANSFER_SHORT_NOT_OK = 1U << 0,
    
    	/** Automatically free() transfer buffer during libusb_free_transfer().
    	 * Note that buffers allocated with libusb_dev_mem_alloc() should not
    	 * be attempted freed in this way, since free() is not an appropriate
    	 * way to release such memory. */
    	LIBUSB_TRANSFER_FREE_BUFFER = 1U << 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 = 1U << 2,
    
    	/** Terminate transfers that are a multiple of the endpoint's
    	 * wMaxPacketSize with an extra zero length packet. This is useful
    	 * when a device protocol mandates that each logical request is
    	 * terminated by an incomplete packet (i.e. the logical requests are
    	 * not separated by other means).
    	 *
    	 * This flag only affects host-to-device transfers to bulk and interrupt
    	 * endpoints. In other situations, it is ignored.
    	 *
    	 * This flag only affects transfers with a length that is a multiple of
    	 * the endpoint's wMaxPacketSize. On transfers of other lengths, this
    	 * flag has no effect. Therefore, if you are working with a device that
    	 * needs a ZLP whenever the end of the logical request falls on a packet
    	 * boundary, then it is sensible to set this flag on <em>every</em>
    	 * transfer (you do not have to worry about only setting it on transfers
    	 * that end on the boundary).
    	 *
    	 * This flag is currently only supported on Linux.
    	 * On other systems, libusb_submit_transfer() will return
    	 * LIBUSB_ERROR_NOT_SUPPORTED for every transfer where this flag is set.
    	 *
    	 * Available since libusb-1.0.9.
    	 */
    	LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1U << 3,
    };
    
    /** \ingroup libusb_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;
    
    /** \ingroup libusb_asyncio
     * Asynchronous transfer callback function type. When submitting asynchronous
     * transfers, you pass a pointer to a callback function of this type via the
     * \ref libusb_transfer::callback "callback" member of the libusb_transfer
     * structure. libusb will call this function later, when the transfer has
     * completed or failed. See \ref libusb_asyncio for more information.
     * \param transfer The libusb_transfer struct the callback function is being
     * notified about.
     */
    typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer);
    
    /** \ingroup libusb_asyncio
     * The generic USB transfer structure. The user populates this structure and
     * then submits it in order to request a transfer. After the transfer has
     * completed, the library populates the transfer with the results and passes
     * it back to the user.
     */
    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 milliseconds. 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. Must be non-negative. */
    	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. Must be non-negative. */
    	int num_iso_packets;
    
    	/** Isochronous packet descriptors, for isochronous transfers only. */
    	struct libusb_iso_packet_descriptor iso_packet_desc[ZERO_SIZED_ARRAY];
    };
    
    /** \ingroup libusb_misc
     * Capabilities supported by an instance of libusb on the current running
     * platform. Test if the loaded library supports a given capability by calling
     * \ref libusb_has_capability().
     */
    enum libusb_capability {
    	/** The libusb_has_capability() API is available. */
    	LIBUSB_CAP_HAS_CAPABILITY = 0x0000,
    	/** Hotplug support is available on this platform. */
    	LIBUSB_CAP_HAS_HOTPLUG = 0x0001,
    	/** The library can access HID devices without requiring user intervention.
    	 * Note that before being able to actually access an HID device, you may
    	 * still have to call additional libusb functions such as
    	 * \ref libusb_detach_kernel_driver(). */
    	LIBUSB_CAP_HAS_HID_ACCESS = 0x0100,
    	/** The library supports detaching of the default USB driver, using 
    	 * \ref libusb_detach_kernel_driver(), if one is set by the OS kernel */
    	LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101
    };
    
    /** \ingroup libusb_lib
     *  Log message levels.
     *  - LIBUSB_LOG_LEVEL_NONE (0)    : no messages ever printed by the library (default)
     *  - LIBUSB_LOG_LEVEL_ERROR (1)   : error messages are printed to stderr
     *  - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
     *  - LIBUSB_LOG_LEVEL_INFO (3)    : informational messages are printed to stderr
     *  - LIBUSB_LOG_LEVEL_DEBUG (4)   : debug and informational messages are printed to stderr
     */
    enum libusb_log_level {
    	LIBUSB_LOG_LEVEL_NONE = 0,
    	LIBUSB_LOG_LEVEL_ERROR = 1,
    	LIBUSB_LOG_LEVEL_WARNING = 2,
    	LIBUSB_LOG_LEVEL_INFO = 3,
    	LIBUSB_LOG_LEVEL_DEBUG = 4,
    };
    
    /** \ingroup libusb_lib
     *  Log callback mode.
     * \see libusb_set_log_cb()
     */
    enum libusb_log_cb_mode {
    
    	/** Callback function handling all log mesages. */
    	LIBUSB_LOG_CB_GLOBAL = 1 << 0,
    
    	/** Callback function handling context related log mesages. */
    	LIBUSB_LOG_CB_CONTEXT = 1 << 1
    };
    
    /** \ingroup libusb_lib
     * Callback function for handling log messages.
     * \param ctx the context which is related to the log message, or NULL if it
     * is a global log message
     * \param level the log level, see \ref libusb_log_level for a description
     * \param str the log message
     * \see libusb_set_log_cb()
     */
    typedef void (LIBUSB_CALL *libusb_log_cb)(libusb_context *ctx,
    	enum libusb_log_level level, const char *str);
    
    int LIBUSB_CALL libusb_init(libusb_context **ctx);
    void LIBUSB_CALL libusb_exit(libusb_context *ctx);
    LIBUSB_DEPRECATED_FOR(libusb_set_option)
    void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
    void LIBUSB_CALL libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, int mode);
    const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
    int LIBUSB_CALL libusb_has_capability(uint32_t capability);
    const char * LIBUSB_CALL libusb_error_name(int errcode);
    int LIBUSB_CALL libusb_setlocale(const char *locale);
    const char * LIBUSB_CALL libusb_strerror(enum libusb_error errcode);
    
    ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,
    	libusb_device ***list);
    void LIBUSB_CALL libusb_free_device_list(libusb_device **list,
    	int unref_devices);
    libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev);
    void LIBUSB_CALL libusb_unref_device(libusb_device *dev);
    
    int LIBUSB_CALL libusb_get_configuration(libusb_device_handle *dev,
    	int *config);
    int LIBUSB_CALL libusb_get_device_descriptor(libusb_device *dev,
    	struct libusb_device_descriptor *desc);
    int LIBUSB_CALL libusb_get_active_config_descriptor(libusb_device *dev,
    	struct libusb_config_descriptor **config);
    int LIBUSB_CALL libusb_get_config_descriptor(libusb_device *dev,
    	uint8_t config_index, struct libusb_config_descriptor **config);
    int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev,
    	uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
    void LIBUSB_CALL libusb_free_config_descriptor(
    	struct libusb_config_descriptor *config);
    int LIBUSB_CALL libusb_get_ss_endpoint_companion_descriptor(
    	struct libusb_context *ctx,
    	const struct libusb_endpoint_descriptor *endpoint,
    	struct libusb_ss_endpoint_companion_descriptor **ep_comp);
    void LIBUSB_CALL libusb_free_ss_endpoint_companion_descriptor(
    	struct libusb_ss_endpoint_companion_descriptor *ep_comp);
    int LIBUSB_CALL libusb_get_bos_descriptor(libusb_device_handle *dev_handle,
    	struct libusb_bos_descriptor **bos);
    void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
    int LIBUSB_CALL libusb_get_usb_2_0_extension_descriptor(
    	struct libusb_context *ctx,
    	struct libusb_bos_dev_capability_descriptor *dev_cap,
    	struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension);
    void LIBUSB_CALL libusb_free_usb_2_0_extension_descriptor(
    	struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
    int LIBUSB_CALL libusb_get_ss_usb_device_capability_descriptor(
    	struct libusb_context *ctx,
    	struct libusb_bos_dev_capability_descriptor *dev_cap,
    	struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap);
    void LIBUSB_CALL libusb_free_ss_usb_device_capability_descriptor(
    	struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap);
    int LIBUSB_CALL libusb_get_container_id_descriptor(struct libusb_context *ctx,
    	struct libusb_bos_dev_capability_descriptor *dev_cap,
    	struct libusb_container_id_descriptor **container_id);
    void LIBUSB_CALL libusb_free_container_id_descriptor(
    	struct libusb_container_id_descriptor *container_id);
    uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev);
    uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev);
    int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len);
    LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)
    int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* path, uint8_t path_length);
    libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev);
    uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev);
    int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev);
    int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev,
    	unsigned char endpoint);
    int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev,
    	unsigned char endpoint);
    
    int LIBUSB_CALL libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, libusb_device_handle **dev_handle);
    int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **dev_handle);
    void LIBUSB_CALL libusb_close(libusb_device_handle *dev_handle);
    libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_handle);
    
    int LIBUSB_CALL libusb_set_configuration(libusb_device_handle *dev_handle,
    	int configuration);
    int LIBUSB_CALL libusb_claim_interface(libusb_device_handle *dev_handle,
    	int interface_number);
    int LIBUSB_CALL libusb_release_interface(libusb_device_handle *dev_handle,
    	int interface_number);
    
    libusb_device_handle * LIBUSB_CALL libusb_open_device_with_vid_pid(
    	libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);
    
    int LIBUSB_CALL libusb_set_interface_alt_setting(libusb_device_handle *dev_handle,
    	int interface_number, int alternate_setting);
    int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev_handle,
    	unsigned char endpoint);
    int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev_handle);
    
    int LIBUSB_CALL libusb_alloc_streams(libusb_device_handle *dev_handle,
    	uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
    int LIBUSB_CALL libusb_free_streams(libusb_device_handle *dev_handle,
    	unsigned char *endpoints, int num_endpoints);
    
    unsigned char * LIBUSB_CALL libusb_dev_mem_alloc(libusb_device_handle *dev_handle,
    	size_t length);
    int LIBUSB_CALL libusb_dev_mem_free(libusb_device_handle *dev_handle,
    	unsigned char *buffer, size_t length);
    
    int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev_handle,
    	int interface_number);
    int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev_handle,
    	int interface_number);
    int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev_handle,
    	int interface_number);
    int LIBUSB_CALL libusb_set_auto_detach_kernel_driver(
    	libusb_device_handle *dev_handle, int enable);
    
    /* async I/O */
    
    /** \ingroup libusb_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.
     *
     * Calling this function only makes sense from a transfer callback function,
     * or situations where you have already allocated a suitably sized buffer at
     * transfer->buffer.
     *
     * \param transfer a transfer
     * \returns pointer to the first byte of the data section
     */
    static inline unsigned char *libusb_control_transfer_get_data(
    	struct libusb_transfer *transfer)
    {
    	return transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
    }
    
    /** \ingroup libusb_asyncio
     * Get the control setup packet of a control transfer. This convenience
     * function is here to remind you that the control setup occupies the first
     * 8 bytes of the transfer data buffer.
     *
     * Calling this function only makes sense from a transfer callback function,
     * or situations where you have already allocated a suitably sized buffer at
     * transfer->buffer.
     *
     * \param transfer a transfer
     * \returns a casted pointer to the start of the transfer data buffer
     */
    static inline struct libusb_control_setup *libusb_control_transfer_get_setup(
    	struct libusb_transfer *transfer)
    {
    	return (struct libusb_control_setup *)(void *) transfer->buffer;
    }
    
    /** \ingroup libusb_asyncio
     * Helper function to populate the setup packet (first 8 bytes of the data
     * buffer) for a control transfer. The wIndex, wValue and wLength values should
     * be given in host-endian byte order.
     *
     * \param buffer buffer to output the setup packet into
     * This pointer must be aligned to at least 2 bytes boundary.
     * \param bmRequestType see the
     * \ref libusb_control_setup::bmRequestType "bmRequestType" field of
     * \ref libusb_control_setup
     * \param bRequest see the
     * \ref libusb_control_setup::bRequest "bRequest" field of
     * \ref libusb_control_setup
     * \param wValue see the
     * \ref libusb_control_setup::wValue "wValue" field of
     * \ref libusb_control_setup
     * \param wIndex see the
     * \ref libusb_control_setup::wIndex "wIndex" field of
     * \ref libusb_control_setup
     * \param wLength see the
     * \ref libusb_control_setup::wLength "wLength" field of
     * \ref libusb_control_setup
     */
    static inline void libusb_fill_control_setup(unsigned char *buffer,
    	uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
    	uint16_t wLength)
    {
    	struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
    	setup->bmRequestType = bmRequestType;
    	setup->bRequest = bRequest;
    	setup->wValue = libusb_cpu_to_le16(wValue);
    	setup->wIndex = libusb_cpu_to_le16(wIndex);
    	setup->wLength = libusb_cpu_to_le16(wLength);
    }
    
    struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets);
    int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer);
    int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer);
    void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
    void LIBUSB_CALL libusb_transfer_set_stream_id(
    	struct libusb_transfer *transfer, uint32_t stream_id);
    uint32_t LIBUSB_CALL libusb_transfer_get_stream_id(
    	struct libusb_transfer *transfer);
    
    /** \ingroup libusb_asyncio
     * Helper function to populate the required \ref libusb_transfer fields
     * for a control transfer.
     *
     * If you pass a transfer buffer to this function, the first 8 bytes will
     * be interpreted as a control setup packet, and the wLength field will be
     * used to automatically populate the \ref libusb_transfer::length "length"
     * field of the transfer. Therefore the recommended approach is:
     * -# Allocate a suitably sized data buffer (including space for control setup)
     * -# Call libusb_fill_control_setup()
     * -# If this is a host-to-device transfer with a data stage, put the data
     *    in place after the setup packet
     * -# Call this function
     * -# Call libusb_submit_transfer()
     *
     * It is also legal to pass a NULL buffer to this function, in which case this
     * function will not attempt to populate the length field. Remember that you
     * must then populate the buffer and length fields later.
     *
     * \param transfer the transfer to populate
     * \param dev_handle handle of the device that will handle the transfer
     * \param buffer data buffer. If provided, this function will interpret the
     * first 8 bytes as a setup packet and infer the transfer length from that.
     * This pointer must be aligned to at least 2 bytes boundary.
     * \param callback callback function to be invoked on transfer completion
     * \param user_data user data to pass to callback function
     * \param timeout timeout for the transfer in milliseconds
     */
    static inline void libusb_fill_control_transfer(
    	struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
    	unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data,
    	unsigned int timeout)
    {
    	struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
    	transfer->dev_handle = dev_handle;
    	transfer->endpoint = 0;
    	transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL;
    	transfer->timeout = timeout;
    	transfer->buffer = buffer;
    	if (setup)
    		transfer->length = (int) (LIBUSB_CONTROL_SETUP_SIZE
    			+ libusb_le16_to_cpu(setup->wLength));
    	transfer->user_data = user_data;
    	transfer->callback = callback;
    }
    
    /** \ingroup libusb_asyncio
     * Helper function to populate the required \ref libusb_transfer fields
     * for a bulk transfer.
     *
     * \param transfer the transfer to populate
     * \param dev_handle handle of the device that will handle the transfer
     * \param endpoint address of the endpoint where this transfer will be sent
     * \param buffer data buffer
     * \param length length of data buffer
     * \param callback callback function to be invoked on transfer completion
     * \param user_data user data to pass to callback function
     * \param timeout timeout for the transfer in milliseconds
     */
    static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
    	libusb_device_handle *dev_handle, unsigned char endpoint,
    	unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
    	void *user_data, unsigned int timeout)
    {
    	transfer->dev_handle = dev_handle;
    	transfer->endpoint = endpoint;
    	transfer->type = LIBUSB_TRANSFER_TYPE_BULK;
    	transfer->timeout = timeout;
    	transfer->buffer = buffer;
    	transfer->length = length;
    	transfer->user_data = user_data;
    	transfer->callback = callback;
    }
    
    /** \ingroup libusb_asyncio
     * Helper function to populate the required \ref libusb_transfer fields
     * for a bulk transfer using bulk streams.
     *
     * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
     *
     * \param transfer the transfer to populate
     * \param dev_handle handle of the device that will handle the transfer
     * \param endpoint address of the endpoint where this transfer will be sent
     * \param stream_id bulk stream id for this transfer
     * \param buffer data buffer
     * \param length length of data buffer
     * \param callback callback function to be invoked on transfer completion
     * \param user_data user data to pass to callback function
     * \param timeout timeout for the transfer in milliseconds
     */
    static inline void libusb_fill_bulk_stream_transfer(
    	struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
    	unsigned char endpoint, uint32_t stream_id,
    	unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
    	void *user_data, unsigned int timeout)
    {
    	libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer,
    				  length, callback, user_data, timeout);
    	transfer->type = LIBUSB_TRANSFER_TYPE_BULK_STREAM;
    	libusb_transfer_set_stream_id(transfer, stream_id);
    }
    
    /** \ingroup libusb_asyncio
     * Helper function to populate the required \ref libusb_transfer fields
     * for an interrupt transfer.
     *
     * \param transfer the transfer to populate
     * \param dev_handle handle of the device that will handle the transfer
     * \param endpoint address of the endpoint where this transfer will be sent
     * \param buffer data buffer
     * \param length length of data buffer
     * \param callback callback function to be invoked on transfer completion
     * \param user_data user data to pass to callback function
     * \param timeout timeout for the transfer in milliseconds
     */
    static inline void libusb_fill_interrupt_transfer(
    	struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
    	unsigned char endpoint, unsigned char *buffer, int length,
    	libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
    {
    	transfer->dev_handle = dev_handle;
    	transfer->endpoint = endpoint;
    	transfer->type = LIBUSB_TRANSFER_TYPE_INTERRUPT;
    	transfer->timeout = timeout;
    	transfer->buffer = buffer;
    	transfer->length = length;
    	transfer->user_data = user_data;
    	transfer->callback = callback;
    }
    
    /** \ingroup libusb_asyncio
     * Helper function to populate the required \ref libusb_transfer fields
     * for an isochronous transfer.
     *
     * \param transfer the transfer to populate
     * \param dev_handle handle of the device that will handle the transfer
     * \param endpoint address of the endpoint where this transfer will be sent
     * \param buffer data buffer
     * \param length length of data buffer
     * \param num_iso_packets the number of isochronous packets
     * \param callback callback function to be invoked on transfer completion
     * \param user_data user data to pass to callback function
     * \param timeout timeout for the transfer in milliseconds
     */
    static inline void libusb_fill_iso_transfer(struct libusb_transfer *transfer,
    	libusb_device_handle *dev_handle, unsigned char endpoint,
    	unsigned char *buffer, int length, int num_iso_packets,
    	libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
    {
    	transfer->dev_handle = dev_handle;
    	transfer->endpoint = endpoint;
    	transfer->type = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS;
    	transfer->timeout = timeout;
    	transfer->buffer = buffer;
    	transfer->length = length;
    	transfer->num_iso_packets = num_iso_packets;
    	transfer->user_data = user_data;
    	transfer->callback = callback;
    }
    
    /** \ingroup libusb_asyncio
     * Convenience function to set the length of all packets in an isochronous
     * transfer, based on the num_iso_packets field in the transfer structure.
     *
     * \param transfer a transfer
     * \param length the length to set in each isochronous packet descriptor
     * \see libusb_get_max_packet_size()
     */
    static inline void libusb_set_iso_packet_lengths(
    	struct libusb_transfer *transfer, unsigned int length)
    {
    	int i;
    	for (i = 0; i < transfer->num_iso_packets; i++)
    		transfer->iso_packet_desc[i].length = length;
    }
    
    /** \ingroup libusb_asyncio
     * Convenience function to locate the position of an isochronous packet
     * within the buffer of an isochronous transfer.
     *
     * This is a thorough function which loops through all preceding packets,
     * accumulating their lengths to find the position of the specified packet.
     * Typically you will assign equal lengths to each packet in the transfer,
     * and hence the above method is sub-optimal. You may wish to use
     * libusb_get_iso_packet_buffer_simple() instead.
     *
     * \param transfer a transfer
     * \param packet the packet to return the address of
     * \returns the base address of the packet buffer inside the transfer buffer,
     * or NULL if the packet does not exist.
     * \see libusb_get_iso_packet_buffer_simple()
     */
    static inline unsigned char *libusb_get_iso_packet_buffer(
    	struct libusb_transfer *transfer, unsigned int packet)
    {
    	int i;
    	size_t offset = 0;
    	int _packet;
    
    	/* oops..slight bug in the API. packet is an unsigned int, but we use
    	 * signed integers almost everywhere else. range-check and convert to
    	 * signed to avoid compiler warnings. FIXME for libusb-2. */
    	if (packet > INT_MAX)
    		return NULL;
    	_packet = (int) packet;
    
    	if (_packet >= transfer->num_iso_packets)
    		return NULL;
    
    	for (i = 0; i < _packet; i++)
    		offset += transfer->iso_packet_desc[i].length;
    
    	return transfer->buffer + offset;
    }
    
    /** \ingroup libusb_asyncio
     * Convenience function to locate the position of an isochronous packet
     * within the buffer of an isochronous transfer, for transfers where each
     * packet is of identical size.
     *
     * This function relies on the assumption that every packet within the transfer
     * is of identical size to the first packet. Calculating the location of
     * the packet buffer is then just a simple calculation:
     * <tt>buffer + (packet_size * packet)</tt>
     *
     * Do not use this function on transfers other than those that have identical
     * packet lengths for each packet.
     *
     * \param transfer a transfer
     * \param packet the packet to return the address of
     * \returns the base address of the packet buffer inside the transfer buffer,
     * or NULL if the packet does not exist.
     * \see libusb_get_iso_packet_buffer()
     */
    static inline unsigned char *libusb_get_iso_packet_buffer_simple(
    	struct libusb_transfer *transfer, unsigned int packet)
    {
    	int _packet;
    
    	/* oops..slight bug in the API. packet is an unsigned int, but we use
    	 * signed integers almost everywhere else. range-check and convert to
    	 * signed to avoid compiler warnings. FIXME for libusb-2. */
    	if (packet > INT_MAX)
    		return NULL;
    	_packet = (int) packet;
    
    	if (_packet >= transfer->num_iso_packets)
    		return NULL;
    
    	return transfer->buffer + ((int) transfer->iso_packet_desc[0].length * _packet);
    }
    
    /* sync I/O */
    
    int LIBUSB_CALL libusb_control_transfer(libusb_device_handle *dev_handle,
    	uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
    	unsigned char *data, uint16_t wLength, unsigned int timeout);
    
    int LIBUSB_CALL libusb_bulk_transfer(libusb_device_handle *dev_handle,
    	unsigned char endpoint, unsigned char *data, int length,
    	int *actual_length, unsigned int timeout);
    
    int LIBUSB_CALL libusb_interrupt_transfer(libusb_device_handle *dev_handle,
    	unsigned char endpoint, unsigned char *data, int length,
    	int *actual_length, unsigned int timeout);
    
    /** \ingroup libusb_desc
     * Retrieve a descriptor from the default control pipe.
     * This is a convenience function which formulates the appropriate control
     * message to retrieve the descriptor.
     *
     * \param dev_handle a device handle
     * \param desc_type the descriptor type, see \ref libusb_descriptor_type
     * \param desc_index the index of the descriptor to retrieve
     * \param data output buffer for descriptor
     * \param length size of data buffer
     * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
     */
    static inline int libusb_get_descriptor(libusb_device_handle *dev_handle,
    	uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length)
    {
    	return libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_IN,
    		LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t) ((desc_type << 8) | desc_index),
    		0, data, (uint16_t) length, 1000);
    }
    
    /** \ingroup libusb_desc
     * Retrieve a descriptor from a device.
     * This is a convenience function which formulates the appropriate control
     * message to retrieve the descriptor. The string returned is Unicode, as
     * detailed in the USB specifications.
     *
     * \param dev_handle a device handle
     * \param desc_index the index of the descriptor to retrieve
     * \param langid the language ID for the string descriptor
     * \param data output buffer for descriptor
     * \param length size of data buffer
     * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
     * \see libusb_get_string_descriptor_ascii()
     */
    static inline int libusb_get_string_descriptor(libusb_device_handle *dev_handle,
    	uint8_t desc_index, uint16_t langid, unsigned char *data, int length)
    {
    	return libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_IN,
    		LIBUSB_REQUEST_GET_DESCRIPTOR, (uint16_t)((LIBUSB_DT_STRING << 8) | desc_index),
    		langid, data, (uint16_t) length, 1000);
    }
    
    int LIBUSB_CALL libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle,
    	uint8_t desc_index, unsigned char *data, int length);
    
    /* polling and timeouts */
    
    int LIBUSB_CALL libusb_try_lock_events(libusb_context *ctx);
    void LIBUSB_CALL libusb_lock_events(libusb_context *ctx);
    void LIBUSB_CALL libusb_unlock_events(libusb_context *ctx);
    int LIBUSB_CALL libusb_event_handling_ok(libusb_context *ctx);
    int LIBUSB_CALL libusb_event_handler_active(libusb_context *ctx);
    void LIBUSB_CALL libusb_interrupt_event_handler(libusb_context *ctx);
    void LIBUSB_CALL libusb_lock_event_waiters(libusb_context *ctx);
    void LIBUSB_CALL libusb_unlock_event_waiters(libusb_context *ctx);
    int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *tv);
    
    int LIBUSB_CALL libusb_handle_events_timeout(libusb_context *ctx,
    	struct timeval *tv);
    int LIBUSB_CALL libusb_handle_events_timeout_completed(libusb_context *ctx,
    	struct timeval *tv, int *completed);
    int LIBUSB_CALL libusb_handle_events(libusb_context *ctx);
    int LIBUSB_CALL libusb_handle_events_completed(libusb_context *ctx, int *completed);
    int LIBUSB_CALL libusb_handle_events_locked(libusb_context *ctx,
    	struct timeval *tv);
    int LIBUSB_CALL libusb_pollfds_handle_timeouts(libusb_context *ctx);
    int LIBUSB_CALL libusb_get_next_timeout(libusb_context *ctx,
    	struct timeval *tv);
    
    /** \ingroup libusb_poll
     * File descriptor for polling
     */
    struct libusb_pollfd {
    	/** Numeric file descriptor */
    	int fd;
    
    	/** Event flags to poll for from <poll.h>. POLLIN indicates that you
    	 * should monitor this file descriptor for becoming ready to read from,
    	 * and POLLOUT indicates that you should monitor this file descriptor for
    	 * nonblocking write readiness. */
    	short events;
    };
    
    /** \ingroup libusb_poll
     * Callback function, invoked when a new file descriptor should be added
     * to the set of file descriptors monitored for events.
     * \param fd the new file descriptor
     * \param events events to monitor for, see \ref libusb_pollfd for a
     * description
     * \param user_data User data pointer specified in
     * libusb_set_pollfd_notifiers() call
     * \see libusb_set_pollfd_notifiers()
     */
    typedef void (LIBUSB_CALL *libusb_pollfd_added_cb)(int fd, short events,
    	void *user_data);
    
    /** \ingroup libusb_poll
     * Callback function, invoked when a file descriptor should be removed from
     * the set of file descriptors being monitored for events. After returning
     * from this callback, do not use that file descriptor again.
     * \param fd the file descriptor to stop monitoring
     * \param user_data User data pointer specified in
     * libusb_set_pollfd_notifiers() call
     * \see libusb_set_pollfd_notifiers()
     */
    typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_data);
    
    const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds(
    	libusb_context *ctx);
    void LIBUSB_CALL libusb_free_pollfds(const struct libusb_pollfd **pollfds);
    void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx,
    	libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,
    	void *user_data);
    
    /** \ingroup libusb_hotplug
     * Callback handle.
     *
     * Callbacks handles are generated by libusb_hotplug_register_callback()
     * and can be used to deregister callbacks. Callback handles are unique
     * per libusb_context and it is safe to call libusb_hotplug_deregister_callback()
     * on an already deregisted callback.
     *
     * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
     *
     * For more information, see \ref libusb_hotplug.
     */
    typedef int libusb_hotplug_callback_handle;
    
    /** \ingroup libusb_hotplug
     *
     * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
     *
     * Flags for hotplug events */
    typedef enum {
    	/** Default value when not using any flags. */
    	LIBUSB_HOTPLUG_NO_FLAGS = 0U,
    
    	/** Arm the callback and fire it for all matching currently attached devices. */
    	LIBUSB_HOTPLUG_ENUMERATE = 1U << 0,
    } libusb_hotplug_flag;
    
    /** \ingroup libusb_hotplug
     *
     * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
     *
     * Hotplug events */
    typedef enum {
    	/** A device has been plugged in and is ready to use */
    	LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 0x01U,
    
    	/** A device has left and is no longer available.
    	 * It is the user's responsibility to call libusb_close on any handle associated with a disconnected device.
    	 * It is safe to call libusb_get_device_descriptor on a device that has left */
    	LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT    = 0x02U,
    } libusb_hotplug_event;
    
    /** \ingroup libusb_hotplug
     * Wildcard matching for hotplug events */
    #define LIBUSB_HOTPLUG_MATCH_ANY -1
    
    /** \ingroup libusb_hotplug
     * Hotplug callback function type. When requesting hotplug event notifications,
     * you pass a pointer to a callback function of this type.
     *
     * This callback may be called by an internal event thread and as such it is
     * recommended the callback do minimal processing before returning.
     *
     * libusb will call this function later, when a matching event had happened on
     * a matching device. See \ref libusb_hotplug for more information.
     *
     * It is safe to call either libusb_hotplug_register_callback() or
     * libusb_hotplug_deregister_callback() from within a callback function.
     *
     * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
     *
     * \param ctx            context of this notification
     * \param device         libusb_device this event occurred on
     * \param event          event that occurred
     * \param user_data      user data provided when this callback was registered
     * \returns bool whether this callback is finished processing events.
     *                       returning 1 will cause this callback to be deregistered
     */
    typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
    						libusb_device *device,
    						libusb_hotplug_event event,
    						void *user_data);
    
    /** \ingroup libusb_hotplug
     * Register a hotplug callback function
     *
     * Register a callback with the libusb_context. The callback will fire
     * when a matching event occurs on a matching device. The callback is
     * armed until either it is deregistered with libusb_hotplug_deregister_callback()
     * or the supplied callback returns 1 to indicate it is finished processing events.
     *
     * If the \ref LIBUSB_HOTPLUG_ENUMERATE is passed the callback will be
     * called with a \ref LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED for all devices
     * already plugged into the machine. Note that libusb modifies its internal
     * device list from a separate thread, while calling hotplug callbacks from
     * libusb_handle_events(), so it is possible for a device to already be present
     * on, or removed from, its internal device list, while the hotplug callbacks
     * still need to be dispatched. This means that when using \ref
     * LIBUSB_HOTPLUG_ENUMERATE, your callback may be called twice for the arrival
     * of the same device, once from libusb_hotplug_register_callback() and once
     * from libusb_handle_events(); and/or your callback may be called for the
     * removal of a device for which an arrived call was never made.
     *
     * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
     *
     * \param[in] ctx context to register this callback with
     * \param[in] events bitwise or of events that will trigger this callback. See \ref
     *            libusb_hotplug_event
     * \param[in] flags hotplug callback flags. See \ref libusb_hotplug_flag
     * \param[in] vendor_id the vendor id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
     * \param[in] product_id the product id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
     * \param[in] dev_class the device class to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
     * \param[in] cb_fn the function to be invoked on a matching event/device
     * \param[in] user_data user data to pass to the callback function
     * \param[out] callback_handle pointer to store the handle of the allocated callback (can be NULL)
     * \returns LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure
     */
    int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
    						libusb_hotplug_event events,
    						libusb_hotplug_flag flags,
    						int vendor_id, int product_id,
    						int dev_class,
    						libusb_hotplug_callback_fn cb_fn,
    						void *user_data,
    						libusb_hotplug_callback_handle *callback_handle);
    
    /** \ingroup libusb_hotplug
     * Deregisters a hotplug callback.
     *
     * Deregister a callback from a libusb_context. This function is safe to call from within
     * a hotplug callback.
     *
     * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
     *
     * \param[in] ctx context this callback is registered with
     * \param[in] callback_handle the handle of the callback to deregister
     */
    void LIBUSB_CALL libusb_hotplug_deregister_callback(libusb_context *ctx,
    						libusb_hotplug_callback_handle callback_handle);
    
    /** \ingroup libusb_lib
     * Available option values for libusb_set_option().
     */
    enum libusb_option {
    	/** Set the log message verbosity.
    	 *
    	 * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever
    	 * printed. If you choose to increase the message verbosity level, ensure
    	 * that your application does not close the stderr file descriptor.
    	 *
    	 * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusb is conservative
    	 * with its message logging and most of the time, will only log messages that
    	 * explain error conditions and other oddities. This will help you debug
    	 * your software.
    	 *
    	 * If the LIBUSB_DEBUG environment variable was set when libusb was
    	 * initialized, this function does nothing: the message verbosity is fixed
    	 * to the value in the environment variable.
    	 *
    	 * If libusb was compiled without any message logging, this function does
    	 * nothing: you'll never get any messages.
    	 *
    	 * If libusb was compiled with verbose debug message logging, this function
    	 * does nothing: you'll always get messages from all levels.
    	 */
    	LIBUSB_OPTION_LOG_LEVEL,
    
    	/** Use the UsbDk backend for a specific context, if available.
    	 *
    	 * This option should be set immediately after calling libusb_init(), otherwise
    	 * unspecified behavior may occur.
    	 *
    	 * Only valid on Windows.
    	 */
    	LIBUSB_OPTION_USE_USBDK,
    };
    
    int LIBUSB_CALL libusb_set_option(libusb_context *ctx, enum libusb_option option, ...);
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif
    
    


  • @Timo_R sagte in Terminalausgabe Testprogramm:

    Sie sind "Ossi" das höre ich schon -

    halten Sie sich mal bitte daraus -

    Bitte was?

    Zum problem:

    *hust https://stackoverflow.com/questions/23840108/linking-to-libusb

    Die google Suche war ziemlich aufwendig, hat mich mindestens 10sek gekostet.

    Die Datei liegt bei mir in

    /usr/include/libusb-1.0/libusb.h

    Dementsprechend ist die include Anweisung:

    #include <libusb-1.0/libusb.h>

    und der Befehl

    gcc -L /usr/include/ test.cpp -lusb-1.0

    Edit: /usr/incldue ist im Standardverzeichnis, von daher ist das Angeben von dem Pfad gar nicht nötig. Habs der Vollständigkeit halber aber mal drinnen gelassen, falls der Pfad angepasst werden muss.



  • @Leon0402 sagte in Terminalausgabe Testprogramm:

    Die Datei liegt bei mir in
    /usr/include/libusb-1.0/libusb.h
    Dementsprechend ist die include Anweisung:
    #include <libusb-1.0/libusb.h>
    und der Befehl
    gcc -L /usr/include/ test.cpp -lusb-1.0

    Funktioniert leider bei mir nicht, auf meinen Fall gemünzt wäre
    dann, die Datei liegt bei mir
    /usr/include/libusb/libusb.h

    Die include-Anweisung im Quelltext lautet bei mir dementsprechend:
    #include <libusb/libusb.h>

    Beim Befehl jedoch herrscht Uneinigkeit:
    g++ -L /usr/include/ TEST1.cpp -lusb-1.0

    liefert wieder bei mir oben benannten Fehler.
    Irgendwas stimmt meiner Meinung nach bei dem Befehl des
    Einbindens nicht.



  • Mit -L gibt man den Library-Pfad an, mit -I den Include-Pfad...



  • @Bashar
    Dank für die Anmerkung,
    wusst ich schon, klappt immer noch nicht.



  • Don't feed the troll.



  • @Timo_R: Dies ist die Hürde, die entscheidet, ob man zum Programmieren geeignet ist - du bist es anscheinend nicht...



  • Wie Sie sagen TH69 - aber Sie sind
    nicht die Person, die darüber richtet.

    Von 47 Beiträgen - nur eine handvoll Beiträge,
    in denen es verständlich fachlich wurde.

    NAJA -



  • @Timo_R sagte in Terminalausgabe Testprogramm:

    Sie sind "Ossi" das höre ich schon -

    halten Sie sich mal bitte daraus -

    Aye, Sir!
    Dann mal viel Erfolg, du kriegst das bestimmt noch hin. Irgendwann. Vielleicht.



  • @5cript sagte in Terminalausgabe Testprogramm:

    Ist das auf einem Linux?
    "$ whereis libusb"

    Was ich eigentlich damit bezwecken wollte, ist dass dir der pfad der library ausgegeben wird komplett.
    Der Header ist ja egal, das ist ja nicht das Problem.

    Bei mir:
    libusb: /usr/lib/libusb.so

    Ich bin auf ArchLinux und das von mir installierte package ist core/libusb.



  • Puh, da bin ich ja jetzt beruhigt. Ich hatte schon gedacht, ich hätte zu früh rumgemault.
    Aber Respekt, dass nach dem "Ossi"-Spruch und offensichtlichem rumgetrolle immer noch konstruktive Antworten kommen!


Anmelden zum Antworten