Top | ![]() |
![]() |
![]() |
![]() |
#define | G_USB_DEVICE_ERROR |
enum | GUsbDeviceDirection |
enum | GUsbDeviceRequestType |
enum | GUsbDeviceRecipient |
enum | GUsbDeviceError |
enum | GUsbDeviceClaimInterfaceFlags |
enum | GUsbDeviceClassCode |
struct | GUsbDevice |
struct | GUsbDeviceClass |
GUsbDevicePrivate |
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
When the device is removed and then replugged, this value is not expected to be different.
Since: 0.1.1
GUsbDevice *
g_usb_device_get_parent (GUsbDevice *device
);
Gets the device parent if one exists.
Since: 0.2.4
GPtrArray *
g_usb_device_get_children (GUsbDevice *device
);
Gets the device children if any exist.
Since: 0.2.4
guint8
g_usb_device_get_bus (GUsbDevice *device
);
Gets the USB bus number for the device.
Since: 0.1.0
guint8
g_usb_device_get_address (GUsbDevice *device
);
Gets the USB address for the device.
Since: 0.1.0
guint8
g_usb_device_get_port_number (GUsbDevice *device
);
Gets the USB port number for the device.
Since: 0.2.4
guint16
g_usb_device_get_vid (GUsbDevice *device
);
Gets the vendor ID for the device.
Since: 0.1.0
guint16
g_usb_device_get_pid (GUsbDevice *device
);
Gets the product ID for the device.
Since: 0.1.0
guint16
g_usb_device_get_release (GUsbDevice *device
);
Gets the BCD firmware version number for the device.
Since: 0.2.8
const gchar *
g_usb_device_get_vid_as_str (GUsbDevice *device
);
Gets the vendor ID for the device as a string.
Since: 0.2.4
const gchar *
g_usb_device_get_pid_as_str (GUsbDevice *device
);
Gets the product ID for the device as a string.
Since: 0.2.4
guint8
g_usb_device_get_device_class (GUsbDevice *device
);
Gets the device class, typically a GUsbDeviceClassCode.
Since: 0.1.7
guint8
g_usb_device_get_device_subclass (GUsbDevice *device
);
Gets the device subclass qualified by the class number.
See g_usb_device_get_device_class()
.
Since: 0.2.4
guint8
g_usb_device_get_device_protocol (GUsbDevice *device
);
Gets the device protocol qualified by the class and subclass numbers.
See g_usb_device_get_device_class()
and g_usb_device_get_device_subclass()
.
Since: 0.2.4
guint8
g_usb_device_get_manufacturer_index (GUsbDevice *device
);
Gets the index for the Manufacturer string descriptor.
Since: 0.1.0
guint8
g_usb_device_get_product_index (GUsbDevice *device
);
Gets the index for the Product string descriptor.
Since: 0.1.0
guint8
g_usb_device_get_serial_number_index (GUsbDevice *device
);
Gets the index for the Serial Number string descriptor.
Since: 0.1.0
guint8 g_usb_device_get_custom_index (GUsbDevice *device
,guint8 class_id
,guint8 subclass_id
,guint8 protocol_id
,GError **error
);
Gets the string index from the vendor class interface descriptor.
device |
||
class_id |
a device class, e.g. 0xff for VENDOR |
|
subclass_id |
a device subclass |
|
protocol_id |
a protocol number |
|
error |
Since: 0.2.5
GUsbInterface * g_usb_device_get_interface (GUsbDevice *device
,guint8 class_id
,guint8 subclass_id
,guint8 protocol_id
,GError **error
);
Gets the first interface that matches the vendor class interface descriptor.
If you want to find all the interfaces that match (there may be other
'alternate' interfaces you have to use g_usb_device_get_interfaces()
and
check each one manally.
device |
||
class_id |
a device class, e.g. 0xff for VENDOR |
|
subclass_id |
a device subclass |
|
protocol_id |
a protocol number |
|
error |
Since: 0.2.8
GPtrArray * g_usb_device_get_interfaces (GUsbDevice *device
,GError **error
);
Gets all the interfaces exported by the device.
Since: 0.2.8
gboolean g_usb_device_open (GUsbDevice *device
,GError **error
);
Opens the device for use.
Warning: this function is synchronous.
Since: 0.1.0
gboolean g_usb_device_close (GUsbDevice *device
,GError **error
);
Closes the device when it is no longer required.
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.
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.
Since: 0.1.0
gboolean g_usb_device_set_configuration (GUsbDevice *device
,gint configuration
,GError **error
);
Set the active bConfigurationValue for the device.
Warning: this function is synchronous.
Since: 0.1.0
gboolean g_usb_device_claim_interface (GUsbDevice *device
,gint interface
,GUsbDeviceClaimInterfaceFlags flags
,GError **error
);
Claim an interface of the device.
Since: 0.1.0
gboolean g_usb_device_release_interface (GUsbDevice *device
,gint interface
,GUsbDeviceClaimInterfaceFlags flags
,GError **error
);
Release an interface of the device.
Since: 0.1.0
gboolean g_usb_device_set_interface_alt (GUsbDevice *device
,gint interface
,guint8 alt
,GError **error
);
Sets an alternate setting on an interface.
device |
||
interface |
bInterfaceNumber of the interface you wish to release |
|
alt |
alternative setting number |
|
error |
Since: 0.2.8
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.
Since: 0.1.0
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.
device |
||
request_type |
the request type field for the setup packet |
|
request |
the request field for the setup packet |
|
value |
the value field for the setup packet |
|
idx |
the index field for the setup packet |
|
data |
a suitably-sized data buffer for either input or output. |
[array length=length] |
length |
the length field for the setup packet. |
|
actual_length |
the actual number of bytes sent, or |
|
timeout |
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
cancellable |
a GCancellable, or |
|
error |
Since: 0.1.0
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.
device |
||
endpoint |
the address of a valid endpoint to communicate with |
|
data |
a suitably-sized data buffer for either input or output. |
[array length=length] |
length |
the length field for the setup packet. |
|
actual_length |
the actual number of bytes sent, or |
|
timeout |
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
cancellable |
a GCancellable, or |
|
error |
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.
device |
||
endpoint |
the address of a valid endpoint to communicate with |
|
data |
a suitably-sized data buffer for either input or output. |
[array length=length] |
length |
the length field for the setup packet. |
|
actual_length |
the actual number of bytes sent, or |
|
timeout |
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
cancellable |
a GCancellable, or |
|
error |
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
device |
||
data |
a suitably-sized data buffer for either input or output. |
[array length=length] |
length |
the length field for the setup packet. |
|
timeout |
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
cancellable |
a GCancellable, or |
|
callback |
the function to run on completion |
|
user_data |
the data to pass to |
Since: 0.1.0
gssize g_usb_device_control_transfer_finish (GUsbDevice *device
,GAsyncResult *res
,GError **error
);
Gets the result from the asynchronous function.
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
device |
a GUsbDevice instance. |
|
endpoint |
the address of a valid endpoint to communicate with |
|
data |
a suitably-sized data buffer for either input or output. |
[array length=length] |
length |
the length field for the setup packet. |
|
timeout |
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
cancellable |
a GCancellable, or |
|
callback |
the function to run on completion |
|
user_data |
the data to pass to |
Since: 0.1.0
gssize g_usb_device_bulk_transfer_finish (GUsbDevice *device
,GAsyncResult *res
,GError **error
);
Gets the result from the asynchronous function.
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
device |
a GUsbDevice instance. |
|
endpoint |
the address of a valid endpoint to communicate with |
|
data |
a suitably-sized data buffer for either input or output. |
[array length=length] |
length |
the length field for the setup packet. |
|
timeout |
timeout timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use 0. |
|
cancellable |
a GCancellable, or |
|
callback |
the function to run on completion |
|
user_data |
the data to pass to |
Since: 0.1.0
gssize g_usb_device_interrupt_transfer_finish (GUsbDevice *device
,GAsyncResult *res
,GError **error
);
Gets the result from the asynchronous function.
Since: 0.1.0
Flags for the g_usb_device_claim_interface and g_usb_device_release_interface methods flags parameters.