Ir al contenido principal

raydriver.core.discovery.session

DiscoverySession​

Accumulates discovered devices across repeated scans and reports the difference between scans as plain data:

  • apply_scan returns (added, removed_keys) — devices are matched by their stable DiscoveredDevice.key.
  • Serial ports of found devices (those without a host parameter) 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 via prune_absent_ports when the port vanishes from the system.
  • apply_probe attaches 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.

ParameterTypeDescription
keystr
profileAny
ReturnsOptional[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).

ParameterTypeDescription
devicesSequence[discovery.DiscoveredDevice]
Returnstuple[list[discovery.DiscoveredDevice], list[str]]

get()​

get(key: str) -> Optional[discovery.DiscoveredDevice]
ParameterTypeDescription
keystr
ReturnsOptional[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.

ParameterTypeDescription
present_portsIterable[str]
Returnslist[str]

reset()​

reset() -> None

Forgets everything (e.g. when the UI re-enters discovery).

ParameterTypeDescription
ReturnsNone