User's Manual

PMAC User Manual
Writing a Host Communications Program 247
WRITING A HOST COMMUNICATIONS PROGRAM
Communicating From a Host Computer
If communicating from a host computer to PMAC in the actual application, write a host communications
program. The PMAC Executive program that was used in development is not intended as a host program
for an actual application; it was designed simply as a development tool.
At a fundamental level, the host communications routines that are written send and receive strings of
ASCII-coded characters to and from PMAC. Create some low-level routines to send and receive
individual characters and text lines; these will be called repeatedly, specifying the different text strings to
read or write.
The basic concepts of communications are covered in the Talking to PMAC section of this manual.
Communications to the PMAC will take place over one of three PMAC communications ports (each
version of PMAC has two of these ports). Every PMAC has a serial port that can connect to a COM port
on a host computer. The PMAC PC, -Lite, and -STD have a host port for bus communications to the
host. This port works the same on all three versions. The PMAC VME has mailbox registers for
communications over the VME bus to the host computer. Instructions for using each of these ports are
discussed in the following sections.
This section covers the communications of text commands and text responses. With the Option 2 dual-
ported RAM, completely binary methods of communications are possible, with the proper programs
written on both the host computer and PMAC.
Note:
Delta Tau provides several software libraries to make the development of host
communications programs easier. Most notably, the Acc-9P PCOMM library
handles all of the low-level issues described in this section. Much of the
discussion in this section is not required if you are using one of these
communications libraries.
Polled vs. Interrupt-Based Communications
Regardless of the port that is used, there are two fundamental methods for doing the handshaking on the
passing of characters. In the first method, the host can poll the PMAC interface, repeatedly if necessary,
to see if it is ready to send or receive the next character or line. In the second method, the PMAC
interface will interrupt the host when it is ready to send or receive the next character or line.
Polled communications handshaking is easier to write, but it is less efficient, because of the time, the
program can spend waiting for PMAC to be ready. Interrupt-based communications is more efficient,
because the host computer can be performing other tasks while PMAC is not ready, but it is much more
difficult to write. Initialize, vector, and unmask the interrupts, write the interrupt service routines, decide
which routines disable which other interrupts, and you must restore the interrupts when completed.
Serial Port Communications
When communicating to the PMAC through the PMAC serial port, typically one of the COM ports in the
host computer is used. In an IBM-PC or compatible, usually these are the built-in COM1 and COM2 RS-
232 ports, but they can be on expansion cards as well. Most COM ports, even on non-IBM-compatible
computers, use the same ICs, so usually they have the same registers on the host side.
Setting up the Interface
Every time the system is started up, the serial port of the host computer must be initialized to interface
properly with the settings of PMAC. This is done with some simple byte-write commands to the I/O
space of the computer.