(c)  Copyright 1989 Commodore-Amiga, Inc.   All rights reserved.
The information contained herein is subject to change without notice, and 
is provided "as is" without warranty of any kind, either expressed or implied.  
The entire risk as to the use of this information is assumed by the user.



                     Amiga Multiple Serial Ports

                          by Bryce Nesbitt


The current version of the Amiga has only one serial port.  Since many 
devices can interface with a serial port, having more serial ports is an 
obvious improvement.  

New system software has been developed for the Amiga which will allow
plug in cards with extra serial ports to be used.   A typical setup on a 
four port machine might be:

	Port 1 - Connected to a MIDI keyboard
	Port 2 - connected to a modem
	Port 3 - connected to a printer
	Port 4 - connected to a home-control device 

Extra serial ports will also allow applications such as a multiple line 
bulletin board system (BBS) with several modems connected to a single 
computer.  Such a BBS could support simultaneous users.
			


Multiple serial ports are implemented in a way which is compatible with
existing software.

    o  Old applications that ask for the serial port will be given 
       the "default" port.  Using the Preferences tool, the user will
       be able to set the default to any valid port.

    o  New programs will provide a way for the user to select the serial
       port to use.   If the user selects the number "0" or the word 
       "default", the program will connect to the default port which is set 
       in Preferences.  The built-in port is unit 1.  Extra serial ports
       are numbered from two upward.  

    o  From BASIC and the CLI, ports may be directly accessed in the
       same manner as works today:

		    SER:    = the default port 
		    SER1:   = the built-in port
		    SER2:   = the second port
		    SER3:   = the third port
		    SER4:   = the fourth port

New Hardware

In addition to the new software support, Commodore is developing a plug in
card with multiple serial ports.  All Commodore multiple serial port cards 
will have a simple installation procedure:

    o  Insert the serial card into a slot.
    o  Boot up with the normal Workbench disk or hard drive.
    o  Insert the disk that comes with each serial card.
    o  Double click on the "Install Drivers" icon.
    o  To remove a driver, double click on the "Remove Drivers" icon.

Any number of cards may be installed.  Advanced users may install the 
driver software manually instead of using the installation icon.

Commodore's design for matching ports on cards with unit numbers is simple.
Port number 1 is the serial port built into each Amiga.  Higher port numbers 
indicate extra serial ports the user has added with a plug in card.
The bottom plug on a card is given the lowest unit number.


Applications Software

If you are writing serial port applications for the Amiga, you can now
add support for multiple serial port cards.  This is easy to do and
will give your program extra power.

On an Amiga with one serial port the code needed to open the serial port 
looks like this:

    error = OpenDevice("serial.device", 0, myIORequest, 0);
    /*
     *	    BYTE=OpenDevice(char *,ULONG,struct IORequest *,ULONG);
     *
     *	    "serial.device" = name of the device
     *	    0		    = unit number (unused)
     *	    myIORequest     = a blank extended trackdisk IORequest
     *	    0		    = flags (unused)
     */

To work with multiple serial ports, just two very simple additions are
required:

    error = OpenDevice(myName, myUnit, myIORequest, 0);
    /*
     *	    BYTE=OpenDevice(char *,ULONG,struct IORequest *,ULONG);
     *
     *	    myName	    = name of the device ("serial.device" default)
     *	    myUnit	    = which unit to try and open (0 default)
     *	    myIORequest     = a blank extended trackdisk IORequest
     *	    0		    = flags (unused)
     */


Notice that the device name and unit number have changed.  Under the old 
system the unit number was always set to 0.  Now the unit number is used to
identify which of the serial ports should be used.  The unit assignments are:


    Unit 0  =	default port, settable from Preferences
    Unit 1  =	the built-in serial port
    Unit 2  =	the first extended unit
    Unit n  =   last extended unit

To add system support for a multiple port serial card, some of three system 
files on the Workbench disk had to be changed:

	devs:serial.device	;exec support
	l:port-handler		;AmigaDOS support
	Preferences		;default port selector buttons




User Interface

If you decide to provide a TOOLTYPES interface for setting the default,
please use the following labels:

		UNIT=0
		DEVICE=serial.device

See the Workbench chapter in the ROM Kernel Manual for information on
processing tooltypes.


Future Design Issues

Plans for the V1.4 serial.device include several sensible extensions to the
current command set.  For example, the best way to read under the current 
serial.device is:

    o  Send a CMD_QUERY to see how many bytes are in the buffer.

    o  If there are any bytes, get them ALL with a CMD_READ.

    o  Else post a CMD_READ for exactly one byte.  When it returns,
       loop back to step #1.


With the old serial.device, this was the only way to get acceptable 
performance at high baud rates.  With the new serial.device, one will be 
able to set a bit to request all available bytes from the serial port 
(up to the size of the user buffer).  The request will be held by the 
device until at least one byte is ready.

The OpenDevice() call does not support a version number check at present.  
In most cases there is no need to check the version number since the new 
serial device is backward compatible.  However, if you do need to find the 
version number of the serial device, you should first open the device and 
then look at the LIB_VERSION word in the device base.  Versions 36 and higher 
support multiple ports.  Versions 35 and lower ignore the unit number field.

The Amiga's built-in serial port can generate any baud rate in the range
108 to 1,000,000 baud.  However, off-the-shelf serial chips usually only
support the standard rates such as:

             110      600       9600     
             150     1200      19200
             300     2400      38400

Also, standard serial chips usually do not support the MIDI baud rate (31250).
Since most multiple serial port cards will be using standard serial chips,
the extra ports will not support all the different baud rates that the
built-in serial port does.  There is no way for a serial.device client to
find out the capabilities of a specific serial unit at present.

The ability to add more serial ports combined with the Amiga's multi-tasking
operating system makes powerful new applications possible.  In particular,
when a low-cost multi-user solution is appropriate, the Amiga can now do the 
job easily. 


