Skip to content

[Bug]: Iohub failing to communicate with Pstbox #7299

@rdkirkden

Description

@rdkirkden

PsychoPy Version

2024.1.5

What OS are your PsychoPy running on?

Windows 10 and 11

Bug Description

In Windows 10 and 11, Coder and Builder programs both crash when using iohub to communicate with a Psychology Software Tools (PST) button box. Coder has been crashing since v2023.2.3, and Builder has been crashing since v2022.1.0. I have identified the causes. For Coder there is a single cause. For Builder there are two causes, one of which is the same as for Coder. The key error message associated with the common cause is:

ERROR: DEVICE CONFIG ERRORS FOUND! IOHUB NOT LOADING DEVICE: psychopy.iohub.devices.serial
errors count 1:
    ('monitor_event_types', ['PstboxButtonEvent'])

I originally reported the bug in PsychoPy Discourse in November 2023 (here) and have more recently described the causes (here). I will summarise the causes here, but please refer to those posts for more detail.

Expected Behaviour

The cause that is common to Coder and Builder is that the ‘getSupportedConfigSettings’ function in ‘psychopy\iohub\util/_init_.py’ returns the wrong value for ‘validation_file_path’. This function always returns a file path ending in ‘supported_config_settings.yaml’, but the ‘yaml’ file for the Pstbox component has a different name because the default name is reserved for the Serial component. I would suggest that the ‘getSupportedConfigSettings’ function is sent the ‘device_class_name’ variable, which will allow it to distinguish between the Pstbox and Serial components and assign a file path accordingly.

In Builder, there is an additional problem that occurs when a code component is used to create an iohub object for communication with the Pstbox. This code clashes with code that Builder automatically generates when creating a Keyboard component, as this also involves creating an iohub object. I have found that a temporary solution is to edit the compiled Builder code to create the Pstbox and Keyboard components at the same time with a single iohub object. I think a better solution might be to add a Pstbox component to the Builder GUI interface, as this would also allow the Keyboard and Pstbox component to be created at the same time with a single iohub object.

Steps to Reproduce

The following Coder program will reproduce the bug, even if a Pstbox is not connected to the PC

import time
from psychopy import core, visual
from psychopy.iohub import launchHubServer

SERIAL_PORT = 'COM4'
BAUDRATE = 19200
psychopy_mon_name = 'Monitor_01'
exp_code = 'pstbox'
sess_code = 'S_{0}'.format(int(time.mktime(time.localtime())))

iohubkwargs = {
'psychopy_monitor_name': psychopy_mon_name,
'experiment_code': exp_code,
'session_code': sess_code,
'serial.Pstbox': dict(name='pstbox', port=SERIAL_PORT, baud=BAUDRATE)
}

ioHubServer = launchHubServer(**iohubkwargs)
display = ioHubServer.devices.display
pstbox = ioHubServer.devices.pstbox

Additional context

In order to test whether a bug fix has worked, it may be necessary to have a Pstbox connected to a serial port, or connected via a USB to serial adapter cable to a USB port. I would be happy to carry out testing, as I have a Pstbox.

Metadata

Metadata

Assignees

Labels

🐞 bugIssue describes a bug (crash or error) or undefined behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions