Using the parallel port for output with Linux

by Drew Perttula
Here's a tiny program for Linux that turns the parallel port's data lines on and off. parcon.c

You say:

> parcon 1h 2h 3l

old = 00000000
new = 00000011

to set the first and second lines high and the third low.

Here's an executable for Intel Linux systems. The program needs to be run as root. Either make yourself root before running it, or (as root)

chown root parcon
chmod u+s parcon
This turns on the setuid bit for the program, so it gets root privileges even when other users run it.

Here's a simple interface to parcon, written in Tcl/tk. You can click on the numbers or type them on the keyboard to toggle the states of the output lines. tkparcon

Want to use the parallel port from python? You might like to check out some SWIG modules I used on a project. Check out the whole project with:

cvs -z3 -d co light9
The file light9/light8/parport.i is a swig wrapper for parport.c which I used on a recent project. It's messy and specific to the particular hardware I was controlling, but it contains at least what you'd need. There's a makefile too. (As well as entire functioning theater lighting control system :)

Home page