-- File: RS232C.Mesa
-- LastEdited: January 22, 1981  2:14 PM   By: Danielson  

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

RS232C: DEFINITIONS =
  BEGIN
  -- Interface Definitions
  Create: PROCEDURE [lineNumber: CARDINAL, lineType: LineType]
    RETURNS [ChannelHandle];
  Get: PROCEDURE [channel: ChannelHandle, rec: PhysicalRecordHandle]
    RETURNS [CompletionHandle];
  Put: PROCEDURE [channel: ChannelHandle, rec: PhysicalRecordHandle]
    RETURNS [CompletionHandle];
  TransferWait: PROCEDURE [channel: ChannelHandle, event: CompletionHandle]
    RETURNS [byteCount: CARDINAL, status: TransferStatus];
  Delete: PROCEDURE [channel: ChannelHandle];
  Suspend: PROCEDURE [channel: ChannelHandle, class: OperationClass];
  Restart: PROCEDURE [channel: ChannelHandle, class: OperationClass];
  GetStatus: PROCEDURE [channel: ChannelHandle] RETURNS [stat: DeviceStatus];
  StatusWait: PROCEDURE [channel: ChannelHandle, stat: DeviceStatus]
    RETURNS [newstat: DeviceStatus];
  --  RS232C-specific procedures  --
  AutoRecognitionWait: PROCEDURE [channel: ChannelHandle]
    RETURNS [outcome: AutoRecognitionOutcome];
  GetLineCount: PROCEDURE RETURNS [numberOfLines: CARDINAL];
  TransmitNow: PROCEDURE [channel: ChannelHandle, event: CompletionHandle]
    RETURNS [byteCount: CARDINAL, status: TransferStatus];
  SendBreak: PROCEDURE [channel: ChannelHandle];
  SetParameter: PROCEDURE [channel: ChannelHandle, parameter: Parameter];
  SetLineType: PROCEDURE [channel: ChannelHandle, lineType: LineType];
  -- SIGNALs and ERRORs
  ChannelAlreadyExists, ChannelSuspended, InvalidLineNumber, InvalidParameter,
    NoRS232CHardware, SendBreakIllegal, UnimplementedFeature: ERROR;
  -- Interface type definitions
  LineType: TYPE = RS232CEnvironment.LineType;
  ChannelHandle: TYPE [2];
  AutoRecognitionOutcome: TYPE = RS232CEnvironment.AutoRecognitionOutcome;
  CompletionHandle: TYPE = RS232CEnvironment.CompletionHandle;
  OperationClass: TYPE = {input, output, other, all};
  PhysicalRecordHandle: TYPE = RS232CEnvironment.PhysicalRecordHandle;
  PhysicalRecord: TYPE = RS232CEnvironment.PhysicalRecord;
  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 [
    statusAborted: BOOLEAN,
    dataLost: BOOLEAN,
    --latched: caused by arrival of data with no input buffer allocated
    breakDetected: BOOLEAN, --latched
    clearToSend, dataSetReady, carrierDetect: BOOLEAN,
    -- correspond to signals in EIA RS-232-C Spec
    ringHeard: BOOLEAN, --latched version of EIA RS-232-C Ring Indicator
    ringIndicator: BOOLEAN,
    deviceError: BOOLEAN];
  Parameter: TYPE = RECORD [
    SELECT type: ParameterType FROM
      charLength => [charLength: CharLength],
      correspondent => [correspondent: Correspondent],
      dataTerminalReady => [dataTerminalReady: BOOLEAN],
      frameTimeout => [frameTimeout: CARDINAL],
      latchBitClear => [latchBitClearMask: LatchBitClearMask],
      lineSpeed => [lineSpeed: LineSpeed],
      parity => [parity: Parity],
      requestToSend => [requestToSend: BOOLEAN],
      stopBits => [stopBits: StopBits],
      syncChar => [syncChar: SyncChar],
      syncCount => [syncCount: SyncCount],
      ENDCASE];
  ParameterType: TYPE = {
    charLength, correspondent, dataTerminalReady, frameTimeout, latchBitClear,
    lineSpeed, parity, requestToSend, stopBits, syncChar, syncCount};
  CharLength: TYPE = RS232CEnvironment.CharLength;
  Correspondent: TYPE = RS232CEnvironment.Correspondent;
  LatchBitClearMask: TYPE = DeviceStatus;
  LineSpeed: TYPE = RS232CEnvironment.LineSpeed;
  Parity: TYPE = RS232CEnvironment.Parity;
  StopBits: TYPE = RS232CEnvironment.StopBits;
  SyncCount: TYPE = RS232CEnvironment.SyncCount;
  SyncChar: TYPE = RS232CEnvironment.SyncChar;
  END.  -- RS232C
LOG
Time: 1978	By: Victor Schwartz	Action: Created file
Time: October 1979	By: Victor Schwartz	Action: Pre-Teak LOG entries removed
Time: June 20, 1980  2:51 PM	By: Victor Schwartz	Action: Pre-Amargosa LOG entries removed.
Time: June 20, 1980  2:51 PM	By: Victor Schwartz	Action: Remove Abort and ChannelDoesNotExist.  Change semantics of Suspend/Restart.
Time: January 20, 1981  12:43 PM 	By: Danielson	Action: Add procedure GetLineCount to allow client to obtain count of total number of RS232C lines.  Added deviceError to deviceStatus to allow reporting of terminal device errors.