OS: Win11
PsychoPy version: 2022.2.5
Standard Standalone? yes
What are you trying to achieve?:
In my Lab we are trying to send key presses as stimuli via a serial Port connection to our EEG-Software (BrainVision Recorder). I know that there have been other Posts with this exact same problem, yet when trying to implement those solutions the Trials crashed after starting.
What did you try to make it work?:
I already tried to implement the solutions from these two posts:
Post 1
Post 2
Unfortunately I couldn’t get those solutions to work…
This is the current configuration:
Note: key_resp > Data is set to “all keys”
Begin experiment:
import serial
import time
Only used at begin and end of experiment…
PulseWidth = 0.01
Open the Windows device manager, search for the “TriggerBox VirtualSerial Port (COM3)”
in “Ports /COM & LPT)” and enter the COM port number in the constructor.
port = serial.Serial(“COM3”)
Set trigger to zero
port.write([0x00])
time.sleep(PulseWidth)
Begin routine:
pulse_started = False
pulse_ended = False
CountedKeys = 0
Each frame:
What specifically went wrong when you tried that?:
Alerts:
Alert 4210:JavaScript Syntax Error in ‘Begin JS Experiment’ tab. See ‘Line 1: Unexpected token’ in the ‘Begin JS Experiment’ tab.
Stdout:
Traceback (most recent call last):
File “C:\Users-----\Documents\psychopy-------\trust-distrust - Backup_lastrun.py”, line 505, in
if stimulus.status == STARTED and not pulse_started:# where “mything” refers to a visual thing you are trying to sync the trigger to (so you could have one of these for different component’s in the same routine
NameError: name ‘stimulus’ is not defined
################# Experiment ended with exit code 1 [pid:4860] #################
I have no idea about Python and just tried to implement the existing solutions…
Any help would be kindly appreciated