[open] Sending triggers for EEG through serial port
I have been trying to set up my OpenSesame experiment to run from my laptop, with an EEG system. I want to send triggers to the EEG machine via a (USB converted) serial port, and had previously been using an inline script for sending through a parallel port (copied from the forum). So far, I had some help to make the changes for sending via the serial port, but am still having some issues. Firstly, I do not know how to open and close the serial port appropriately. I have included some inline script at the beginning of the experiment, as follows:
ser = serial.Serial('COM1', 19200)
from ctypes import windll
io = windll.dlportio # requires dlportio.dll !!!
print 'The parallel port couldnt be opened'
Then, for sending triggers, I have included this inline script just after stimulus presentation:
trigger = self.get("triggerstart")
print 'Failed to send trigger!'
I am presenting a series of images in short succession (hopefully for 80ms each), and have therefore used "sleep" here. The triggers are defined in the loop, in the variable "triggerstart". Right now, the inline script does seem to be sending the triggers, but a problem is that it seems to be sending ASCII codes, instead of the integers that I have defined in "triggerstart". There also seems to be some additional trigger codes coming on the EEG recording that I cannot see where, and if (unintentionally), I defined them, or where they are coming from.
Is there something I am doing wrong in the inline script?
How I should open and close the port properly?
How I can change the trigger codes to be the integers I defined, instead of the ASCII codes that I am currently getting?