expyriment.io.ParallelPort¶
-
class
expyriment.io.
ParallelPort
(address, reverse=False)¶ A class implementing a parallel port input and output.
Notes
CAUTION: On Windows, one of the following parallel port drivers needs to be installed: ‘inpout32’ (http://www.highrez.co.uk/Downloads/InpOut32/) or ‘dlportio’ (http://real.kiev.ua/2010/11/29/dlportio-and-32-bit-windows/). On Linux, the Python package ‘PyParallel’ (http://pyserial.sourceforge.net/pyparallel.html) has to be installed.
-
__init__
(address, reverse=False)¶ Create a parallel port input and output.
Parameters: address : hex or str
The address of the port to use.
reverse : bool
Whether the port should be in reverse mode (default=False). Reverse mode enables to read from the data pins.
Notes
On Windows, common port addresses are:
LPT1 = 0x0378 or 0x03BC LPT2 = 0x0278 or 0x0378 LPT3 = 0x0278
On Linux, port addresses are in the following format:
/dev/parport0
-
address
¶ Getter for address.
-
clear
()¶ Clear the parallel port.
Dummy method required for port interfaces (see e.g. ButtonBox)
-
static
get_available_ports
()¶ Return an array of strings representing available parallel ports.
Returns: ports : list
array of strings representing the available parallel ports
Notes
This method does only work on Linux.
-
static
get_driver
()¶ Return the driver used for interacting with parallel ports.
On Windows, one of the following parallel port drivers needs to be installed: ‘input32’ (http://www.highrez.co.uk/Downloads/InpOut32/) or ‘dlportio’ (http://real.kiev.ua/2010/11/29/dlportio-and-32-bit-windows/). On Linux, the Python package ‘PyParallel’ (http://pyserial.sourceforge.net/pyparallel.html) has to be installed.
-
has_input_history
¶ Returns always False, because ParallelPort has no input history.
-
logging
¶ Getter for logging.
-
parallel
¶ Getter for parallel
-
poll
()¶ Poll the parallel port.
This will read the status pins (11, 10, 12, 13, 15), the data pins (2-9), and control pins (1, 14, 16, 17).
The received data is encoded in 17 bits, corresponding to the 17 pins:
Pin: 17 16 14 1 9 8 7 6 5 | | | | | | | | | Bit: 65536 32768 16384 8192 4096 2048 1024 512 256 Pin: 4 3 2 11 10 12 13 15 | | | | | | | | Bit: 128 64 32 16 8 4 2 1
Returns: data : int (0-65535)
The value of all input pins.
-
read_control
()¶ Read data from the control pins.
Reads control pins 1, 14, 16, 17.
The received data is encoded in 4 bits, corresponding to the 4 pins:
Pin: 17 16 14 1 | | | | Bit: 8 4 2 1
Returns: data : int (0-15)
The value of the control pins.
-
read_data
()¶ Read the data pins.
Reads the data pins (2-9) on the parallel port.
- The received data is encoded in 8 bits, corresponding to the 8 pins::
- Pin: 9 7 6 5 4 3 2 1
- | | | | | | |
Bit: 128 64 32 16 8 4 2 1
-
read_pin
(pin)¶ Determine whether an input pin is set high(True) or low(False).
Parameters: pin : int
The number of the input pin to read (2-13 and 15)
Returns: set : bool
Whether the pin is set high(True) or low(False)
-
read_status
()¶ Read data from the status pins.
Reads all status pins (10, 11, 12, 13, 15).
The received data is encoded in 5 bits, corresponding to the 5 pins:
Pin: 11 10 12 13 15 | | | | | Bit: 16 8 4 2 1
Returns: data : int (0-31)
The value of the status pins.
-
reverse
¶ Getter for reverse.
-
send
(data)¶ Send data via all output pins.
Sets the data pins (2-9) and the control pins (1, 14, 16, 17) on the parallel port.
The data is encoded in 12 bits, corresponding to the 12 pins:
Pin: 17 16 14 1 9 8 7 6 5 4 3 2 | | | | | | | | | | | | Bit: 2048 1024 512 256 128 64 32 16 8 4 2 1
Parameters: data : int (0-2047)
The data to be send via the output pins.
-
set_control
(data)¶ Send data via control pins.
Sets the control pins (1, 14, 16, 17) on the parallel port.
The data is encoded in 8 bits, corresponding to the 4 pins:
Pin: 17 16 14 1 | | | | Bit: 8 4 2 1
Parameters: data : int (0-15)
The data to be send via the control pins.
-
set_data
(data)¶ Send data via data pins.
Sets the data pins (2-9) on the parallel port.
The data is encoded in 8 bits, corresponding to the 8 pins:
Pin: 9 7 6 5 4 3 2 1 | | | | | | | | Bit: 128 64 32 16 8 4 2 1
Parameters: data : int (0-255)
The data to be send via the data pins.
-
set_logging
(onoff)¶ Set logging of this object on or off
Parameters: onoff : bool
set logging on (True) or off (False)
Notes
See also design.experiment.set_log_level fur further information about event logging.
-
set_pin
(pin, state)¶ Set a desired output pin to be high(True) or low(False).
Parameters: pin : int
The number of the output pin to set (2-9).
state : bool
Whether the pin is to be set high(True) or low(False).
-