USB Inspector
Overview
A simple package that leverages pyusb and allows you to lookup USB vendor and device IDs and get back a human readable vendor and device name.
It includes ability to manually update the USB DB without installing a new version of usb-inspector.
Installation
uv add usb-inspector
# via pip
python3 -m pip install usb-inspector
IMPORTANT: On Windows ensure you have libusb-1.0.dll (64bit) in C:\Windows\System32 or you will get a NoBackendError. You can get it from here.
Example Usage
Command Line:
usb-inspector lookup --vendor-id 1A40
usb-inspector lookup --vendor-id 1A40 --device-id 0801
# To manually update the USB DB
usb-inspector delete-data
usb-inspector update-db
import asyncio
from usb_inspector import create_usb_monitoring_service
async def main():
service = create_usb_monitoring_service(poll_interval=1.0)
monitor_task = asyncio.create_task(service.run())
await asyncio.sleep(10)
await service.stop()
await monitor_task
asyncio.run(main())
Device identity
USB Inspector uses a device's vendor/product IDs and USB serial number as its preferred identity. When a backend cannot read a serial number temporarily, it uses the USB bus and port path to retain the identity already associated with that physical connection. USB addresses are not treated as stable because they can change when a device re-enumerates.
If a device has no readable serial number and is moved to a different USB port, it is necessarily reported as a new device.
Issues
If you experience any issues, please create an issue on Bitbucket.
Development
To get a list of all commands with descriptions simply run just.
just env
just pip-install-editable
Testing
just pytest
just coverage
just open-coverage
History
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
1.1.0 (2026-08-11)
- FIXED transient USB serial-number read failures no longer create duplicate device records or spurious disconnect/connect events.
- CHANGED device monitoring now reads each serial number once per snapshot and uses the USB bus/port path to preserve an established device identity when the serial is temporarily unavailable.
- ADDED detection of a different serial number at the same USB port as a device replacement.
1.0.0 (2026-05-22)
Breaking changes
- REMOVED
USBDeviceMonitorfrom the public API. Usecreate_usb_monitoring_service()instead, which returns aUSBMonitoringServiceinstance with the same behavior. - REMOVED standalone free functions
lookup_usb_details,delete_usb_db,delete_data_file, andupdate_usb_dbfromusb_inspector.usb.infrastructure.repository. UseSQLiteUSBDetailsRepositoryandUSBDatabaseMaintenanceRepositorydirectly. - CHANGED public API of
usb_inspectorpackage now exportsUSBMonitoringService,USBDetailsLookupPort, andcreate_usb_monitoring_service. ImportingUSBDeviceMonitorfrom the top-level package will raiseImportError.USBEnumeratorPortremains importable fromusb_inspector.usb.application.ports.
Other changes
- CHANGED package no longer initialises the USB database on import. Initialisation is now lazy: the database is created on the first call to
SQLiteUSBDetailsRepository.lookup()if it does not already exist. - CHANGED
usb_inspector.usbpackage no longer re-exportsUSBMonitoringService; import fromusb_inspectororusb_inspector.usb.application.servicedirectly. - CHANGED
usb_inspector.usb.infrastructurepackage now exports onlycreate_usb_monitoring_service; concrete repository classes remain importable from their module.
0.3.1 (2026-04-21)
- CHANGED updated build backend and release tooling configuration.
- CHANGED refreshed Justfile workflows for environment, testing, and release checks.
- CHANGED updated packaging/verification helper scripts and dependency lock maintenance.
- CHANGED updated pre-commit toolchain versions.
0.3.0 (2026-03-13)
- CHANGED refactored package internals to a layered DDD structure under
usb_inspector.usb(domain/application/infrastructure/interface). - CHANGED internal legacy modules
db.py,update.py, andcli.pywere removed; CLI entry point now resolves tousb_inspector.usb.interface.router:cli. - CHANGED
usb_inspector.monitorremains available as a compatibility shim forUSBDeviceMonitor. - FIXED circular import issues in package initialization/import flow.
- ADDED layered test coverage for application and infrastructure modules plus import regression coverage.
0.2.2 (2025-12-04)
- ADDED tox and more test coverage
0.2.1 (2025-11-21)
- ADDED
portto the device info - CHANGED cleaned up logging on connect/disconnect descriptions
0.2.0 (2025-11-21)
- FIXED Connecting/Disconnecting the same physical device to the same port now correctly identifies the device as the same device on Windows/Linux.
0.1.9 (2025-11-21)
- FIXED Cached sql db lookup so it occurs only once.
0.1.8 (2025-11-20)
- FIXED turned default packaged logging to
ERROR. WasINFO...Sorry!
0.1.7 (2025-11-13)
- FIXED
is_connectedbug introduced in last patch. - ADDED improved tracking of devices allowing multiple of the same vendor/device ID to be connected.
0.1.6 (2025-11-13)
- FIXED
last_seentimestamp for each device, only updates when connected/disonnected.
0.1.5 (2025-11-05)
- Locked
pandasto version 2.3.3 for Raspberry Pi compatability (it pulls the pre-built wheel from piwheels.org)
0.1.4 (2025-11-05)
- Added
last_seentimestamp for each device.
0.1.4 (2025-10-31)
update-dbcli command only adds new Vendors and Devices to the existing DB rather than requiring deletion and recreation of the DB.- Track which devices are connected/disconnected.
0.1.2 (2025-10-30)
- Fix lookup error
0.1.1 (2025-10-30)
- Added
startas an alias formonitor.
0.1.0 (2025-10-30)
- First release
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file usb_inspector-1.1.0.tar.gz.
File metadata
- Download URL: usb_inspector-1.1.0.tar.gz
- Upload date:
- Size: 356.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1ef6ee79a494b1eeb6f7e0404b615d0a29287eb42f862e1bdd333e2df951526
|
|
| MD5 |
133422db2bb7d60215300276261d5d70
|
|
| BLAKE2b-256 |
25f079f2124bdaf6df140134f4adf261e0fe90c7ab4f693fe65af50d7f3b966a
|
File details
Details for the file usb_inspector-1.1.0-py3-none-any.whl.
File metadata
- Download URL: usb_inspector-1.1.0-py3-none-any.whl
- Upload date:
- Size: 273.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1931d060aa2c886e98938215c3c21137a4f167bd6ca0096fd560ed93e1d0a6ec
|
|
| MD5 |
69c0aafa9fc2ce9f7c240ee00ee89f01
|
|
| BLAKE2b-256 |
a1a0ff90d7812f87d655218b55645fdad97a411a936db9f692d49c8a2235cc96
|