Table Of Contents

Previous topic

psychopy.monitors - for those that don’t like Monitor Center

Next topic

psychopy.preferences - getting and setting preferences

This Page

Quick links

psychopy.parallel - functions for interacting with the parallel port

This module provides read / write access to the parallel port for Linux or Windows.

The Parallel class described below will attempt to load whichever parallel port driver is first found on your system and should suffice in most instances. If you need to use a specific driver then, instead of using ParallelPort shown below you can use one of the following as drop-in replacements, forcing the use of a specific driver:

  • psychopy.parallel.PParallelInpOut32
  • psychopy.parallel.PParallelDLPortIO
  • psychopy.parallel.PParallelLinux

Either way, each instance of the class can provide access to a different parallel port.

There is also a legacy API which consists of the routines which are directly in this module. That API assumes you only ever want to use a single parallel port at once.

psychopy.parallel.ParallelPort

alias of PParallelLinux

Legacy functions

We would strongly recommend you use the class above instead: these are provided for backwards compatibility only.

parallel.setPortAddress(address=888)

Set the memory address or device node for your parallel port of your parallel port, to be used in subsequent commands

Common port addresses:

LPT1 = 0x0378 or 0x03BC
LPT2 = 0x0278 or 0x0378
LPT3 = 0x0278
or for Linux::
/dev/parport0

This routine will attempt to find a usable driver depending on your platform

parallel.setData(data)

Set the data to be presented on the parallel port (one ubyte). Alternatively you can set the value of each pin (data pins are pins 2-9 inclusive) using setPin()

Examples:

parallel.setData(0)  # sets all pins low
parallel.setData(255)  # sets all pins high
parallel.setData(2)  # sets just pin 3 high (remember that pin2=bit0)
parallel.setData(3)  # sets just pins 2 and 3 high

You can also convert base 2 to int v easily in python:

parallel.setData(int("00000011", 2))  # pins 2 and 3 high
parallel.setData(int("00000101", 2))  # pins 2 and 4 high
parallel.setPin(pinNumber, state)

Set a desired pin to be high (1) or low (0).

Only pins 2-9 (incl) are normally used for data output:

parallel.setPin(3, 1)  # sets pin 3 high
parallel.setPin(3, 0)  # sets pin 3 low
parallel.readPin(pinNumber)

Determine whether a desired (input) pin is high(1) or low(0).

Pins 2-13 and 15 are currently read here