Jump to content

From Wikibooks, open books for an open world

This document was originally hosted at the ETHZ. It remains in the WayBack archive under the ETH license.

Serial and parallel port support

Summary

Oberon supports parallel or serial ports for controlling peripheral devices such as mice (serial), printers (parallel or serial), modems (serial), routers, bridges, firewalls.

Hint: Communication devices such as the Zyxel Prestige 100 ISDN Router and the Zyxel ZyWall firewall can easily be configured via their serial control port with the V24.Panel , the GUI of a simple terminal-emulation application. The bloated configuration software delivered with the devices can quietly be ignored.

Parallel ports

All of the three possible parallel ports are supported. The ports are set up as follows:

            Addr. 
    LPT1    378H 
    LPT2    278H 
    LPT3    3BCH

and operate in unidirectional mode only. Hence, no IRQ is assigned or used. A bi-directional protocol is not implemented.

A machine is usually equiped with a single parallel port set up as shown above. If an add-on I/O card with additional ports is installed, the address and the IRQ assigned to a port are usually jumpered on the card. The jumpers setting must comply with what is shown above.

For additional information consult Wikipedia.

How to control a parallel port by program

Use the procedures in module Centronics.Mod in your own program. They support output only. The Centronics module imports SYSTEM and uses the PORTIN / PORTOUT procedures. The latter are for use with Native Oberon of course. Note that a module importing SYSTEM is not portable. The PlugIn version of Oberon for Windows uses the Native Oberon compiler and consequently, PORTIN and PORTOUT are also useable. Under Windows NT and Win 2000, executing one of these procedures will however lead to a "privileged instruction" TRAP.

PORTIN and PORTOUT can also be implemented with in-line assembler code.

MODULE PortIO; 
     IMPORT SYSTEM;

     PROCEDURE - inch 
          066H, 08BH, 055H, 00CH, 0ECH, 08BH, 05DH, 008H, 088H, 003H;

     PROCEDURE InCh(VAR ch: CHAR; port: INTEGER); 
     BEGIN 
          inch 
     END InCh;

     PROCEDURE - outch 
          066H, 08BH, 055H, 00CH, 08AH, 045H, 008H, 0EEH;

     PROCEDURE OutCh(ch: CHAR; port: INTEGER); 
     BEGIN 
          outch 
     END OutCh;

END PortIO.

A similar implementation is found in Oberon V4, but the formal parameters in InCh and OutCh are permuted because the Oberon V4 compiler uses the C language convention for sequencing the parameters.

Serial ports

All of the four possible serial RS-232 ports are supported. A machine is usually equiped with two serial ports, either built in on the motherboard or on an add-on I/O card. Built in COM ports are usually configured with the BIOS set up program, but may be configured with jumpers in older computers. COM ports on add-on cards are normally configured with jumpers on the card. By default, in Oberon, the base address and the IRQs of the ports are set up as follows:

            Addr.  IRQ 
    COM1    3F8H    4 
    COM2    2F8H    3 
    COM3    3E8H    4 
    COM4    2E8H    3

The base addresses above for COM1 and COM2 are standard. There are several alternate addresses that can be used for COM3 and COM4. If these are hard-wired into a board or card they will normally be paired as shown. If they are individually selectable, it is desirable to use them in the pairs shown below:

    COM3 - 3E8H 338H 3F8H 2E8H 220H 
    COM4 - 2E8H 238H 2F8H 2E0H 228H

The support, together with the BIOS set up program of the machine and the jumpers, allow to arrange the COM ports among the serial interfaces as desired and to associate them with the best suited IRQ lines. The following commands are available for setting up the ports.

ConfigV24.SetIRQs { [ xxxH | 000H ] IRQx } ~

Assign four pairs of base address + IRQ to the serial ports. No duplicate address is allowed. Uninstalled or disabled ports are assigned the address 000H. The IRQs may be chosen among the free (i.e. non-conflicting) IRQs of the machine. Duplicate IRQs may be assigned, provided the ports are not used simultaneously. It is common practice to see COM3 using IRQ 4 and COM4 using IRQ 3, as is done by default. The final settings are displayed in the System log in the form of a new ConfigV24.SetIRQs command ready for editing and executing.
This command is best placed in Oberon.Text ahead of a possible ConfigInput.Mouse or ConfigInput.WatchMouse command, specially if a serial mouse is attached which should be recognized immediately when Oberon is started.

ConfigV24.GetIRQs

Display the serial port settings in the System log. The current settings are displayed in the System log in the form of a new ConfigV24.SetIRQs command ready for editing and executing.

For additional information consult Wikipedia.

For the programmer

V24.Mod is the device driver of an asynchronous RS-232 interface and in OSI terminology, it handles protocols on level 2a - the media access control. Client modules must implement the protocols of level 2b - the logical link control. The receiving part is timing critical: the receive buffer may overflow and data may get lost as a consequence of an overrun condition. The buffer has a fixed length of 4'096 bytes.

Serial connect

In addition to using an external modem connected to a serial port, it is also possible to establish direct communication to another computer by connecting the serial ports through a crossed serial cable (also known as a null-modem cable) and using a generic communications program. V24.Panel was designed for this purpose. The most likely use you will have for this technique is trapping debug output from a problematic machine to another faultless machine for analyzing the debug information and diagnosing the problem. This technique is described in Low-level tracing.

[Top]

11 Jul 2002 - Copyright © 2002 ETH Zürich. All rights reserved.
E-Mail: oberon at lists.inf.ethz.ch
Homepage: http://www.ethoberon.ethz.ch/