bpod_core.bpod.Bpod

class bpod_core.bpod.Bpod

Bases: AbstractBpod

Bpod class for interfacing with the Bpod Finite State Machine.

__init__(port=None, serial_number=None) None
Parameters:
  • port (str | None)

  • serial_number (str | None)

Return type:

None

close() None

Close the connection to the Bpod.

Return type:

None

open() None

Open the connection to the Bpod.

Raises:
  • SerialException – If the port could not be opened.

  • BpodException – If the handshake fails.

Return type:

None

reset_session_clock() bool
Return type:

bool

run_state_machine(*, blocking=True) None

Temporary run method for debugging purposes.

Return type:

None

Parameters:

blocking (bool)

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:

None

set_status_led(enabled) bool

Enable or disable the Bpod’s status LED.

Parameters:

enabled (bool) – True to enable the status LED, False to disable.

Returns:

True if the operation was successful, False otherwise.

Return type:

bool

stop_state_machine() None

Stop the currently running state machine.

Return type:

None

update_modules() None

Update the list of connected modules and their configurations.

Return type:

None

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:

None

wait() None

Wait for the currently running state machine to finish.

This method blocks until the state machine has finished executing. If no state machine is currently running, it raises a RuntimeError.

Return type:

None

actions: list[str]

List of output actions.

event_names: list[str]

List of event names.

inputs: NamedTuple

Available input channels.

property is_running: bool

Check if the Bpod is currently running a state machine.

property location: str | None

Get the location of the Bpod device.

modules: NamedTuple

Available modules.

property name: str | None

Get the name of the Bpod device.

outputs: NamedTuple

Available output channels.

property port: str | None

The port of the Bpod’s primary serial device.

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.