Check whether a gusb version equal to or greater than
major.minor.micro.
Creates a new context for accessing USB devices.
a new %GUsbContext object or %NULL on error.
Our personal error quark.
Enumerates all the USB devices and adds them to the context.
You only need to call this function once, and any subsequent calls
are silently ignored.
a #GUsbContext
Finds a device based on its bus and address values.
a new #GUsbDevice, or %NULL if not found.
a #GUsbContext
a bus number
a bus address
Finds a device based on its platform id value.
a new #GUsbDevice, or %NULL if not found.
a #GUsbContext
a platform id, e.g. "usb:00:03:03:02"
Finds a device based on its bus and address values.
a new #GUsbDevice, or %NULL if not found.
a #GUsbContext
a vendor ID
a product ID
a new #GPtrArray of #GUsbDevice's.
a #GUsbContext
Sets the flags to use for the context.
the #GUsbContextFlags, e.g. %G_USB_CONTEXT_FLAGS_AUTO_OPEN_DEVICES
a #GUsbContext
Gets the poll interval for platforms like Windows that do not support `LIBUSB_CAP_HAS_HOTPLUG`.
the interval in ms
a #GUsbContext
Gets the internal GMainContext to use for synchronous methods.
By default the value is set to the value of g_main_context_default()
the #GMainContext
a #GUsbContext
This function does nothing.
the #GUsbSource.
a #GUsbContext
a #GMainContext, or %NULL
Sets the debug flags which control what is logged to the console.
Using %G_LOG_LEVEL_INFO will output to standard out, and everything
else logs to standard error.
a #GUsbContext
a GLogLevelFlags such as %G_LOG_LEVEL_ERROR | %G_LOG_LEVEL_INFO, or 0
Sets the flags to use for the context. These should be set before
g_usb_context_enumerate() is called.
a #GUsbContext
some #GUsbContextFlags, e.g. %G_USB_CONTEXT_FLAGS_AUTO_OPEN_DEVICES
Sets the poll interval for platforms like Windows that do not support `LIBUSB_CAP_HAS_HOTPLUG`.
This defaults to 1000ms and can be changed before or after g_usb_context_enumerate() has been
called.
a #GUsbContext
the interval in ms
Sets the internal GMainContext to use for synchronous methods.
a #GUsbContext
Waits for the device to be replugged.
It may come back with a different VID:PID.
Warning: This is synchronous and blocks until the device comes
back or the timeout triggers.
a new #GUsbDevice, or %NULL for invalid
a #GUsbContext
a #GUsbDevice
timeout to wait
This signal is emitted when a USB device is added.
A #GUsbDevice
This signal is emitted when a USB device is removed.
A #GUsbDevice
The flags to use for the context.
Private #GUsbContext data
Our personal error quark.
Perform a USB bulk transfer.
Warning: this function is synchronous, and cannot be cancelled.
%TRUE on success
a #GUsbDevice
the address of a valid endpoint to communicate with
a suitably-sized data buffer for
either input or output
the length field for the setup packet.
the actual number of bytes sent, or %NULL
timeout timeout (in milliseconds) that this function should wait
before giving up due to no response being received. For an unlimited
timeout, use 0.
a #GCancellable, or %NULL
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
the length field for the setup packet.
timeout timeout (in milliseconds) 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
Gets the result from the asynchronous function.
the actual number of bytes sent, or -1 on error.
a #GUsbDevice instance.
the #GAsyncResult
Claim an interface of the device.
%TRUE on success
a #GUsbDevice
bInterfaceNumber of the interface you wish to claim
#GUsbDeviceClaimInterfaceFlags
Closes the device when it is no longer required.
%TRUE on success
a #GUsbDevice
Perform a USB control transfer.
Warning: this function is synchronous, and cannot be cancelled.
%TRUE on success
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
the length field for the setup packet.
the actual number of bytes sent, or %NULL
timeout timeout (in milliseconds) that this function should wait
before giving up due to no response being received. For an unlimited
timeout, use 0.
a #GCancellable, or %NULL
Do an async control transfer
a #GUsbDevice
a suitably-sized data buffer for
either input or output
the length field for the setup packet.
timeout timeout (in milliseconds) 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
Gets the result from the asynchronous function.
the actual number of bytes sent, or -1 on error.
a #GUsbDevice instance.
the #GAsyncResult
Gets the USB address for the device.
The 8-bit address
a #GUsbDevice
Gets the USB bus number for the device.
The 8-bit bus number
a #GUsbDevice
Gets the device children if any exist.
an array of #GUsbDevice
a #GUsbDevice instance
Get the bConfigurationValue for the active configuration of the device.
Warning: this function is synchronous.
The bConfigurationValue of the active config, or -1 on error
a #GUsbDevice
Get the index for the active Configuration string descriptor
ie, iConfiguration.
a string descriptor index.
a #GUsbDevice
Gets the string index from the vendor class interface descriptor.
a non-zero index, or 0x00 for failure
a #GUsbDevice
a device class, e.g. 0xff for VENDOR
a device subclass
a protocol number
Gets the device class, typically a #GUsbDeviceClassCode.
a device class number, e.g. 0x09 is a USB hub.
a #GUsbDevice
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().
a device protocol number.
a #GUsbDevice
Gets the device subclass qualified by the class number.
See g_usb_device_get_device_class().
a device subclass number.
a #GUsbDevice
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.
a #GUsbInterface or %NULL for not found
a #GUsbDevice
a device class, e.g. 0xff for VENDOR
a device subclass
a protocol number
Gets all the interfaces exported by the device.
an array of interfaces or %NULL for error
a #GUsbDevice
Gets the index for the Manufacturer string descriptor.
a string descriptor index.
a #GUsbDevice
Gets the device parent if one exists.
#GUsbDevice or %NULL
a #GUsbDevice instance
Gets the product ID for the device.
an ID.
a #GUsbDevice
Gets the product ID for the device as a string.
an string ID, or %NULL if not available.
a #GUsbDevice
Gets the platform identifier for the device.
When the device is removed and then replugged, this value is not expected to
be different.
The platform ID, e.g. "usb:02:00:03:01"
a #GUsbDevice
Gets the USB port number for the device.
The 8-bit port number
a #GUsbDevice
Gets the index for the Product string descriptor.
a string descriptor index.
a #GUsbDevice
Gets the BCD firmware version number for the device.
a version number in BCD format.
a #GUsbDevice
Gets the index for the Serial Number string descriptor.
a string descriptor index.
a #GUsbDevice
Gets the BCD specification revision for the device. For example,
`0x0110` indicates USB 1.1 and 0x0320 indicates USB 3.2
a specification revision in BCD format.
a #GUsbDevice
Get a string descriptor from the device. The returned string should be freed
with g_free() when no longer needed.
a newly-allocated string holding the descriptor, or NULL on error.
the index for the string descriptor to retrieve
Get a raw string descriptor from the device. The returned string should be freed
with g_bytes_unref() when no longer needed.
The descriptor will be at most 128 btes in length, if you need to
issue a request with either a smaller or larger descriptor, you can
use g_usb_device_get_string_descriptor_bytes_full instead.
a possibly UTF-16 string, or NULL on error.
the index for the string descriptor to retrieve
the language ID
Get a raw string descriptor from the device. The returned string should be freed
with g_bytes_unref() when no longer needed.
a possibly UTF-16 string, or NULL on error.
the index for the string descriptor to retrieve
the language ID
size of the request data buffer
Gets the vendor ID for the device.
an ID.
a #GUsbDevice
Gets the vendor ID for the device as a string.
an string ID, or %NULL if not available.
a #GUsbDevice
Perform a USB interrupt transfer.
Warning: this function is synchronous, and cannot be cancelled.
%TRUE on success
a #GUsbDevice
the address of a valid endpoint to communicate with
a suitably-sized data buffer for
either input or output
the length field for the setup packet.
the actual number of bytes sent, or %NULL
timeout timeout (in milliseconds) that this function should wait
before giving up due to no response being received. For an unlimited
timeout, use 0.
a #GCancellable, or %NULL
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
the length field for the setup packet.
timeout timeout (in milliseconds) 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
Gets the result from the asynchronous function.
the actual number of bytes sent, or -1 on error.
a #GUsbDevice instance.
the #GAsyncResult
Opens the device for use.
Warning: this function is synchronous.
%TRUE on success
a #GUsbDevice
Release an interface of the device.
%TRUE on success
a #GUsbDevice
bInterfaceNumber of the interface you wish to release
#GUsbDeviceClaimInterfaceFlags
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.
%TRUE on success
a #GUsbDevice
Set the active bConfigurationValue for the device.
Warning: this function is synchronous.
%TRUE on success
a #GUsbDevice
the configuration value to set
Sets an alternate setting on an interface.
%TRUE on success
a #GUsbDevice
bInterfaceNumber of the interface you wish to release
alternative setting number
Flags for the g_usb_device_claim_interface and
g_usb_device_release_interface methods flags parameters.
The USB device class.
The message direction.
The error code.
The USB language ID.
Creates a new device list.
You will need to call g_usb_device_list_coldplug() to coldplug the
list of devices after creating a device list.
a new #GUsbDeviceList
a #GUsbContext
This function does nothing.
a #GUsbDeviceList
Finds a device based on its bus and address values.
a new #GUsbDevice, or %NULL if not found.
a #GUsbDeviceList
a bus number
a bus address
Finds a device based on its bus and address values.
a new #GUsbDevice, or %NULL if not found.
a #GUsbDeviceList
a vendor ID
a product ID
a new #GPtrArray of #GUsbDevice's.
a #GUsbDeviceList
This signal is emitted when a USB device is added.
A #GUsbDevice
This signal is emitted when a USB device is removed.
A #GUsbDevice
Private #GUsbDevice data
The message recipient.
The message request type.
Gets the address of the endpoint.
The 4-bit endpoint address
a #GUsbEndpoint
Gets the direction of the endpoint.
The endpoint direction
a #GUsbEndpoint
Gets any extra data from the endpoint.
a #GBytes, or %NULL for failure
a #GUsbEndpoint
Gets the type of endpoint.
The 8-bit type
a #GUsbEndpoint
Gets the maximum packet size this endpoint is capable of sending/receiving.
The maximum packet size
a #GUsbEndpoint
Gets the number part of endpoint address.
The lower 4-bit of endpoint address
a #GUsbEndpoint
Gets the endpoint polling interval.
The endpoint polling interval
a #GUsbEndpoint
Gets the rate at which synchronization feedback is provided, for audio device only.
The endpoint refresh
a #GUsbEndpoint
Gets the address if the synch endpoint, for audio device only.
The synch endpoint address
a #GUsbEndpoint
Gets the alternate setting for the interface.
alt setting, typically zero.
a #GUsbInterface
Gets the interface class, typically a #GUsbInterfaceClassCode.
a interface class number, e.g. 0x09 is a USB hub.
a #GUsbInterface
Gets interface endpoints.
an array of endpoints, or %NULL on failure
a #GUsbInterface
Gets any extra data from the interface.
a #GBytes, or %NULL for failure
a #GUsbInterface
Gets the index for the string descriptor.
a string descriptor index.
a #GUsbInterface
Gets the type of interface.
The 8-bit address
a #GUsbInterface
Gets the USB bus number for the interface.
The 8-bit bus number
a #GUsbInterface
Gets the interface number.
The interface ID
a #GUsbInterface
Gets the interface protocol qualified by the class and subclass numbers.
See g_usb_interface_get_class() and g_usb_interface_get_subclass().
a interface protocol number.
a #GUsbInterface
Gets the interface subclass qualified by the class number.
See g_usb_interface_get_class().
a interface subclass number.
a #GUsbInterface
The compile-time major version
The compile-time micro version
The compile-time minor version
This function does nothing.
a #GUsbSource
a function to call
data to pass to @func
a #GDestroyNotify
Our personal error quark.
The error code.
This object is used to get a context that is thread safe.
This object is a thin glib wrapper around a libusb_device
A device list that is updated as devices are pluged in and unplugged.
This object is a thin glib wrapper around a libusb_endpoint_descriptor.
All the data is copied when the object is created and the original
descriptor can be destroyed any at point.
This object is a thin glib wrapper around a libusb_interface_descriptor.
All the data is copied when the object is created and the original
descriptor can be destroyed any at point.
This object used to integrate libusb into the GLib main loop before we used
a thread. It's now pretty much unused.
These compile time macros allow the user to enable parts of client code
depending on the version of libgusb installed.
Our personal error quark.
Converts the error code into a string
String, or %NULL
a libusb error code
Gets the GUsb installed runtime version.
a version number, e.g. "0.3.1"