SerialException: could not open port 'COM3' WindowsError(5, 'Access is denied')
I've been trying to send a trigger through a CEDRUS StimTracker Duo. The information on here about using serial ports seemed fairly straight forward, but implementing the scripts has not worked for me despite many modifications to the script. My current setup looks as follows, This inline script is at the very beginning of the experiment:
import serial ser = serial.Serial() ser.baudrate = 115200 ser.port = 'COM3' ser.open() exp.ser = serial.Serial('COM3', baudrate=115200, bytesize=serial.EIGHTBITS) exp.ser.write(chr(1)) exp.cleanup_functions.append(exp.ser.close)
The following inline script is put in during the practice_sequence and is meant to send the trigger when the stimulus is presented:
Running this gives me the error in the title. I have also thought that perhaps I need to implement the sample python code provided by Cedrus, but this gives me an even more complicated error. running the following script:
import pyxid # get a list of all attached XID devices devices = pyxid.get_xid_devices() dev = devices # get the first device to use if dev.is_response_device(): dev.reset_base_timer() dev.reset_rt_timer() while True: dev.poll_for_response() if dev.response_queue_size() > 0: response = dev.get_next_response() # do something with the response
The line that seems to be giving me trouble is dev = devices as I get the error message IndexError: list index out of range. If anyone has any idea as to how I can approach these errors I'd appreciate it as google hasn't given me a great solution yet.