Hardware
busylight_core.hardware
¶
USB Hardware Description
This module provides a description of USB hardware devices, including HID and serial connections.
Attributes¶
Classes¶
busylight_core.hardware.ConnectionType
¶
Bases: int
, Enum
USB device connection protocols supported by the library.
Defines the different communication protocols that can be used to interact with USB status light devices. Use these values with Hardware.enumerate() to filter device discovery by protocol type.
Attributes¶
busylight_core.hardware.Hardware
dataclass
¶
Hardware(
device_type,
path,
vendor_id,
product_id,
serial_number,
manufacturer_string,
product_string=None,
release_number=None,
usage=None,
usage_page=None,
interface_number=None,
bus_type=None,
is_acquired=False,
)
Represents a USB-connected status light hardware device.
Contains all the information needed to identify, connect to, and communicate with a USB device that can function as a status light. Hardware instances are typically created through discovery methods (enumerate, from_hid, from_portinfo) and then used to initialize Light instances for device control.
Attributes¶
busylight_core.hardware.Hardware.product_string
class-attribute
instance-attribute
¶
busylight_core.hardware.Hardware.release_number
class-attribute
instance-attribute
¶
busylight_core.hardware.Hardware.interface_number
class-attribute
instance-attribute
¶
busylight_core.hardware.Hardware.is_acquired
class-attribute
instance-attribute
¶
busylight_core.hardware.Hardware.device_id
cached
property
¶
A tuple of the vendor and product identifiers.
Each item in the tuple is a 16-bit integer.
Functions¶
busylight_core.hardware.Hardware.enumerate
classmethod
¶
enumerate(by_type=ANY)
Discover all USB devices that could potentially be status lights.
Scans the system for USB devices using HID and serial protocols, creating Hardware instances for each discovered device. Use this for device discovery, inventory management, or when you need to present users with available hardware options.
The returned Hardware instances represent raw device information and have not been tested for compatibility with specific Light classes. Use Light.claims() to determine which Light class can control each device.
:param by_type: Limit discovery to specific connection types or scan all types :return: List of Hardware instances representing discovered USB devices :raises NotImplementedError: If the specified connection type is not supported
Source code in src/busylight_core/hardware.py
busylight_core.hardware.Hardware.from_portinfo
classmethod
¶
Create Hardware instance from serial port information.
Converts a pyserial ListPortInfo object into a Hardware instance suitable for Light class initialization. Use this when you have serial port information from pyserial's list_ports.comports() and need to create a Hardware representation.
:param port_info: Serial port information from pyserial enumeration :return: Hardware instance representing the serial device :raises InvalidHardwareError: If port information is incomplete or invalid
Source code in src/busylight_core/hardware.py
busylight_core.hardware.Hardware.from_hid
classmethod
¶
Create Hardware instance from HID device information.
Converts a HID device dictionary (from hid.enumerate()) into a Hardware instance suitable for Light class initialization. Use this when you have HID device information and need to create a Hardware representation.
:param device: HID device dictionary from hidapi enumeration :return: Hardware instance representing the HID device :raises InvalidHardwareError: If device information is incomplete or invalid
Source code in src/busylight_core/hardware.py
busylight_core.hardware.Hardware.as_dict
¶
Source code in src/busylight_core/hardware.py
busylight_core.hardware.Hardware.acquire
¶
Open the hardware device.
The device is available for I/O operations after this method returns. If the device is already acquired, no actions are taken.
Source code in src/busylight_core/hardware.py
busylight_core.hardware.Hardware.release
¶
Close the hardware device.
Subsequent I/O operations to this device will fail after this method returns. If the device has already been released, no action is taken.