Console

Overview

Module Console provides a simple IO interface to the Astrobe console. It directly uses the corresponding serial interface, which is buffered for input and output.

Texts.Writer Console.C

Console exports a Texts.Writer Console.C to the console that can be used by any module to output texts.

The body of Console:

NEW(dev); RS232dev.Init(dev, RS232dev.Dev0);
Texts.OpenWriter(C, dev, RS232.PutChar)

Usage example in module System:

MODULE System;

IMPORT Texts, Console;

VAR W: Texts.Writer

BEGIN
  W := Console.C
END System.

The Main API Procedures

PROCEDURE Available*(VAR ch: CHAR): BOOLEAN;

Check if an input character is available, and return that character in ch. This procedure uses a special mode of the underlying serial device, which leaves the character in the buffer upon reading, so that subsequently complete command lines from the console can be read, see ReadLine.

PROCEDURE ReadLine*(VAR line: ARRAY OF CHAR; VAR n: INTEGER);

Read one line of text, with the line delimited by an LF character, as sent by the Astrobe console. Return the number of characters read in n.

PROCEDURE WriteLine*(line: ARRAY OF CHAR);

Write one line of text, plus an LF character.

PROCEDURE AwaitTxBufferEmpty*;

Busy-waits until the output buffer is empty. Only used in error conditions to delay the restart of the system until an error message has been completely sent out to the console.