Copyright (c) Hyperion Entertainment and contributors.

AmigaOS Manual: Serial and parallel ports

From AmigaOS Documentation Wiki
Revision as of 17:22, 26 August 2017 by Janne Peräaho (talk | contribs)
Jump to navigation Jump to search

A serial port can be used for communicating with all kinds of serial devices: modems, bar code scanners, UPSes, sound digitizers, other computers, etc. Many non-serial devices have a serial port too for configuring the device and/or updating its firmware.

A parallel port is faster than a serial port and it has no baud rate or flow control settings like the serial port. Typical parallel port devices are printers, scanners, ZIP drives, and EPROM programmers.

Serial port communication

Depending on your Amiga hardware you have one or more serial ports. The first serial port device is SER:, second is SER1:, third is SER2:, and so on. The first serial port can be configured through the Serial Preferences editor and the other ports by editing their mount configuration files stored in the 'DEVS:DOSDrivers' directory.

The Serial Preferences editor allows you to change all serial port properties: unit, baud rate, handshaking, parity, data bits, and stop bits.

Sending data through the serial port

A serial port can be used for receiving and sending data. The procedure of using serial port for sending data is as follows:

  1. Open the serial port device for writing.
  2. Write data to be send to the device.
  3. Close the device.

When opening the serial port device, you can request custom serial port settings for your communication session. The default settings will be restored when you close the device.

The following settings are available:

Keyword Template Description
BAUD BAUD/N Baud rate.
UNIT UNIT/K/N Device unit to be used.
FLOW=HANDSHAKE FLOW=HANDSHAKE/K Flow control setting: SOFT=SOFTWARE, HARD=HARDWARE=7WIRE, or NONE.
CONTROL CONTROL/F Data bits, parity, and stop bits setting. A three letter sequence is expected. The first letter is the number of data bits, the second letter tells which parity should be used, and the third letter is the number of stop bits. The valid setting for each letter is: 1st letter: 7 or 8, 2nd letter: N, O, E, M, or S (N = No parity, O = Odd parity, E = Even parity, M = Mark parity, and S = Space parity), 3rd letter: 1 or 2.

If you supply several parameters when opening the device, the parameter must be separated with slashes (/). For example:

OPEN( 'serial', 'SER:UNIT=0/BAUD=19200/FLOW=NONE', 'W' )

Program 19: WriteToSerial.rexx

Receiving data through the serial port

When you want to read data from the serial port, do as follows:

  1. Open the serial port device for reading.
  2. Read data from the device.
  3. Close the device.

Different serial port settings can be requested when opening the device for reading. For the available settings, see the settings table above.

Program 20: ReadFromSerial.rexx

Parallel port communication