| Reference | Downloads | Github

Sending triggers with USB to LTP to BrainVision Recorder

Dear Psychopy users,

What I want to achieve: I am trying to send triggers (Oddball paradigm) via USB to LTP using Python or Psychopy and display them on BrainVision Recorder.

What works: the Windows Manager recognize in COM4 a Virtual Serial Port

What doesn’t work: when I run the python code to get access to the port:

import serial
import time
import threading
Connected = True
PulseWidth = 0.01
def ReadTHread(port):
while Connected:
if port.InWaiting ()> o:
print (“0x%X”%ord(

#Open the Windows device manager search for the TriggerBox VirtualSerialPort
#in Ports/COM & LPT) and enter the port number in the constructor

port = serial.Serial(“COM4”)
#Start the read thread

thread = threading.Thread(targe=ReadThread, args=(port,))
#Set the port to an initial state


while True:
#Set Bit 0 Pin 1 of the Output (to Amp) connector

#Reset Bit0, Pin 2 of the Output (to Amp) connector

I get this error
"could not open port ‘COM4’: PermissionError(13, ‘a device connected to the system is not in function.’, None, 31)

Basically, python does not recognize the COM4 port.

Thank you in advance to everyone will provide constructive feedback,


To me looks kind of weird as python just access to the systems ports.

If it’s not erroring out when you use serial.Serial() to open the port, that suggests that the port is functioning but the device is not. You could try changing the port used like this:

or try running those same commands via Python IDLE ( to see whether it’s something Psychopy is doing, if not it may be a hardware issue with your serial device… Does it work through other software?