bpod_core.bpod.Bpod
- class bpod_core.bpod.Bpod
Bases:
SerialDevice,AbstractBpodClass for interfacing with a Bpod Finite State Machine.
- __init__(port=None, serial_number=None, *, remote=False) None
Initialize the serial device.
- Parameters:
port (
str) – The serial port device path (e.g., ‘/dev/ttyUSB0’ or ‘COM3’).serial_device_name (
str, optional) – Name used to identify this device in log messages, by default'serial_device'.open_connection (
bool, optional) – Whether to open the connection immediately, by default True.**kwargs – Additional arguments for compatibility with subclasses.
serial_number (str | None)
remote (bool)
- Raises:
serial.SerialException – If the specified port does not exist.
- Return type:
None
- close() None
Close the connection to the Bpod.
- Raises:
SerialException – If the port could not be closed.
- Return type:
- reset_session_clock() bool
Reset the Bpod session clock to zero.
- Returns:
True if the Bpod acknowledged the command.
- Return type:
- run_state_machine(*, blocking=True) None
Run the previously sent state machine.
- Parameters:
blocking (
bool, optional) – If True (default), block until the state machine finishes. If False, return immediately after starting.- Raises:
RuntimeError – If a state machine is already running.
- Return type:
- send_state_machine(state_machine, *, run_asap=False, validate_only=False) None
Send a state machine to the Bpod.
This method compiles the provided state machine into a byte array format compatible with the Bpod and sends it to the device. It also validates the state machine for compatibility with the hardware before sending.
- Parameters:
state_machine (
StateMachine) – The state machine to be sent to the Bpod device.run_asap (
bool, optional) – If True, the state machine will run immediately after the current one has finished. Default is False.validate_only (
bool, optional) – If True, the state machine is only validated and not sent to the device. Default is False.
- Raises:
ValueError – If the state machine is invalid or exceeds hardware limitations.
validate_callCallHintViolation – If function arguments don’t match type hints.
- Return type:
- validate_state_machine(state_machine) None
Validate the provided state machine for compatibility with the hardware.
- Parameters:
state_machine (
StateMachine) – The state machine to validate.- Raises:
ValueError – If the state machine is invalid or not compatible with the hardware.
- Return type:
- wait() None
Wait for the currently running state machine to finish.
Blocks until the state machine thread completes. If no state machine is currently running, this method returns immediately.
- Return type:
-
inputs:
NamedTuple Available input channels.
-
modules:
NamedTuple Available modules.
-
outputs:
NamedTuple Available output channels.
- property port: str
The name of the serial port.
- Returns:
The device path of the serial port (e.g., ‘/dev/ttyACM0’).
- Return type:
- property serial0: ExtendedSerial
Primary serial device for communication with the Bpod.
-
serial1:
ExtendedSerial|None= None Secondary serial device for communication with the Bpod.
-
serial2:
ExtendedSerial|None= None Tertiary serial device for communication with the Bpod - used by Bpod 2+ only.
- property version: VersionInfo
Version information of the Bpod’s firmware and hardware.