bpod_core.com.SerialDevice

class bpod_core.com.SerialDevice

Bases: AbstractContextManager

Class that interfaces with a USB serial device.

__init__(port, *, open_connection=True) None

Initialize the serial device.

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

  • open_connection (bool, default: True) – Whether to open the connection immediately.

Raises:

serial.SerialException – If the specified port does not exist.

Return type:

None

close() None

Close the serial connection.

If the connection is already closed, this method does nothing.

Raises:

serial.SerialException – If the connection cannot be closed.

Return type:

None

open() None

Open the serial connection.

If the connection is already open, this method does nothing.

Raises:

serial.SerialException – If the connection cannot be opened.

Return type:

None

property port: str

The name of the serial port.

Returns:

The device path of the serial port (e.g., ‘/dev/ttyACM0’).

Return type:

str