Skip to main content

Hardware detector CLI for USB serial/debug devices (TriLightSense, STLINK-V3, ESP32, host info).

Project description

hwscan

A Python CLI tool that detects attached hardware devices on Linux systems. It scans for connected USB devices, storage devices, and host system information, outputting results in JSON format.

Features

Supported Hardware Detection:

  • TriLightSense (FTDI devices)
  • STLINK-V3 (ST-Link debuggers with attached storage)
  • ESP32 (C5 WROOM variant)
  • Arduino Leonardo
  • JLink (Segger JLink debuggers)
  • UART to DMX converters
  • Host System Info (hostname, model name, system UUID)

Installation

Prerequisites

  • Python 3.8 or higher
  • Linux operating system (uses sysfs for device detection)

Install from PyPI

pip install lr-hwscan

Install from source

git clone <repository-url>
cd lr-hwscan
pip install -e ".[dev]"

Usage

Basic Usage

Run the scanner with JSON output:

hwscan

Pretty-print JSON Output

For more readable JSON formatting:

hwscan --pretty

Display Detector Errors

To see any errors encountered during hardware detection:

hwscan --errors

Combined example:

hwscan --pretty --errors

Save Results to File

Save hardware detection results to a JSON file:

hwscan --output hardware.json

Smart Merging: If the file already exists, the tool intelligently merges new detection results with existing data. This preserves any custom fields you've added (like name for device mapping) while updating detected information:

# First run - creates the file
hwscan --output hardware.json

# Later, if device configuration changes, custom fields are preserved
hwscan --output hardware.json

Example: If your hardware.json contains custom mapping data:

{
  "3C:DC:75:84:F9:7C": {
    "name": "spi-bridge-timo",
    "type": "esp32-c5-wroom",
    "tty": "/dev/ttyACM0"
  }
}

And the tty changes to /dev/ttyACM1, running hwscan --output hardware.json will update the tty while preserving the name field.

Show Version

hwscan --version

Output Format

The tool outputs a JSON object where each key is a unique hardware identifier and the value contains device information.

Example output:

{
  "trilightsense_0": {
    "vendor": "FTDI",
    "product": "TriLightSense",
    "serial": "FTDI123456",
    "port": "/dev/ttyUSB0"
  },
  "stlink_0": {
    "vendor": "STMicroelectronics",
    "product": "STLINK-V3",
    "serial": "STL12345678",
    "port": "/dev/ttyACM0"
  },
  "host_system": {
    "hostname": "workstation-01",
    "model": "Dell Inc.",
    "uuid": "550e8400-e29b-41d4-a716-446655440000"
  }
}

Use Cases

  • Hardware Inventory: Automatically detect and catalog connected devices in labs or production environments
  • CI/CD Pipelines: Verify required hardware is available before running CI tests
  • Device Management: Track connected debugging and serial devices
  • System Integration: Generate hardware resource definitions for automated test systems

Development

Run Tests

make test

Format Code

make black

Build Distribution

make build

Requirements

Runtime Dependencies:

  • requests >= 2.32
  • typer >= 0.12
  • rich >= 13.7
  • pydantic >= 2.8

Development Dependencies:

  • black >= 25.9.0
  • pytest >= 8.4.2
  • pytest-html
  • pytest-cov
  • build >= 1.2.1
  • twine >= 5.1.1

License

MIT License - See LICENSE file for details

Support

This tool is intended for internal LumenRadio use. For issues or feature requests, please contact the development team.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lr_hwscan-1.1.0.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lr_hwscan-1.1.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file lr_hwscan-1.1.0.tar.gz.

File metadata

  • Download URL: lr_hwscan-1.1.0.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for lr_hwscan-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b42115f4f0b4e0be68a24af72d4d4c9eba770a1e58cd8c1f50cc733c24ebc7d7
MD5 99e597053686e0a4efab1a55f8354c77
BLAKE2b-256 98fbae4083f2b6e2d61f5b8f892e22acfc107f0badf078cc525040398e5c9941

See more details on using hashes here.

File details

Details for the file lr_hwscan-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: lr_hwscan-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for lr_hwscan-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4abf749a65497ff53b82a926ede75691c8bd988cc7003179194fb3347e14a56
MD5 111a7ad480e588026aa8fe48998364b5
BLAKE2b-256 e285d299fae5b52390667c2ca0a7c5f444218ac54c7d31fc894371bdc650884c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page