The state of this project that it is totally and completely
dead! This parallel port server only worked for a little
while and one day when I upgrade my operating system version
it stopped working entirely. I abandoned it back in 1998.
It is written in a computer language that is no longer
supported. Trust me, this code is a total dead end waste
of time.
These days, trying to do real time programming on a Linux
box requires real time operating system extensions. The
best support for a parallel port that I know of would be
the EMC2 HAL infrastructure at
LinuxCNC.Org. If you plow through the extensive
documentation (good documentation is not that common
in the Linux space), you will discover that they have
implemented a truly extensive infrastructure for their
HAL (Hardware Abstraction Layer).
Parallel Port Server
This parallel port server provides a TCP/IP interface
to a single Linux parallel port via the Linux
/dev/port
interface. Since the
/dev/port
interface provides access to
all I/O devices, /dev/port
can
only be accessed by programs being run as root.
Thus, this parallel port server must be run from root.
Other programs can access the parallel port server via
TCP/IP without having to be logged in as root. While
a run amok program might be able to mess up the hardware
that is plugged into the parallel port, the parallel
port server will ensure that no extraneous accesses
occur to other I/O devices available via the
/dev/port
interface.
The parallel port server program is run as:
parallel_server
[-p
tcp_port]
[port]
where
-
[
-p
tcp_port] -
specifies the TCP port that the server will
listen for connections on. If not specified,
the default is 4243.
-
[port]
-
is one of 278, 378, or 3bc. If port
is not specified, 378 is the default.
After connecting to the parallel port server via
a bi-directional TCP/IP stream, all subsequent
commands are line based. The client sends a line
of text to the server, which is `executed' and the
server responds with a line of results. All commands
are are done using printing ASCII characters.
All lines are terminiated with a carriage return
line feed sequence. The carriage return is ignored,
and the line feed actually starts execution.
Upon initial connection, the server sends a message of
the form:
H Parallel_Server
major minor
where
-
major
-
is the major version number (currently 1.)
-
minor
-
is the minor version number (currently 0.)
The register mode command provides the ability
to directly manipulate the three registers that
make up the parallel port interface:
-
D (Data)
-
The 8-bit data register is bi-directional.
-
C (Control)
-
The 8-bit control register is basically
write-only and provides a way to control
the remaining output only wires of a
parallel port.
-
S (Status)
-
The 8-bit status register is basically
read-only and provides a way to read
the input only wires of a parallel port.
The register mode command has the following form:
R
register_commands
Where register_commands is a sequence of
one or more of the following characters:
-
0-9, a-f (Send Hex)
-
Send a hex digit.
-
C (Write C Register)
-
Write the preceeding hexadecimal number to
the C (control) register.
-
D (Set C and D Register Defaults)
-
Remember the current C and D register values
and reset to these values if when the
connection is closed.
-
E (Echo)
-
Take the preceeding hexadecimal number and
append it to the result string as "##"
where "##" is the hexadecimal value of the
number. (This command is useful for
debugging.)
-
I (Input from S and Mask)
-
Read the S register and mask it with the
internal mask register. If resultant
value is non-zero append 1 to the result
string; otherwise append 0.
-
L (sLeep)
-
Sleep for the preceeding hexadecimal number
of milliseconds.
-
M (Set Mask Register)
-
Set the internal mask register to the
preceeding hexadeicmal register.
-
R (Read D Register)
-
Read data from D (data) register and append
"##" to the result string where "##" is the
hexadecimal value read.
-
S (Read S Register)
-
Read the S (status) register and append "##"
to the result string, where "##" is the
hexadecimal value read.
-
V (Write and Verify D Register)
-
Write preceeding hexadecimal number to D
(data) register and then read the data back
and verify that it matches the preceeding
hexadecimal number. If it matchs append "+"
to the result string. If it does not match,
append "-##" where "##" is the hexadecimal
value read.
-
W (Write D Register)
-
Write preceeding hexadecimal number to D
(data) register.
The serial programming mode command is used to program
PIC microcontrollers from
Microchip. It has been optimized to make it
easy to read, write, and program these chips using
fairly simple parallel programmmers.
The serial programming mode command has the following
form:
S
serial_commands
where the serial commands are as follows:
-
0-9, a-f
-
Send a hexadecimal digit
-
W (Write)
-
Write the preceeding hexadecimal number
into the PIC, reread it and verify that
it is correct, and increment the address.
If the verify is correct, append "." to
the result string; otherwise append "!#"
to the result stream, where # is the value
that was read back.
-
R (Read)
-
Read the next word from the PIC program
memory and append it to the result stream
as "#### " where "####" is a hexadecimal
number between 1 and 4 digits long.
The address is incremented.
-
C (Command)
-
Execute the preceeding hexadecimal number
as a command.
-
P (Put)
-
Put (send) the preceeding hexadecimal number
to the PIC as 12 or 14 bits of data.
-
G (Get)
-
Get 12 or 14 bits of data from the PIC and
append it to the result stream as "#### "
where "####" is a hexadecimal number between
1 and 4 digits long.
-
I (Index Configuration)
-
Set configuration index register to the
preceeding hexadecimal number.
-
S (Set Configuration)
-
Set the current configuration register pointed
to by the configuration index register to the
preceeding hexadecimal number.
-
L (sLeep)
-
Use the preceeding hexadeicmal number to
sleep for that many milliseconds.
-
D (power Down)
-
Power down the programmer.
-
U (power Up)
-
Power up the programmer to prepare for
programming.
There are a bunch of configuration registers that
do the following:
-
0 (Clock Configure)
-
Specifies the offset and inversion for
the clock bit. The lower 3 bits specifiy
the shift. The next bit specifies the
D (=0) or C (=1) registers. and the next
bit specifies inversion (=1) or not (=0).
-
1 (Data Out Configure)
-
Specifies the offset and inversion for
the data bit.
-
2 (Enable Configure)
-
Specifies the offset and inversion for
the data out enable bit.
-
3 (Power Configure)
-
Specifies the offset and inversion for
the power (+5V) enable bit.
-
4 (Program Configure)
-
Specifies the offset and inversion for
the programming power (+13V) enable bit.
-
5 (Input Configure)
-
Specifies the offset and inversion for
the data input bit.
-
6 (Word Width)
-
Specifies the word width which is either
12 or 14 bits.
-
7 (Increment Command)
-
Specifies the 6-bit command used to increment.
-
8 (Read Command)
-
Specifies the 6-bit command used to read
a program word.
-
9 (Load Command)
-
Specifies the 6-bit command used to load
a program word.
-
a (Program Command)
-
Specifies the 6-bit command used to start
programming.
-
b (Sleep Amount)
-
Specifies the delay for sleeping after
programming a word (in milliseconds.)
-
c (Program Stop Command)
-
Specifies the command to use to stop
programming. 0 is specified if there
is no stop command.
-
d (Maximum Program Attempts)
-
Specifies the maximum number of attempts
required to program a location.
-
e (Over Program Attempts)
-
Specifies the number times to program a
location after the first time it is read
properly.
-
f (Command Pause)
-
Specifies the number of milliseconds of
pause after every command.
{Print mode Command goes here}
The quit command has the following form:
Q
and causes the parallel port server to immediately
close its connection.
There is a list of
available files.
One of these days I need to provide a modes for
supporting a printer.
Copyright (c) 2000-2001 by
amWayne C. Gramlich All rights reserved.