Howdy, Stranger!

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

Supported by

[solved] Parallel port trigger stopping

edited April 2016 in OpenSesame

Hi!

I'm trying to use OpenSesame with parallel_port_trigger plug-in to trigger events in an EEG-recording software (EMOTIV's TestBench), both run on the same machine under ubuntu.

I followed the instructions (from http://osdoc.cogsci.nl/3.0/devices/triggers/) but however my experiment is stopping right after the start with following text:

text begin =====================================

Stopped

The experiment did not finish normally for the following reason:

  • Could not access the Parallel Port

Details

  • item-stack: experiment[prepare].new_parallel_port_trigger[prepare]
  • exception message: [Errno 2] No such file or directory: '/dev/parport0'
  • time: Wed Mar 30 17:16:33 2016
  • exception type: OSError

Traceback (also in debug window)

<br />File "/home/nkobelev/pythonTest/OpenSesame-release-3.0.7/plugins/parallel_port_trigger/parallel_port_trigger.py", line 103, in prepare
    self.experiment.pptrigger = parallel.Parallel()

File "/home/nkobelev/pythonTest/OpenSesame-release-3.0.7/plugins/parallel_port_trigger/parallelppdev.py", line 187, in __init__
    self._fd = os.open(self.device, os.O_RDWR)

OSError: [Errno 2] No such file or directory: '/dev/parport0'

Any ideas what am I doing wrong?

Comments

  • edited March 2016

    HI Kobi,

    You need to specify the device that corresponds to the parallel port. You have specified /dev/parport0 (the default on non-Windows systems), but this device apparently doesn't exist on your system. So you will need to find out what the parallel port is called. What operating system are you using?

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited March 2016

    Hi Sebastiaan,

    thanks for Your fast response!

    My operating system is Ubuntu 12.04 . I didn't specify the port as it was said in the instructions that the value for port in the parallel_port_trigger is ignored under Linux. If I do specify the port the error-text remains the same.

    UPDATE: TestBench (my EEG scanning software) listens to serial port triggers not parallel port if I understand it correctly (I can choose only from ttyS0 - ttyS31).
    Is there another way to produce serial port triggers in OpenSesame?

    UPDATE2:
    I tried to execute an inline_script item with following code:

    import serial
    exp.serial_port = serial.Serial('/dev/ttyS1',baudrate=19200, bytesize=serial.EIGHTBITS,stopbits=1)
    print(exp.serial_port.name)
    exp.serial_port.write(chr(1))
    exp.serial_port.close
    

    I can see /dev/ttyS0 in debug output window,
    but I can't see any trigger events in the EEG-software.

    any other ttySX return following error-text:

    Stopped
    
    The experiment did not finish normally for the following reason:
    
    Error while executing inline script
    
    Details
    
    - item-stack: `experiment[run].new_inline_script[run]`
    - exception type: `SerialException`
    - exception message: `Could not configure port: (5, 'Input/output error')`
    - item: `new_inline_script`
    - time: `Thu Mar 31 15:10:34 2016`
    - phase: `run`
    
    Traceback (also in debug window)
    
    .traceback
      File "/home/nkobelev/pythonTest/OpenSesame-release-3.0.7/libopensesame/inline_script.py", line 102, in run
        self.experiment.python_workspace._exec(self.crun)
      File "/home/nkobelev/pythonTest/OpenSesame-release-3.0.7/libopensesame/python_workspace.py", line 159, in _exec
        exec(bytecode, self._globals)
      File "", line 5, in 
      File "/usr/local/lib/python2.7/site-packages/serial/serialutil.py", line 177, in __init__
        self.open()
      File "/usr/local/lib/python2.7/site-packages/serial/serialposix.py", line 300, in open
        self._reconfigure_port(force_update=True)
      File "/usr/local/lib/python2.7/site-packages/serial/serialposix.py", line 332, in _reconfigure_port
        raise SerialException("Could not configure port: {}".format(msg))
    SerialException: Could not configure port: (5, 'Input/output error')
    
    
    

    Cheers,
    Niklas

  • edited April 2016

    I think I've found a solution. Now I can send trigger events to serial port from OpenSesame and see them in TestBench. For the case someone else has same difficulties with TestBench and OpenSesame on Ubuntu:

    Step1: open terminal and create a pair of virtual ports with socat

    sudo socat PTY,link=/dev/ttyS10,b19200 PTY,link=/dev/ttyS11,b19200
    

    Step2: open another terminal and grant a read/write permissions for the new ports:

    sudo chmod o+rw /dev/ttyS10
    sudo chmod o+rw /dev/ttyS11
    

    Step3: open OpenSesame and create an inline_script item.
    in that item write:

    import serial
    s = serial.Serial('/dev/ttyS10',baudrate=19200,
          bytesize=serial.EIGHTBITS,stopbits=1)
    s.write(chr(1))
    s.close()
    

    Step4: open TestBench, go to marker->configure serial port and select the same port as You created with socat (ttyS11 in my case) and set bit per seconds to the same rate as you specified in socat (19200 in my case).

    That's It! Now as You execute the inline_script in OpenSesame You should see an event with a value=1 in TestBench.

    I hope it works for You too!

    Cheers,
    Niklas

Sign In or Register to comment.