raydriver.core.discovery.session
DiscoverySession
Accumulates discovered devices across repeated scans and reports the difference between scans as plain data:
apply_scanreturns(added, removed_keys)— devices are matched by their stableDiscoveredDevice.key.- Serial ports of found devices (those without a
hostparameter) are remembered as held; held ports are meant to be excluded from rescans (re-opening them would reset some boards) and their devices stay listed even though a rescan cannot see them. They leave only viaprune_absent_portswhen the port vanishes from the system. apply_probeattaches a probed profile to a device and returns the enriched device.
devices
devices: list
held_ports
held_ports: set
Ports of known devices; exclude from rescans.
apply_probe()
apply_probe(key: str, profile: Any) -> Optional[discovery.DiscoveredDevice]
Attaches a probed profile to the device with key and returns the enriched device, or None when the key is unknown.
| Parameter | Type | Description |
|---|---|---|
key | str | |
profile | Any | |
| Returns | Optional[discovery.DiscoveredDevice] |
apply_scan()
apply_scan(
devices: Sequence[discovery.DiscoveredDevice],
) -> tuple[list[discovery.DiscoveredDevice], list[str]]
Reconciles the known devices with a fresh scan result. Returns the newly seen devices and the keys of devices that disappeared (excluding those on held ports).
| Parameter | Type | Description |
|---|---|---|
devices | Sequence[discovery.DiscoveredDevice] | |
| Returns | tuple[list[discovery.DiscoveredDevice], list[str]] |
get()
get(key: str) -> Optional[discovery.DiscoveredDevice]
| Parameter | Type | Description |
|---|---|---|
key | str | |
| Returns | Optional[discovery.DiscoveredDevice] |
prune_absent_ports()
prune_absent_ports(present_ports: Iterable[str]) -> list[str]
Drops devices whose serial port is no longer present on the system. Returns the removed keys.
| Parameter | Type | Description |
|---|---|---|
present_ports | Iterable[str] | |
| Returns | list[str] |
reset()
reset() -> None
Forgets everything (e.g. when the UI re-enters discovery).
| Parameter | Type | Description |
|---|---|---|
| Returns | None |