psychopy.org | Reference | Downloads | Github

Strange problem (for me) with PsychoPy-PsychoToolBox-ioLab Button box on Windows

Here are my settings.
My main machine : MacBook Pro, macOS 10.15.3, StandalonePsychoPy3-2020.1.0-MacOS
My secondary machine : DELL Latitude; Windows 10 18363.657, StandalonePsychoPy3-2020.1.0-win64

An ioLab Systems button box connected to a USB port of either the main machine or the secondary.

The button box port 0 or 2 is connected to a parallel I/O port of a Biopac MP36R. The MP36R is connected to a USB port of a Macbook with AcqKnowledge. In AcqKnowledge a window is open showing the values of the input ports.

I’m using the following code for my tests.

# Tests of settings for ioLabs Button Box I/O port
# Joël Brogniart - 202002
# Informations about commands and settings where found
# in the python-ioLabs code <https://github.com/ioLab/python-ioLabs/>
# and the "PsyScope X- USB BBOX Manual".

import psychopy, sys, time
import numpy as np
import psychtoolbox as ptb

resetClockCommand = np.uint8(0x52)
purgeQueueCommand = np.uint8(0x51)
logicSetCommand = np.uint8(0x4c)
directionSetCommand = np.uint8(0x57)
port0SetCommand = np.uint8(0x30)
port2SetCommand = np.uint8(0x32)
port0_2SetCommand = np.uint8(0x3D)
allPositiveLogic = np.uint8(0xFF)
allNegativeLogic = np.uint8(0)
# It seems that 0 is for output direction and 0xFF for input direction
allOutputDirection = np.uint8(0xFF)
allInputDirection = np.uint8(0)
disableLoopBackPort2 = np.uint8(0)
enableLoopBackPort2 = np.uint8(1)
allUp = np.uint8(0xFF)
allDown = np.uint8(0)

iolabID = 0x19BC
bboxID = 0x0001

def getBBoxIndex(devices):
    bboxIndex = -1
    for dev in devices:
        if dev['vendorID'] == iolabID and dev['productID'] == bboxID:
            bboxIndex = dev['index']
            break
    return bboxIndex

def initBBox(bboxIndex): 
    ptb.PsychHID('SetReport', bboxIndex, 2, 0, [directionSetCommand, disableLoopBackPort2, allInputDirection, allInputDirection])
    ptb.PsychHID('SetReport', bboxIndex, 2, 0, [logicSetCommand, allPositiveLogic, allPositiveLogic])
    ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port0_2SetCommand, allDown, allDown])
    ptb.PsychHID('SetReport', bboxIndex, 2, 0, [resetClockCommand])
    ptb.PsychHID('SetReport', bboxIndex, 2, 0, [purgeQueueCommand])

def setBitsOnPort(bits, port):
    # Set port 0 and 2 simultaneously.
    # ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port0_2SetCommand, unknown_usage, port2_bits, port0_bits])
    # To set only port0 use
    # ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port0SetCommand, port0_bits])
    # To set only port2 (and leds) use
    # ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port2SetCommand, port2_bits])
    if port == 0:
        ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port0SetCommand, bits])
    elif port == 2:
        ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port2SetCommand, bits])
    else:
        print('Unknown port: {:d}'.port)
        sys.exit(0)

devices = ptb.PsychHID('devices')
bboxIndex = getBBoxIndex(devices)
if bboxIndex == -1:
    print('No ioLabs button box found')
    sys.exit(0)
print('ioLabs button box found')
initBBox(bboxIndex)

# Simple loop to turn on each led one after the other.
# Set port 0 and 2 simultaneously.
# ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port0_2SetCommand, unknown_usage, port2_bits, port0_bits])
# To set only port0 use
# ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port0SetCommand, port0_bits])
# To set only port2 (and leds) use
# ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port2SetCommand, port2_bits])
ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port0_2SetCommand, allDown, allDown, allDown])
#
time.sleep(1)
ledOn = np.uint8(1)
for x in range(7):
    ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port0_2SetCommand, allDown, ledOn, ledOn])
    #ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port0SetCommand, ledOn])
    #ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port2SetCommand, ledOn])
    print("ledOn: {:#010b}".format(ledOn))
    time.sleep(1)
    ledOn = np.uint8(ledOn << 1)
for x in range(9):
    ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port0_2SetCommand, allDown, ledOn, ledOn])
    #ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port0SetCommand, ledOn])
    #ptb.PsychHID('SetReport', bboxIndex, 2, 0, [port2SetCommand, ledOn])
    print("ledOn: {:#010b}".format(ledOn))
    time.sleep(1)
    ledOn = np.uint8(ledOn >> 1)

When the code is run in PsychoPy3 Experiment Runner from the macBook, all is fine. All leds light up one by one and the Input values window of AcqKnowledge show the I/O ports up and down accordingly.

When the same code is running on the Dell, All leds light up and down correctly but there is nothing on the Acqknowledge side.

I tested the code with two button boxes with the same result. When I compare the mac vs Dell result, I simply unplug the box from the USB port of one machine to plug it to the other. I also tested to plug the button box to the different (4) USB ports of the Dell. No change of the rest of the setting.

Could the Windows part of the psychtoolbox library explain that this code is not working as expected on the Dell side?