bpod_core.com.verify_serial_discovery

bpod_core.com.verify_serial_discovery(port, expected_message, timeout=1, trigger=None) bool

Check if a device sends an expected discovery message on a serial port.

Opens the specified serial port and waits to receive bytes matching the expected discovery message. Optionally executes a function first, which can be used trigger the device’s discovery routine, e.g., by sending a command.

Parameters:
  • port (str) – The serial port to read from (e.g., ‘/dev/ttyUSB0’ or ‘COM3’).

  • expected_message (bytes) – The exact byte sequence expected from the device.

  • timeout (float, default: 1) – Maximum time (in seconds) to wait for the discovery message. Defaults to 1 s.

  • trigger (Callable, optional) – A function to call before reading. Use this to trigger the device’s discovery routine.

Returns:

True if the device sent the expected message within the timeout period, False otherwise (including if the port cannot be opened).

Return type:

bool