The Parallel Port

This Chapter provides the bridge between the Amiga's Parallel Port and AMOS Professional. One parallel channel may be opened at a time, so if a printer is already attached to the Parallel Port, the Parallel device may not be opened at the same time as the Printer device.

In fact, accessing the Parallel device has three main advantages over the Printer device:

There are few disadvantages, although control over sequence conversion is not possible, and screen dumps cannot be made via the Parallel Port.


instruction: open the Parallel Port for reading or writing
Parallel Open

This instruction initialises the Parallel Port for use by an AMOS Professional program. The first time that this command is used in any programming session, the "Parallel.device" driver will be loaded into memory. If it is not available, you will be prompted to insert the relevant disc automatically.


instruction: close the parallel port
Parallel Close

This command simply closes the Parallel port.


instruction: send a string of characters to the Parallel Port
Parallel Send text$

This is very similar to the PRINTER SEND command, which is explained in Chapter 10.3, except that text data is transmitted exactly as it appears in the original source string. There is no translation of code, so that any Escape codes will be interpreted directly by a printer. Please check your printer documentation for details of allowable control codes.

If data is output to a printer via the Parallel Port, each line should be terminated by a single line- feed, which is Chr$(10). This tells the printer to print a new line onto paper, starting at the current position. If the line-feed is omitted, nothing will appear to happen! Characters are transmitted using multi-tasking, so your main program will not wait for printing to be completed, but will continue immediately from the next instruction.


instruction: send data from memory to the Parallel Port
Parallel Out address,length

This instruction is similar to the PRINTER OUT command, and transmits the specified number of characters defined by the length parameter, starting from a given address.


function: read a string from the Parallel Port
text$=Parallel Input$(length[,stop])

The PARALLEL INPUTS function waits for a specific number of characters from the Parallel Port. Because this port does not have an internal buffer area, the AMOS Professional program will halt completely until all characters have been successfully received. If the requested bytes have not arrived after a reasonable amount of time, a time-out error will be generated. This may be detected using the TRAP instruction, explained in Chapter 12.2.

The PARALLEL INPUTS parameters are as follows: length holds the number of characters to be received. The square brackets can hold an optional stop character, which will end the transmission as soon as it is encountered anywhere in an input string.

If you intend to devise a communications protocol using the Parallel Port, then the first item to send should be the total number of bytes to be transmitted!


instruction: stop a parallel operation
Parallel Abort

This command is used to stop a PARALLEL SEND or PARALLEL OUT instruction from transmitting any additional information via the Parallel Port. Any characters that are currently in transit will be completely lost.


function: report the availability of the Parallel Port
value=Parallel Check

The PARALLEL CHECK function is used to return the readiness of the Parallel Port. The status is returned by either a value of zero (False) if it is not available, or -1 (True) if the port is ready for use.


function: check for an error in transmission via the Parallel Port
value=Parallel Error

To check for errors during the current transmission via the Parallel Port, use this function.

A value of zero is returned all the time that everything is proceeding normally, but any other value indicates a problem in the current transmission operation.


function: return the current status of the Parallel Port
status=Parallel Status

This function is used to give information concerning the current status of the Parallel Port. Each possibility is represented by a single bit in the status report. Here is a table of the relevant bits:

0Printer selected
1Paper out
2Printer busy
3Direction of transmission (0=read, 1=write)


function: get the base address of the Parallel Port
address=Parallel Base

This function returns the address of the internal memory area that is used to handle the Parallel Port. Experienced programmers will be able to read and change various settings, but careless use of the PARALLEL BASE function can easily result in problems.