You are viewing unmaintained documentation for an older version of OpenSesame. Click here to view the current documentation. Your version of OpenSesame: Language:

OpenSesame 3.0.0 will bring amazing new features! Curious? Take it for a test spin, and help us iron out the kinks.

SR Box

Overview

About the srbox plug-in

The serial response (SR) box is a button box, specifically designed for response collection in psychological experiments. The original version, developed by Psychology Software Tools, has 5 buttons, 5 lights, and is connected to the PC trough the serial port. There are also SR Box compatible devices by other manufacturers, which may differ in the number of buttons and lights and often use a USB connection, which emulates a serial port. The advantage of using an SR Box is that response times can be measured more accurately than using a garden variety keyboard. Of course, it also looks much more sciency. The SR Box plug-in for OpenSesame allows you to use the SR Box or compatible device in your OpenSesame experiments. The plug-in appears as an item in the item toolbar and you can simply drag it into your experiment.

Screenshot

No alt text specified

Setting the device name

By default, the plug-in tries to autodetect your SR Box. If this works, you don’t have to change it. If your experiment freezes, OpenSesame has chosen the wrong serial port and you must enter the device name manually. Under Windows, the device is probably called something like

COM4

Under Linux the device is probably called something like

/dev/tty0

Requirements

An SR Box or compatible device and OpenSesame 0.22 or higher.

Download and installation

As of 0.25, the srbox plugin is included with OpenSesame by default, so no installation is required.

Using the SR Box from Python inline code

class libsrbox

If you insert the srbox plugin at the start of your experiment, an instance of libsrbox automatically becomes part of the experiment object and can be accessed from within an inline_script item as exp.srbox.

Important note 1:

If you do not specify a device, the plug-in will try to autodetect the SR Box port. However, on some systems this freezes the experiment, so it is better to explicitly specify a device.

Important note 2:

You need to call libsrbox.start to put the SR Box in sending mode, before calling libsrbox.get_button_press to collect a button press.

Function list:

Example:

t0 = self.time()
exp.srbox.start()
buttonlist, t1 = exp.srbox.get_button_press(allowed_buttons=[1,2])
if 1 in buttonlist:
        response_time = t1 - t0
        print('Button 1 was pressed in %d ms!' % response_time)
exp.srbox.stop()

function libsrbox.__init__(experiment, dev=None)

Constructor. An srbox object is created automatically by the srbox plug-in, and you do not generally need to call the constructor yourself.

Arguments:

  • experiment – An Opensesame experiment.
    • Type: experiment

Keywords:

  • dev – No description
    • Default: None

function libsrbox.close()

Closes the connection to the srbox.

function libsrbox.get_button_press(allowed_buttons=None, timeout=None)

Collect a button press from the SR box. This function will return right away if a button is already pressed.

Keywords:

  • allowed_buttons – A list of buttons that are accepted or None to accept all buttons. Valid buttons are integers 1 through 8.
    • Type: list, NoneType
    • Default: None
  • timeout – A timeout value in milliseconds or None for no timeout.
    • Type: int, float, NoneType
    • Default: None

Returns:

A timestamp, buttonlist tuple. The buttonlist consists of a list of button numbers.

  • Type: tuple

function libsrbox.send(ch)

Sends a single character to the SR Box.

Arguments:

  • ch – The character to send.
    • Type: str

function libsrbox.start()

Turns on sending mode, so that the SR Box starts to send output. The SR Box must be in sending mode when you call libsrbox.get_button_press.

function libsrbox.stop()

Turns off sending mode, so that the SR Box stops giving output.