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

Test the next generation of OpenSesame: 2.9.0 Hesitant Heisenberg!

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

If you insert the srbox plugin at the start of your experiment, an srbox object automatically becomes part of the experiment object and can be accessed from within an inline_script item as exp.srbox. Below is a list of available functions.

class libsrbox

Function overview:
__init__
close
get_button_press
send
start
stop

libsrbox.__init__(experiment, dev=None)
Constructor. Connects to the SR Box.

Arguments:
experiment → Opensesame experiment.

Keywords arguments:
dev → The srbox device port or None for auto-detect (default=None).
libsrbox.close()
Closes the connection to the srbox. This is (sometimes?) required in order to re-use the SR Box in the same session of OpenSesame.
libsrbox.get_button_press(allowed_buttons=None, timeout=None)
Gets a button press from the SR box.

Keywords arguments:
allowed_buttons → A list of buttons that are accepted or None to accept all buttons. Valid buttons are integers 1 through 8. (default=None)
timeout → A timeout value or None for no timeout. (default=None)

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

Example:
exp.srbox.start()
timestamp, buttonlist = exp.srbox.get_button_press(allowed_buttons=[1,2])
if 1 in buttonlist:
		print('Button 1 was pressed!')
exp.srbox.stop()

libsrbox.send(ch)
Sends a single character.

Arguments:
ch → The character to send.
libsrbox.start()
Turns on sending mode, to start giving output.

Example:
exp.srbox.start()
timestamp, buttonlist = exp.srbox.get_button_press(allowed_buttons=[1,2])
if 1 in buttonlist:
		print('Button 1 was pressed!')
exp.srbox.stop()

libsrbox.stop()
Turns off sending mode, to stop giving output.

Example:
exp.srbox.start()
timestamp, buttonlist = exp.srbox.get_button_press(allowed_buttons=[1,2])
if 1 in buttonlist:
		print('Button 1 was pressed!')
exp.srbox.stop()