ppc 1.0 -- A low level parallel port control program.

Copyright (c) 1997 by Ryan Kirkpatrick (rkirkpat@nag.cs.colorado.edu). 
  All rights reserved.

* This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

* This program is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.

* You should have received a copy of the GNU General Public License
  along with this program; see the file COPYING.  If not, write to the
  Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.


The purpose of this program is to give the user low level control (pin
by pin, bit by bit) of the parallel port with a simple to use ncurses
interface. It is also a very complete example of how to program the
parallel port under Linux.

I wrote this program to make interfacing custom built digital circuits
with computers easier to debug. The parallel port uses TTL level
signals (5volts), and is the perfect port to use to interface a custom
built digital circuit with a computer. When one builds such a beast,
one usually has a good idea of what kind of simple protocol is going
to be used for communication between the computer and the digital
circuit. But as I discovered in trying this myself, things rarely work
out as planed. Before one can get a custom written program on the
computer to talk with the digital circuit, it is often helpful to have
some way to step through the communications by hand.

This is where ppc comes in. It allows you to control all of the
different bits or pins of the parallel port at a pin by pin level. As
well, it allows you to view the current state of the pins. With this
program you can simulate by hand communicating with your digital
circuit, and hunt down the bugs in the digital circuit, and get used
to the quirks present in parallel port communication. Then once
everything is working with ppc, you can go ahead and write a custom
application to handle the communication itself. And since you have the
source code of the ppc program, you have a complete example of how to
carry out port interfacing to follow in writing your own applications.

To compile this program, edit the makefile to suit your needs. Make
sure to leave the optimizer flag in the CFLAGS variable. Due to the
use of port commands, optimization is required for the program to
compile correctly. Then just type 'make', and in a few moments, you
will have a program called ppc.

There is no install program, but all you need to install by hand is
ppc to the location of your choice. It must be run as root, so you can
either only run it when logged in as root, use sudo, or use setuid. I
have no idea what security risks it poses when setuid, so be careful.

To use the program, just run it with no command line parameters to
open port lp0, or give another parallel port on the command line to
select another (lp1, lp2, lp3). To control lp2, the command line would
be 'ppc lp2'. The interface is very simple and straight forward. You
can read status and data bits, write data bits in binary, decimal, or
Binary Coded Decimal, and write control bits. There is also an option
to bring up some help messages.

In the test.programs directory are a few programs I used to test
parallel port programming as I built this program. Take a look at
them, as well at the code for ppc (most of the port programming is in
ppc.c) for examples of how to program the parallel port. Also, make
sure to look at the IO-Port-Programming-HOWTO, as it holds lots of
good background information and programming excerpts for all ports,
serial, parallel, etc... The HOWTO can be found at
sunsite.unc.edu/LDP, and is included with most major Linux
distributions.

I have tested the ppc program on Linux/Intel and Linux/Alpha. It works
well, and correctly on both platforms. There are a few warning
messages when compiling on Alpha, but nothing to be worried about. I
have not tested it on any other platform or UNIX, so your mileage may
vary. Also, if you try to run ppc on a non-existent parallel port, all
of the status, control, and data bits will be one. That is one way to
tell if you parallel port is working or not. As for what type your
parallel port is, EPP, ECP, Bi-Directional, Standard, and what ever
new standard they have come out with recently, I have found Linux, and
therefore this program, are rather indifferent. I have gotten
bi-directional communications to work correctly through a nine year
old I/O card originally out of a 286, and through current day EPP and
ECP ports. So your port should react well to this program and any
interfacing with custom digital circuits, no matter what kind of port
you have. Though of course, YMMV.

As for information about the digital circuits I keep talking about
interfacing with, they are really the simpler half of the
equation. They are just basicly digital circuits that get some of
their input from the pins of a parallel port. I personally have a
female 25 pin wire wrap connector, and have wire wrapped the pins
coming out of this connector, and those wires are connected to a
prototype board. I also have the ground pin of the parallel cable
connected to the ground line of the proto-board. The input from the
parallel cable is then fed into different logic gates on the
proto-board to carry out different operations. Also I would suggest
finding an old, cheap I/O port ISA card to put in your computer and
use to connect to digital circuits for testing at least. That way, the
chances of doing serious damage to your computer (blowing an on the
motherboard parallel port could be nasty) are greatly reduced.

I hope to some time in the future release some custom program and
wiring diagrams to demonstrate a complete computer - digital circuit
interface. In the meantime the best place to get information about
this is go your local public library and look up books on connecting
electronic or digital circuits to computers. They will almost
assuredly have the interface programs written for DOS, but with the
IO-Port-Programming-HOWTO, and this program you can just pay attention
to the hardware end of the book. Also, the IO-Port-Programming-HOWTO
contains pinouts for many of the standard ports found on a PC. Anyway,
good luck and have fun!

If you have any questions or comments about this program, feel free to
email me at rkirkpat@nag.cs.colorado.edu.

----------------------------------------------------------------------------
|   "For to me to live is Christ, and to die is gain."                     |
|                                            --- Philippians 1:21 (KJV)    |
----------------------------------------------------------------------------
|  Ryan Kirkpatrick  |  Boulder, Colorado  | rkirkpat@nag.cs.colorado.edu  |
----------------------------------------------------------------------------
|               http://www-grad.cs.colorado.edu/~rkirkpat/                |
----------------------------------------------------------------------------

