GUsb.Context¶
- Subclasses:
 None
Methods¶
- Inherited:
 - Structs:
 
class  | 
  | 
class  | 
  | 
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
Virtual Methods¶
- Inherited:
 
  | 
|
  | 
|
  | 
Properties¶
Name  | 
Type  | 
Flags  | 
Short Description  | 
|---|---|---|---|
r/w  | 
|||
r  | 
Signals¶
- Inherited:
 
Name  | 
Short Description  | 
|---|---|
This signal is emitted when a USB device is added.  | 
|
This signal is emitted when a USB device is changed.  | 
|
This signal is emitted when a USB device is removed.  | 
Fields¶
- Inherited:
 
Name  | 
Type  | 
Access  | 
Description  | 
|---|---|---|---|
parent_instance  | 
r  | 
Class Details¶
- class GUsb.Context(**kwargs)¶
 - Bases:
 - Abstract:
 No
- Structure:
 
- classmethod error_quark()¶
 - Returns:
 Our personal error quark.
- Return type:
 
New in version 0.1.0.
- classmethod new()¶
 - Raises:
 - Returns:
 a new
GUsb.Contextobject orNoneon error.- Return type:
 
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, orNoneif 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:
 - Returns:
 a new
GUsb.Device, orNoneif not found.- Return type:
 
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, orNoneif 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.PtrArrayofGUsb.Device's.- Return type:
 
New in version 0.2.2.
- get_flags()¶
 - Returns:
 the
GUsb.ContextFlags, e.g.GUsb.ContextFlags.AUTO_OPEN_DEVICES- Return type:
 
Sets the flags to use for the context.
New in version 0.2.11.
- get_hotplug_poll_interval()¶
 - Returns:
 interval in ms
- Return type:
 
Gets the poll interval for platforms like Windows that do not support
LIBUSB_CAP_HAS_HOTPLUG.New in version 0.3.10.
- get_main_context()¶
 - Returns:
 the
GLib.MainContext- Return type:
 
Gets the internal
GLib.MainContextto use for synchronous methods. By default the value is set to the value ofGLib.MainContext.default()New in version 0.2.5.
- get_source(main_ctx)¶
 - Parameters:
 main_ctx (
GLib.MainContext) – aGLib.MainContext, orNone- Returns:
 the
GUsb.Source.- Return type:
 
This function does nothing.
New in version 0.1.0.
- load(json_object)¶
 - Parameters:
 json_object (
Json.Object) – aJson.Object- Raises:
 - Returns:
 Trueon success- Return type:
 
Loads the context from a JSON object.
New in version 0.4.0.
- load_with_tag(json_object, tag)¶
 - Parameters:
 json_object (
Json.Object) – aJson.Object
- Raises:
 - Returns:
 Trueon success- Return type:
 
Loads any devices with a specified tag into the context from a JSON object.
New in version 0.4.1.
- save(json_builder)¶
 - Parameters:
 json_builder (
Json.Builder) – aJson.Builder- Raises:
 - Returns:
 Trueon success- Return type:
 
Saves the context to an existing JSON builder.
New in version 0.4.0.
- save_with_tag(json_builder, tag)¶
 - Parameters:
 json_builder (
Json.Builder) – aJson.Builder
- Raises:
 - Returns:
 Trueon success- Return type:
 
Saves any devices with a specified tag into an existing JSON builder.
New in version 0.4.1.
- set_debug(flags)¶
 - Parameters:
 flags (
GLib.LogLevelFlags) – aGLib.LogLevelFlagssuch asGLib.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) – someGUsb.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_hotplug_poll_interval(hotplug_poll_interval)¶
 - Parameters:
 hotplug_poll_interval (
int) – the interval in ms
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 afterGUsb.Context.enumerate() has been called.New in version 0.3.10.
- 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.Devicetimeout_ms (
int) – timeout to wait
- Raises:
 - Returns:
 a new
GUsb.Device, orNonefor 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.
- do_device_added(device) virtual¶
 - Parameters:
 device (
GUsb.Device) –
- do_device_changed(device) virtual¶
 - Parameters:
 device (
GUsb.Device) –
- do_device_removed(device) virtual¶
 - Parameters:
 device (
GUsb.Device) –
Signal Details¶
- GUsb.Context.signals.device_added(context, device)¶
 - Signal Name:
 device-added- Flags:
 - Parameters:
 context (
GUsb.Context) – The object which received the signaldevice (
GUsb.Device) – AGUsb.Device
This signal is emitted when a USB device is added.
- GUsb.Context.signals.device_changed(context, device)¶
 - Signal Name:
 device-changed- Flags:
 - Parameters:
 context (
GUsb.Context) – The object which received the signaldevice (
GUsb.Device) – AGUsb.Device
This signal is emitted when a USB device is changed.
- GUsb.Context.signals.device_removed(context, device)¶
 - Signal Name:
 device-removed- Flags:
 - Parameters:
 context (
GUsb.Context) – The object which received the signaldevice (
GUsb.Device) – AGUsb.Device
This signal is emitted when a USB device is removed.
Property Details¶
- GUsb.Context.props.debug_level¶