Skip to content

USB Host: Unreliable Unplug Event Detection #10552

@samblenny

Description

@samblenny

There's currently (10.0.0-beta.2) no good way to detect an unplugged USB device using the usb.core.Device API. Unplugging will occasionally raise an immediate usb.core.USBError, but often it just results in a delayed usb.core.USBTimeoutError when you next try to poll the USB device. There's nothing about such USBTimeoutError objects to distinguish them from other timeouts that happen in the normal course of polling some USB devices (e.g. USB receivers for wireless gamepads).

Desktop PyUSB handles unplug events and other error conditions by setting usb.core.USBError.errno and usb.core.USBTimeoutError.errno with values that correlate to different USB bus conditions. CircuitPython's usb.core implementation generally does not set .errno in a useful way, and its exception string descriptions don't provide enough information to identify unplug events.

I'm posting this issue at tannewt's request to split out one of the points I mentioned in USB Host Improvement Quest Umbrella Issue #10551. The point of this issue is to let people know I'm planning to work on this myself and to ask for comments and feedback.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions