home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
cmanual-3.0.lha
/
CManual
/
Devices
/
ParallelDevice
/
ParallelDevice.doc
< prev
next >
Wrap
Text File
|
1993-10-12
|
48KB
|
1,448 lines
8 PARALLEL DEVICE
8.1 INTRODUCTION
All Amiga models have a parallel port to which you can connect
external devices like a printer, a video digitizer or a sound
sampler. The most common external device for the parallel port
is undoubtedly a printer, although some printers are connected
to the serial device.
The parallel port can send and receive eight bits
simultaneously. This can be compared with the serial port which
only can send/receive a stream of bits. The parallel port
is because of this much faster and is therefore often used for
video digitizers or sound samplers.
The parallel device helps you to work with the printer at a
very low level, but is still easy to handle. The parallel
device can as the serial device be locked for exclusive access
or you can allow other programs to use the device
simultaneously.
It is important to note that the parallel device should only be
used when you want to handle the port directly at a low level.
This can be useful when you want to collect data from a video
digitizer, or send untranslated printer codes. However, if you
simply want to use the printer you should use the printer
device instead. The printer device will automatically take care
of all printer handling, and is using the preference settings.
See next chapter (29) "Printer Device".
8.2 PARALLEL PORT
A parallel port sends a whole byte each time as explained above,
and is therefore very fast. Data that is sent to or received
from the parallel port does not need to be translated in any
way, it is immediately usable.
The Amiga's parallel (Centronics) port is a 25-pin D-female-
type connector. (On the old A1000s the parallel port have a
male connector.) Below is an almost complete list of the pin
assignment, together with a short description. (See
illustration "Centronics".)
Pin Name Direction Description
-----------------------------------------------------
1 STROBE Out Used to coordinate the events
2 Data 0 In/Out Bit 0
3 Data 1 In/Out Bit 1
4 Data 2 In/Out Bit 2
5 Data 3 In/Out Bit 3
6 Data 4 In/Out Bit 4
7 Data 5 In/Out Bit 5
8 Data 6 In/Out Bit 6
9 Data 7 In/Out Bit 7
10 ACK In Data acknowledge
11 BUSY In/Out General Input/Output pin
12 POUT In/Out General Input/Output pin
13 SEL In/Out General Input/Output pin
14 +5V - +5 Volt
15 NC In/Out No connection pin
16 RESET Out The system resets
17 GND - Signal ground
18 GND - Signal ground
19 GND - Signal ground
20 GND - Signal ground
21 GND - Signal ground
22 GND - Signal ground
23 GND - Signal ground
24 GND - Signal ground
25 GND - Signal ground
8.3 PARALLEL DEVICE
The parallel device is very similar to the serial device. It
can either be used in exclusive mode, or several programs may
use the port simultaneously, shared access. When you want that
the parallel device to do something you simply send an already
initialized request block (struct IOExtPar), and the device
will send a message to the reply port when the request has been
done. Exactly as all other devices.
8.3.1 THE PARALLEL REQUESTBLOCK
The request block you should use with the parallel device look
like this: (defined in header file "devices/parallel.h")
struct IOExtPar
{
struct IOStdReq IOPar;
ULONG io_PExtFlags;
UBYTE io_Status;
UBYTE io_ParFlags;
struct IOPArray io_PTermArray;
};
IOPar: This is the standard request block. The IOStdReq
structure is defined in header file "exec/io.h",
and is fully documented in chapter 17 "Devices".
io_PExtFlags: This is currently not used, but will maybe be
used in the future when more parallel flags are
needed.
io_Status: The status of the parallel port and parallel
device. There exist for the moment four
status flags:
IOPTF_RWDIR If this flag is set the device
is currently writing to the
parallel device. On the other
hand, if the flag is not set
the device is collecting data
at the parallel port.
IOPTF_PARSEL Printer selected.
IOPTF_PAPEROUT The printer ran out of paper.
Inform the user!
IOPTF_PARBUSY The parallel port is currently
busy.
Use the command "PDCMD_QUERY" before you look at
these fields to make sure everything is up to
date.
io_ParFlags: This field contains all special parallel flags.
There exist only three flags for the moment, and
one of these is still not usable. Here is the
complete list:
PARF_SHARED Set this flag if you want to
share the parallel port with
other programs. Note that this
flag should only be altered
before you have opened the
parallel device, and should
NOT be changed later on.
If you want to change status
you should close the parallel
device, alter the status and
then try to open the device
again.
PARF_RAD_BOOGIE This flag is currently not
used. It is supposed to be
set when you want to send/
receive data at a very high
speed.
PARF_EOFMODE This is actually the only
flag you may alter after you
have opened the device. If
the flag is set the parallel
device will immediately
stop the transmission of data
when it finds one of the
specified end-of-file
characters.
io_PTermArray: This field contains eight characters which will
be treated as the end-of-file characters if the
PARF_EOFMODE flag is set.
8.3.2 OPEN THE PARALLEL DEVICE
As with all devices you have to open a message port through
which the parallel device can communicate with you, and
allocate a request block (a IOExtPar structure), before you
may open the device itself.
1. Open a message port: (Since it is only our task and the
device that will use the message port, we do not need
to make it "public", hence no name. Priority should as
usual be set to 0, normal priority.)
struct MsgPort *replymp;
replymp = (struct MsgPort *)
CreatePort( NULL, 0 );
if( !replymp )
clean_up( "Could not create the reply port!" );
2. Allocate a request block of type IOExtPar structure.
(The IOExtPar structure is an extended version of the
normal request block, and should therefore be allocated
with help of the CreateExtIO() function with the size
set to sizeof( struct IOExtPar ).
struct IOExtPar *parallel_req;
parallel_req = (struct IOExtPar *)
CreateExtIO( replymp, sizeof( struct IOExtPar ) );
if( !parallel_req )
clean_up( "Not enough memory!" );
Once the message port and the request block have successfully
been created, you need to decide if you want exclusive or
shared access. If you want shared access, other programs may
also