![]() |
![]() |
![]() |
GUsb Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties |
struct GUsbDevice; enum GUsbDeviceClaimInterfaceFlags; struct GUsbDeviceClass; enum GUsbDeviceDirection; enum GUsbDeviceError; enum GUsbDeviceRecipient; enum GUsbDeviceRequestType; #define G_USB_DEVICE_ERROR gboolean g_usb_device_bulk_transfer (GUsbDevice *device
,guint8 endpoint
,guint8 *data
,gsize length
,gsize *actual_length
,guint timeout
,GCancellable *cancellable
,GError **error
); void g_usb_device_bulk_transfer_async (GUsbDevice *device
,guint8 endpoint
,guint8 *data
,gsize length
,guint timeout
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gssize g_usb_device_bulk_transfer_finish (GUsbDevice *device
,GAsyncResult *res
,GError **error
); gboolean g_usb_device_claim_interface (GUsbDevice *device
,gint interface
,GUsbDeviceClaimInterfaceFlags flags
,GError **error
); gboolean g_usb_device_close (GUsbDevice *device
,GError **error
); gboolean g_usb_device_control_transfer (GUsbDevice *device
,GUsbDeviceDirection direction
,GUsbDeviceRequestType request_type
,GUsbDeviceRecipient recipient
,guint8 request
,guint16 value
,guint16 idx
,guint8 *data
,gsize length
,gsize *actual_length
,guint timeout
,GCancellable *cancellable
,GError **error
); void g_usb_device_control_transfer_async (GUsbDevice *device
,GUsbDeviceDirection direction
,GUsbDeviceRequestType request_type
,GUsbDeviceRecipient recipient
,guint8 request
,guint16 value
,guint16 idx
,guint8 *data
,gsize length
,guint timeout
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gssize g_usb_device_control_transfer_finish (GUsbDevice *device
,GAsyncResult *res
,GError **error
); GQuark g_usb_device_error_quark (void
); guint8 g_usb_device_get_address (GUsbDevice *device
); guint8 g_usb_device_get_bus (GUsbDevice *device
); gint g_usb_device_get_configuration (GUsbDevice *device
,GError **error
); guint8 g_usb_device_get_manufacturer_index (GUsbDevice *device
); guint16 g_usb_device_get_pid (GUsbDevice *device
); const gchar * g_usb_device_get_platform_id (GUsbDevice *device
); guint8 g_usb_device_get_product_index (GUsbDevice *device
); guint8 g_usb_device_get_serial_number_index (GUsbDevice *device
); gchar * g_usb_device_get_string_descriptor (GUsbDevice *device
,guint8 desc_index
,GError **error
); guint16 g_usb_device_get_vid (GUsbDevice *device
); gboolean g_usb_device_interrupt_transfer (GUsbDevice *device
,guint8 endpoint
,guint8 *data
,gsize length
,gsize *actual_length
,guint timeout
,GCancellable *cancellable
,GError **error
); void g_usb_device_interrupt_transfer_async (GUsbDevice *device
,guint8 endpoint
,guint8 *data
,gsize length
,guint timeout
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gssize g_usb_device_interrupt_transfer_finish (GUsbDevice *device
,GAsyncResult *res
,GError **error
); gboolean g_usb_device_open (GUsbDevice *device
,GError **error
); gboolean g_usb_device_release_interface (GUsbDevice *device
,gint interface
,GUsbDeviceClaimInterfaceFlags flags
,GError **error
); gboolean g_usb_device_reset (GUsbDevice *device
,GError **error
); gboolean g_usb_device_set_configuration (GUsbDevice *device
,gint configuration
,GError **error
);
"context" GUsbContext* : Write / Construct Only "libusb-device" gpointer : Read / Write / Construct Only "platform-id" gchar* : Write / Construct Only
typedef enum { G_USB_DEVICE_CLAIM_INTERFACE_BIND_KERNEL_DRIVER = 1 << 0, } GUsbDeviceClaimInterfaceFlags;
Flags for the g_usb_device_claim_interface and g_usb_device_release_interface methods flags parameters.
typedef enum { G_USB_DEVICE_DIRECTION_DEVICE_TO_HOST, /* IN */ G_USB_DEVICE_DIRECTION_HOST_TO_DEVICE /* OUT */ } GUsbDeviceDirection;
The message direction.
typedef enum { G_USB_DEVICE_ERROR_INTERNAL, G_USB_DEVICE_ERROR_IO, G_USB_DEVICE_ERROR_TIMED_OUT, G_USB_DEVICE_ERROR_NOT_SUPPORTED, G_USB_DEVICE_ERROR_NO_DEVICE, G_USB_DEVICE_ERROR_NOT_OPEN, G_USB_DEVICE_ERROR_ALREADY_OPEN, G_USB_DEVICE_ERROR_CANCELLED, G_USB_DEVICE_ERROR_FAILED, G_USB_DEVICE_ERROR_LAST } GUsbDeviceError;
The error code.
typedef enum { G_USB_DEVICE_RECIPIENT_DEVICE, G_USB_DEVICE_RECIPIENT_INTERFACE, G_USB_DEVICE_RECIPIENT_ENDPOINT, G_USB_DEVICE_RECIPIENT_OTHER } GUsbDeviceRecipient;
The message recipient.
typedef enum { G_USB_DEVICE_REQUEST_TYPE_STANDARD, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_REQUEST_TYPE_VENDOR, G_USB_DEVICE_REQUEST_TYPE_RESERVED } GUsbDeviceRequestType;
The message request type.
gboolean g_usb_device_bulk_transfer (GUsbDevice *device
,guint8 endpoint
,guint8 *data
,gsize length
,gsize *actual_length
,guint timeout
,GCancellable *cancellable
,GError **error
);
Perform a USB bulk transfer.
Warning: this function is synchronous, and cannot be cancelled.
|
a GUsbDevice |
|
the address of a valid endpoint to communicate with |
|
a suitably-sized data buffer for either input or output. [array length=length] |
|
the length field for the setup packet. |
|
the actual number of bytes sent, or NULL
|
|
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
a GCancellable, or NULL
|
|
a GError, or NULL
|
Returns : |
TRUE on success |
Since 0.1.0
void g_usb_device_bulk_transfer_async (GUsbDevice *device
,guint8 endpoint
,guint8 *data
,gsize length
,guint timeout
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Do an async bulk transfer
|
a GUsbDevice instance. |
|
the address of a valid endpoint to communicate with |
|
a suitably-sized data buffer for either input or output. [array length=length] |
|
the length field for the setup packet. |
|
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
a GCancellable, or NULL
|
|
the function to run on completion |
|
the data to pass to callback
|
Since 0.1.0
gssize g_usb_device_bulk_transfer_finish (GUsbDevice *device
,GAsyncResult *res
,GError **error
);
Gets the result from the asynchronous function.
|
a GUsbDevice instance. |
|
the GAsyncResult |
|
A GError or NULL
|
Returns : |
the actual number of bytes sent, or -1 on error. |
Since 0.1.0
gboolean g_usb_device_claim_interface (GUsbDevice *device
,gint interface
,GUsbDeviceClaimInterfaceFlags flags
,GError **error
);
Claim an interface of the device.
|
a GUsbDevice |
|
bInterfaceNumber of the interface you wish to claim |
|
GUsbDeviceClaimInterfaceFlags |
|
a GError, or NULL
|
Returns : |
TRUE on success |
Since 0.1.0
gboolean g_usb_device_close (GUsbDevice *device
,GError **error
);
Closes the device when it is no longer required.
|
a GUsbDevice |
|
a GError, or NULL
|
Returns : |
TRUE on success |
gboolean g_usb_device_control_transfer (GUsbDevice *device
,GUsbDeviceDirection direction
,GUsbDeviceRequestType request_type
,GUsbDeviceRecipient recipient
,guint8 request
,guint16 value
,guint16 idx
,guint8 *data
,gsize length
,gsize *actual_length
,guint timeout
,GCancellable *cancellable
,GError **error
);
Perform a USB control transfer.
Warning: this function is synchronous, and cannot be cancelled.
|
a GUsbDevice |
|
the request type field for the setup packet |
|
the request field for the setup packet |
|
the value field for the setup packet |
|
the index field for the setup packet |
|
a suitably-sized data buffer for either input or output. [array length=length] |
|
the length field for the setup packet. |
|
the actual number of bytes sent, or NULL
|
|
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
a GCancellable, or NULL
|
|
a GError, or NULL
|
Returns : |
TRUE on success |
Since 0.1.0
void g_usb_device_control_transfer_async (GUsbDevice *device
,GUsbDeviceDirection direction
,GUsbDeviceRequestType request_type
,GUsbDeviceRecipient recipient
,guint8 request
,guint16 value
,guint16 idx
,guint8 *data
,gsize length
,guint timeout
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Do an async control transfer
|
a GUsbDevice |
|
a suitably-sized data buffer for either input or output. [array length=length] |
|
the length field for the setup packet. |
|
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
a GCancellable, or NULL
|
|
the function to run on completion |
|
the data to pass to callback
|
Since 0.1.0
gssize g_usb_device_control_transfer_finish (GUsbDevice *device
,GAsyncResult *res
,GError **error
);
Gets the result from the asynchronous function.
|
a GUsbDevice instance. |
|
the GAsyncResult |
|
A GError or NULL
|
Returns : |
the actual number of bytes sent, or -1 on error. |
Since 0.1.0
GQuark g_usb_device_error_quark (void
);
Returns : |
Our personal error quark. |
Since 0.1.0
guint8 g_usb_device_get_address (GUsbDevice *device
);
Gets the USB address for the device.
|
a GUsbDevice |
Returns : |
The 8-bit address |
Since 0.1.0
guint8 g_usb_device_get_bus (GUsbDevice *device
);
Gets the USB bus number for the device.
|
a GUsbDevice |
Returns : |
The 8-bit bus number |
Since 0.1.0
gint g_usb_device_get_configuration (GUsbDevice *device
,GError **error
);
Get the bConfigurationValue for the active configuration of the device.
Warning: this function is synchronous.
|
a GUsbDevice |
|
a GError, or NULL
|
Returns : |
The bConfigurationValue of the active config, or -1 on error |
Since 0.1.0
guint8 g_usb_device_get_manufacturer_index (GUsbDevice *device
);
Gets the index for the Manufacturer string descriptor.
|
a GUsbDevice |
Returns : |
a string descriptor index. |
Since 0.1.0
guint16 g_usb_device_get_pid (GUsbDevice *device
);
Gets the product ID for the device.
|
a GUsbDevice |
Returns : |
an ID. |
Since 0.1.0
const gchar * g_usb_device_get_platform_id (GUsbDevice *device
);
Gets the platform identifier for the device. On Linux, this is the full sysfs path of the device
|
a GUsbDevice |
Returns : |
The platform ID, or NULL
|
Since 0.1.1
guint8 g_usb_device_get_product_index (GUsbDevice *device
);
Gets the index for the Product string descriptor.
|
a GUsbDevice |
Returns : |
a string descriptor index. |
Since 0.1.0
guint8 g_usb_device_get_serial_number_index
(GUsbDevice *device
);
Gets the index for the Serial Number string descriptor.
|
a GUsbDevice |
Returns : |
a string descriptor index. |
Since 0.1.0
gchar * g_usb_device_get_string_descriptor (GUsbDevice *device
,guint8 desc_index
,GError **error
);
Get a string descriptor from the device. The returned string should be freed
with g_free()
when no longer needed.
|
the index for the string descriptor to retreive |
|
a GError, or NULL
|
Returns : |
a newly-allocated string holding the descriptor, or NULL on error. |
Since 0.1.0
guint16 g_usb_device_get_vid (GUsbDevice *device
);
Gets the vendor ID for the device.
|
a GUsbDevice |
Returns : |
an ID. |
Since 0.1.0
gboolean g_usb_device_interrupt_transfer (GUsbDevice *device
,guint8 endpoint
,guint8 *data
,gsize length
,gsize *actual_length
,guint timeout
,GCancellable *cancellable
,GError **error
);
Perform a USB interrupt transfer.
Warning: this function is synchronous, and cannot be cancelled.
|
a GUsbDevice |
|
the address of a valid endpoint to communicate with |
|
a suitably-sized data buffer for either input or output. [array length=length] |
|
the length field for the setup packet. |
|
the actual number of bytes sent, or NULL
|
|
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
a GCancellable, or NULL
|
|
a GError, or NULL
|
Returns : |
TRUE on success |
Since 0.1.0
void g_usb_device_interrupt_transfer_async (GUsbDevice *device
,guint8 endpoint
,guint8 *data
,gsize length
,guint timeout
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Do an async interrupt transfer
|
a GUsbDevice instance. |
|
the address of a valid endpoint to communicate with |
|
a suitably-sized data buffer for either input or output. [array length=length] |
|
the length field for the setup packet. |
|
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
a GCancellable, or NULL
|
|
the function to run on completion |
|
the data to pass to callback
|
Since 0.1.0
gssize g_usb_device_interrupt_transfer_finish (GUsbDevice *device
,GAsyncResult *res
,GError **error
);
Gets the result from the asynchronous function.
|
a GUsbDevice instance. |
|
the GAsyncResult |
|
A GError or NULL
|
Returns : |
the actual number of bytes sent, or -1 on error. |
Since 0.1.0
gboolean g_usb_device_open (GUsbDevice *device
,GError **error
);
Opens the device for use.
Warning: this function is synchronous.
|
a GUsbDevice |
|
a GError, or NULL
|
Returns : |
TRUE on success |
Since 0.1.0
gboolean g_usb_device_release_interface (GUsbDevice *device
,gint interface
,GUsbDeviceClaimInterfaceFlags flags
,GError **error
);
Release an interface of the device.
|
a GUsbDevice |
|
bInterfaceNumber of the interface you wish to release |
|
GUsbDeviceClaimInterfaceFlags |
|
a GError, or NULL
|
Returns : |
TRUE on success |
Since 0.1.0
gboolean g_usb_device_reset (GUsbDevice *device
,GError **error
);
Perform a USB port reset to reinitialize a device.
If the reset succeeds, the device will appear to disconnected and reconnected.
This means the device
will no longer be valid and should be closed and
rediscovered.
This is a blocking function which usually incurs a noticeable delay.
|
a GUsbDevice |
|
a GError, or NULL
|
Returns : |
TRUE on success |
gboolean g_usb_device_set_configuration (GUsbDevice *device
,gint configuration
,GError **error
);
Set the active bConfigurationValue for the device.
Warning: this function is synchronous.
|
a GUsbDevice |
|
the configuration value to set |
|
a GError, or NULL
|
Returns : |
TRUE on success |
Since 0.1.0