raydriver.core.discovery
DeviceIdentity
Everything known about a discovered device that can be used to match it against a known device profile.
banner
banner: Optional[str]
firmware
firmware: Optional[str]
tokens
tokens: Any
The identity tokens as a frozenset of strings.
usb_pid
usb_pid: Optional[int]
usb_vid
usb_vid: Optional[int]
DiscoveredDevice
A device found by evaluating scan output against a driver's discovery declaration.
detail
detail: str
driver_name
driver_name: str
identity
identity: DeviceIdentity
key
key: str
Stable identity for deduplication in the UI.
label
label: str
params
params: dict
probe_name
probe_name: Optional[str]
The machine name the device itself reported, if any.
probe_profile
probe_profile: Optional[Any]
Profile data collected by probing the device after discovery; attached by the embedding application's UI. Opaque here.
Functions
device_key()
device_key(driver_name: str, params: dict) -> str
Stable identity for a device from its driver and connection parameters: serial ports by path, network devices by host and TCP port, remote devices by daemon endpoint plus device resource.
| Parameter | Type | Description |
|---|---|---|
driver_name | str | |
params | dict | |
| Returns | str |
find_subnet_devices()
find_subnet_devices(
specs: Sequence[dict],
subnets: Optional[Sequence[tuple[str, int]]] = None,
) -> Any
Scan the local subnets for declared TCP ports and confirm each reachable host with its spec's probe.
specs is a list of dicts with the keys id (opaque caller identifier), port, and optionally
probe_command (sent to confirm the firmware) and match_prefix (response-line prefix identifying
it), plus the declaring driver's display fields (driver_name, label, firmware). Without a
probe command any listener on the port is claimed. Returns one DiscoveredDevice per claimed
host; the first matching spec claims a host.
subnets overrides the interface enumeration as (address, prefixlen) pairs; None scans the local interfaces.
| Parameter | Type | Description |
|---|---|---|
specs | Sequence[dict] | |
subnets | Optional[Sequence[tuple[str, int]]] = None | |
| Returns | Any |
local_subnets()
local_subnets() -> list[tuple[str, int]]
The local non-loopback IPv4 interfaces as (address, prefixlen) pairs, for subnet scans.
| Parameter | Type | Description |
|---|---|---|
| Returns | list[tuple[str, int]] |
scan_mdns_services()
scan_mdns_services(
service_types: Sequence[str],
browse_window: float = 2.0,
) -> Any
Browse mDNS for the given service types.
Returns one dict per resolved service with the keys service_type (normalized, e.g. _http._tcp),
name, host, port, server and txt (a str->str dict). browse_window is the listen time in
seconds.
| Parameter | Type | Description |
|---|---|---|
service_types | Sequence[str] | |
browse_window | float = 2.0 | |
| Returns | Any |
scan_serial_ports()
scan_serial_ports(
ports: Sequence[str],
baud_rates: Optional[Sequence[int]] = None,
timeout: Optional[float] = None,
) -> Any
Probe serial ports for device output.
Opens each port once, tries the baud rates in order and captures everything a talking device sends.
Returns one dict per talking port with the keys port, baud_rate and data (bytes). timeout
bounds the whole scan; observations collected so far are still returned when it expires.
| Parameter | Type | Description |
|---|---|---|
ports | Sequence[str] | |
baud_rates | Optional[Sequence[int]] = None | |
timeout | Optional[float] = None | |
| Returns | Any |
scan_subnet()
scan_subnet(
hosts: Sequence[str],
port: int,
connect_timeout: float = 0.5,
concurrency: int = 32,
) -> Any
TCP-connect to port on every host and return the hosts that accept a connection, in input order.
At most concurrency connects run in flight, each bounded by connect_timeout seconds. Intended for explicit, user-requested scans only.
| Parameter | Type | Description |
|---|---|---|
hosts | Sequence[str] | |
port | int | |
connect_timeout | float = 0.5 | |
concurrency | int = 32 | |
| Returns | Any |
subnet_hosts()
subnet_hosts(address: str, prefixlen: int) -> list[str]
The host addresses to probe on the subnet containing address.
Networks wider than /24 are narrowed to the /24 around the address; network and broadcast addresses are excluded.
| Parameter | Type | Description |
|---|---|---|
address | str | |
prefixlen | int | |
| Returns | list[str] |