GUsb.Context¶
| Subclasses: | None | 
|---|
Methods¶
| Inherited: | GObject.Object (37), Gio.Initable (2) | 
|---|---|
| Structs: | GObject.ObjectClass (5) | 
| class | error_quark() | 
| class | new() | 
| enumerate() | |
| find_by_bus_address(bus, address) | |
| find_by_platform_id(platform_id) | |
| find_by_vid_pid(vid, pid) | |
| get_devices() | |
| get_flags() | |
| get_main_context() | |
| get_source(main_ctx) | |
| set_debug(flags) | |
| set_flags(flags) | |
| set_main_context(main_ctx) | |
| wait_for_replug(device, timeout_ms) | 
Virtual Methods¶
| Inherited: | GObject.Object (7), Gio.Initable (1) | 
|---|
| do_device_added(device) | |
| do_device_removed(device) | 
Properties¶
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| debug-level | int | r/w | |
| libusb-context | int | r | 
Signals¶
| Inherited: | GObject.Object (1) | 
|---|
| Name | Short Description | 
|---|---|
| device-added | This signal is emitted when a USB device is added. | 
| device-removed | This signal is emitted when a USB device is removed. | 
Fields¶
| Inherited: | GObject.Object (1) | 
|---|
| Name | Type | Access | Description | 
|---|---|---|---|
| parent | GObject.Object | r | |
| priv | GUsb.ContextPrivate | r | 
Class Details¶
- 
class GUsb.Context(**kwargs)¶
- Bases: - GObject.Object,- Gio.Initable- Abstract: - No - Structure: - GUsb.ContextClass- 
classmethod new()¶
- Raises: - GLib.Error- Returns: - a new - GUsb.Contextobject or- Noneon error.- Return type: - GUsb.Context- Creates a new context for accessing USB devices. - New in version 0.1.0. 
 - 
enumerate()¶
- 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. - New in version 0.2.2. 
 - 
find_by_bus_address(bus, address)¶
- Parameters: - Raises: - Returns: - a new - GUsb.Device, or- Noneif not found.- Return type: - Finds a device based on its bus and address values. - New in version 0.2.2. 
 - 
find_by_platform_id(platform_id)¶
- Parameters: - platform_id ( - str) – a platform id, e.g. “usb:00:03:03:02”- Raises: - GLib.Error- Returns: - a new - GUsb.Device, or- Noneif not found.- Return type: - GUsb.Device- Finds a device based on its platform id value. - New in version 0.2.4. 
 - 
find_by_vid_pid(vid, pid)¶
- Parameters: - Raises: - Returns: - a new - GUsb.Device, or- Noneif not found.- Return type: - Finds a device based on its bus and address values. - New in version 0.2.2. 
 - 
get_devices()¶
- Returns: - a new - GLib.PtrArrayof- GUsb.Device’s.- Return type: - [ - GUsb.Device]- New in version 0.2.2. 
 - 
get_flags()¶
- Returns: - the - GUsb.ContextFlags, e.g.- GUsb.ContextFlags.AUTO_OPEN_DEVICES- Return type: - GUsb.ContextFlags- Sets the flags to use for the context. - New in version 0.2.11. 
 - 
get_main_context()¶
- Returns: - the - GLib.MainContext- Return type: - GLib.MainContext- Gets the internal - GLib.MainContextto use for synchronous methods. By default the value is set to the value of- GLib.MainContext.default()- New in version 0.2.5. 
 - 
get_source(main_ctx)¶
- Parameters: - main_ctx ( - GLib.MainContext) – a- GLib.MainContext, or- None- Returns: - the - GUsb.Source.- Return type: - GUsb.Source- This function does nothing. - New in version 0.1.0. 
 - 
set_debug(flags)¶
- Parameters: - flags ( - GLib.LogLevelFlags) – a- GLib.LogLevelFlagssuch as- GLib.LogLevelFlags.LEVEL_ERROR|- GLib.LogLevelFlags.LEVEL_INFO, or 0- Sets the debug flags which control what is logged to the console. - Using - GLib.LogLevelFlags.LEVEL_INFOwill output to standard out, and everything else logs to standard error.- New in version 0.1.0. 
 - 
set_flags(flags)¶
- Parameters: - flags ( - GUsb.ContextFlags) – some- GUsb.ContextFlags, e.g.- GUsb.ContextFlags.AUTO_OPEN_DEVICES- Sets the flags to use for the context. These should be set before - GUsb.Context.enumerate() is called.- New in version 0.2.11. 
 - 
set_main_context(main_ctx)¶
- Parameters: - main_ctx ( - GLib.MainContext) –- Sets the internal - GLib.MainContextto use for synchronous methods.- New in version 0.2.5. 
 - 
wait_for_replug(device, timeout_ms)¶
- Parameters: - device (GUsb.Device) – aGUsb.Device
- timeout_ms (int) – timeout to wait
 - Raises: - Returns: - a new - GUsb.Device, or- Nonefor invalid- Return type: - 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. - New in version 0.2.9. 
- device (
 - 
do_device_added(device) virtual¶
- Parameters: - device ( - GUsb.Device) –
 - 
do_device_removed(device) virtual¶
- Parameters: - device ( - GUsb.Device) –
 
- 
classmethod 
Signal Details¶
- 
GUsb.Context.signals.device_added(context, device)¶
- Signal Name: - device-added- Flags: - Parameters: - context (GUsb.Context) – The object which received the signal
- device (GUsb.Device) – AGUsb.Device
 - This signal is emitted when a USB device is added. 
- context (
- 
GUsb.Context.signals.device_removed(context, device)¶
- Signal Name: - device-removed- Flags: - Parameters: - context (GUsb.Context) – The object which received the signal
- device (GUsb.Device) – AGUsb.Device
 - This signal is emitted when a USB device is removed. 
- context (