[open] using dlportio to communicate with LPT
Hello all!
I am using OpenSesame 0.27.3 on a Windows 7/64 machine. I've downloaded and installed dlportio by the instructions. I am testing it with a slightly modified code from the example:
varvar=1
while varvar < 10:
try:
from ctypes import windll
global io
io = windll.dlportio # requires dlportio.dll !!!
except:
print 'The parallel port couldnt be opened'
global io
port = '0x378'
try:
io.DlPortWritePortUchar(port, varvar)
print io.DlPortReadPortUchar(port)
except:
print 'Failed to send trigger!'
self.sleep(500)
varvar += 1
I expect to see the numbers from 1 to 9, but instead I see the number 148 which stays constant for the whole loop. The port address is correct -- if I use DirectRT, it will work just fine. I suspect that DlPortWritePortUchar is not working correctly. Can anyone suggest where to look for the problem?
Thanks,
Ilya.
Comments
Hi Ilya,
You have specified the port as a
strobject:I'm kind of surprised that this doesn't result in an error message! What you want to do is define the port as a hexadecimal
int, like so:Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
It is working now. Thanks!
Ilya.
Something wierd is going on. If I read the value of the ports with DlPortReadPortUchar or with the port_reader plugin, I see that the port is changed to the desired value. But PyCorder (a software to record EEG data, can recieve triggers) shows no sign of triggers. But when I use IOTest utility (part of DirectRT), then the triggers are recieved. The port number is the same in both cases. Sometimes it says that "dlportio.sys device driver not loaded", but the information from the port_reader is still correct. And no sign of the trigger in the PyCorder...
Are you sure that the port number is correct?
0x378is hexadecimal notation (indicated by the preceding0x), corresponding to the decimal number888. Perhaps the correct port is simply378?Check out SigmundAI.eu for our OpenSesame AI assistant!