Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] using dlportio to communicate with LPT

edited September 2013 in OpenSesame

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

  • edited 2:19PM

    Hi Ilya,

    You have specified the port as a str object:

    port = '0x378' # Quotes make this a string
    

    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:

    port = 0x378 # No quotes!
    

    Cheers!
    Sebastiaan

  • Hi Sebastiaan,

    It is working now. Thanks!

    Ilya.

  • edited September 2013

    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...

  • edited 2:19PM

    Are you sure that the port number is correct? 0x378 is hexadecimal notation (indicated by the preceding 0x), corresponding to the decimal number 888. Perhaps the correct port is simply 378?

Sign In or Register to comment.