User's Manual

PMAC User Manual
Writing a Host Communications Program 271
Communications Checksum
PMAC is capable of performing checksum calculations on communications lines sent between it and the
host computer. This mode is enabled when I4=1, and disabled when I4=0. It will operate for serial, PC
bus, STD bus, or VME bus communications.
PMAC computes the checksum of the individual bytes (characters) in a communications line sent in
either direction between it and the host. It simply adds together the ASCII value of each character into an
accumulating sum.
At the appropriate time, it sends the checksum – at least the low byte – to the host. It is the host’s
responsibility to make the comparison between the checksum that PMAC has computed and the one that
it has computed itself. PMAC does not do this comparison. The host should never send a checksum byte
to PMAC.
The way the checksum works is subtly different between host-to- PMAC communications and PMAC-to-
host communications. Each case is explained in detail below:
Host-to-PMAC Checksum
After a full command line, including the terminating Carriage-Return (<CR>) byte has been sent to
PMAC, PMAC will parse the line to figure out what action it has to take. As it parses the line, it
computes an accumulating checksum of all the character bytes in the command line. The checksum does
not include any control characters, either those that may have been interjected into the middle of the line,
or the trailing <CR> character.
PMAC will return the checksum to the host immediately after it sends the acknowledging handshake
character, if any. (For I3.=0, there is no acknowledging character, for I3=1, PMAC uses <LF>, for I3=2
or 3, PMAC uses <ACK>.) If the command required a data response from PMAC, the acknowledging
character and the checksum are returned to the host after the data response to the command (and after the
checksum for the data response). If PMAC detects an error in the command line through its normal
syntax checking, it will respond with the <BELL> character (for all values of I3), but it will not follow
this with a checksum byte — the line has been thrown away.
PMAC-to-Host Checksum
PMAC will compute the checksum of any communications line it sends to the host. This checksum
includes control characters sent with the line, including leading line- feed <LF> characters, if any, and the
final <CR> character. The checksum is sent immediately following the <CR> character. For a multiple-
line transmission, one checksum is sent for each line of the transmission, immediately following the
<CR> for that line.
If the PMAC-to-Host transmission was prompted by a host command, at the end of the full transmission
(which could be multiple lines), PMAC will send the acknowledging handshake character, if any,
followed by the checksum of the host command. If the transmission was prompted by a SEND or CMD
statement in a PMAC program, there is no acknowledging handshake character, or checksum of the
command (there is a checksum of the response).
Checksum Format
In general, the checksum of a line can be more than one byte long — as the byte values add up, the
checksum rolls over into a second byte. When using the serial port or the VME bus port, PMAC sends
only the low byte. The value in this byte is that of the full checksum modulo 256. When using the PCbus
or VMEbus, PMAC sends the low byte to the normal communications register (base address + 7), but
simultaneously sends the high byte to the adjacent register (base address + 6). There is the choice of
picking up just the low byte, or both bytes.