-- File: RS232CFace.mesa
-- LastEdited: January 20, 1981  3:56 PM   By: Danielson  
-- This DEFINITIONS module attempts to capture the lowest level interface to an RS-232-C controller which is still independent of the particular controller implementation, as well as the processor on which the controller resides.

DIRECTORY
  Environment USING [Byte],
  RS232CEnvironment USING [
    AutoRecognitionOutcome, CharLength, CompletionHandle, Correspondent,
    LineSpeed, LineType, Parity, PhysicalRecord, PhysicalRecordHandle, StopBits,
    SyncChar, SyncCount];

RS232CFace: DEFINITIONS =
  BEGIN
  -- Interface Procedures
  On: PROCEDURE [lineNumber: CARDINAL];
  Off: PROCEDURE [lineNumber: CARDINAL];
  GetLineCount: PROCEDURE RETURNS [lineCount: CARDINAL];
  ResetLine: PROCEDURE [lineNumber: CARDINAL, paramHandle: ParamHandle]
    RETURNS [outcome: ParameterOutcome];
  SetParameters: PROCEDURE [lineNumber: CARDINAL, paramHandle: ParamHandle]
    RETURNS [outcome: ParameterOutcome];
  AutoRecognitionWait: PROCEDURE [lineNumber: CARDINAL]
    RETURNS [outcome: RS232CEnvironment.AutoRecognitionOutcome];
  Put: PROCEDURE [
    lineNumber: CARDINAL, rec: RS232CEnvironment.PhysicalRecordHandle]
    RETURNS [RS232CEnvironment.CompletionHandle];
  Get: PROCEDURE [
    lineNumber: CARDINAL, rec: RS232CEnvironment.PhysicalRecordHandle]
    RETURNS [RS232CEnvironment.CompletionHandle];
  TransferWait: PROCEDURE [
    lineNumber: CARDINAL, event: RS232CEnvironment.CompletionHandle]
    RETURNS [byteCount: CARDINAL, status: TransferStatus];
  SendBreak: PROCEDURE [lineNumber: CARDINAL];
  AbortInput: PROCEDURE [lineNumber: CARDINAL];
  AbortOutput: PROCEDURE [lineNumber: CARDINAL];
  GetStatus: PROCEDURE [lineNumber: CARDINAL] RETURNS [stat: DeviceStatus];
  StatusWait: PROCEDURE [lineNumber: CARDINAL, stat: DeviceStatus]
    RETURNS [newstat: DeviceStatus];
  AbortStatus: PROCEDURE [lineNumber: CARDINAL];
  TransmitNow: PROCEDURE [
    lineNumber: CARDINAL, event: RS232CEnvironment.CompletionHandle]
    RETURNS [byteCount: CARDINAL, status: TransferStatus];
  -- TYPEs
  ParamHandle: TYPE = LONG POINTER TO ParameterRecord;
  ParameterRecord: TYPE = RECORD [
    lineType: RS232CEnvironment.LineType,
    correspondent: RS232CEnvironment.Correspondent,
    lineSpeed: RS232CEnvironment.LineSpeed,
    stopBits: RS232CEnvironment.StopBits,
    parity: RS232CEnvironment.Parity,
    charLength: RS232CEnvironment.CharLength,
    syncCount: RS232CEnvironment.SyncCount,
    syncChar: RS232CEnvironment.SyncChar,
    frameTimeout: CARDINAL,
    requestToSend, dataTerminalReady, resetRingHeard, resetBreakDetected,
      resetDataLost: BOOLEAN];
  ParameterOutcome: TYPE = {success, unimplemented};
  TransferStatus: TYPE = {
    success, dataLost -- (caused by input buffer overrun --, deviceError,
    frameTimeout, checksumError, parityError, asynchFramingError
    -- (i.e. stop bit(s) missing) --, invalidChar, invalidFrame, aborted,
    disaster};
  DeviceStatus: TYPE = RECORD [
    dataLost: BOOLEAN,
    --latched: caused by arrival of data with no input buffer allocated
    breakDetected: BOOLEAN, -- latched
    clearToSend, dataSetReady, carrierDetect: BOOLEAN,
    ringHeard: BOOLEAN, -- latched
    ringIndicator: BOOLEAN,
    deviceError: BOOLEAN]; -- set if fatal device problem occurs

  END. -- RS232CFace
LOG
Time: May 8, 1979  8:45 AM	By: Victor Schwartz	Action: Created file
Time: May 30, 1980  2:39 PM	By: Victor Schwartz	Action: Remove pre-Amargosa log entries, and add lineNumber parameter to On and Off, to allow resource allocation on a line-by-line basis.
Time: August 4, 1980  12:58 PM	By: Victor Schwartz	Action: Remove PROCEDUREs SuspendInput, SuspendOutput, RestartInput, RestartOutput.  Change ParamHandle to a LONG pointer.
Time: January 20, 1981  12:37 PM	By: Danielson	Action: Added deviceError bit to DeviceStatus.