Send triggers from psychopy to EEG recorder using MMBT-S

I would like to use MMBT-S to trigger the EEG recording machine from psychopy.
The current status of the device is as follows

  • Windows: 11 (We have confirmed that the same error occurs in windows 10.)
  • Psychopy v2023.2.3 (standalone)
  • EEG recorder: PolymatePro

The following is what I am currently doing.

Send the trigger from Psychopy via serial port using MMBT-S. Start Tachyon and confirm that the trigger is sent to EEG recorder by clicking the “Send” button.

I tried to send the trigger by entering the following code from the “code” part of Psychopy.

Begin Experment

import serial
Ser = serial.Serial()
Ser.port = 'COM6'
Ser.open()

Each Frame

Trigger = 5
Ser.write(bytes(chr(Trigger)), 'UTF-8')`

End Experiment

Ser.close()

The following error code was generated.

Generating PsychoPy script...

############# Running: C:\Users\user\Desktop\untitled2_lastrun.py ##############

pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)

Traceback (most recent call last):

Hello from the pygame community. https://www.pygame.org/contribute.html

File "C:\Users\user\Desktop\untitled2_lastrun.py", line 39, in <module>

Ser.open()

File "C:\Program Files\PsychoPy\lib\site-packages\serial\serialwin32.py", line 64, in open

raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))

serial.serialutil.SerialException: could not open port 'COM6': PermissionError(13, 'Scc', None, 5)

################# Experiment ended with exit code 1 [pid:7668] #################

I am wondering if the code is incorrect, and since I am able to send the trigger in Tachyon, I am thinking that it is most likely a configuration failure within Psychopy.

I would like to know what the solution is.

Thank you in advance.