DataMuseum.dk

Presents historical artifacts from the history of:

CR80 Wang WCS documentation floppies

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about CR80 Wang WCS documentation floppies

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦4c801b7a2⟧ Wang Wps File

    Length: 51090 (0xc792)
    Types: Wang Wps File
    Notes: PC/PDS/001 - ISSUE 2      
    Names: »6213A «

Derivation

└─⟦05b6108d7⟧ Bits:30006238 8" Wang WCS floppy, CR 0624A
    └─ ⟦this⟧ »6213A « 

WangText



A…08…A…09…A…0a…A…00…A…06…@…0c…@…0f…@
@…07…?…0b…?…0c…?…0e…?
?…06…>…0d…> =…0b…=…86…1
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    …02… 
     
     
     
     
     …02…
     
    …02… 
     
     
     
    

…02…PC/PDS/001

…02…851001…02……02…
 
PROTOCOL
 CONVERTER
PACKAGE
 DESIGN
 SPECIFICATION…02…ISSUE
 1.2…02…  
 PC








4.2.6    C̲C̲I̲S̲ ̲L̲o̲w̲ ̲L̲e̲v̲e̲l̲ ̲P̲r̲o̲t̲o̲c̲o̲l̲s̲ ̲(̲C̲L̲P̲)̲



4.2.6.1  F̲u̲n̲c̲t̲i̲o̲n̲a̲l̲ ̲S̲p̲e̲c̲i̲f̲i̲c̲a̲t̲i̲o̲n̲

         The CLP package is responsible for data communication
         between the CR80 and the GRTS software in the DN355/DN6678
         front-end processor on the CCIS side.

         CLP is implemented in the CR80 LTU and the CLP SW therefore
         has to be down-line loaded from the CR80 memory during
         initialization of the LTU.

         CLP communicates with the GRTS using the following
         three types of subsegments:

         - S̲e̲r̲v̲i̲c̲e̲ ̲M̲e̲s̲s̲a̲g̲e̲s̲  for opening and closing the line

         - C̲o̲n̲t̲r̲o̲l̲ ̲M̲e̲s̲s̲a̲g̲e̲s̲  for delivery of passwords and other
         
           control data.

         - I̲n̲f̲o̲r̲m̲a̲t̲i̲o̲n̲ ̲M̲e̲s̲s̲a̲g̲e̲s̲  used during the transmission
           of data segments 

         In this context the term "messages" means the various
         subsegment types sent between the CLP and GRTS including
         header and trailer characters.

         Due to the half-duplex nature of the communication
         link the sets of messages sent from the two sides are
         not symmetrical. Therefore, a description of the possible
         messages sent from either side of the link is given
         in Figure 4.2.6.1-1 and 4.2.6.1-2.
















































                    FIGURE 4.2.6.1-1 
                 SERVICE/CONTROL MESSAGES















































                     FIGURE 4.2.6.1-2
                   INFORMATION MESSAGES


         In the above figures the nomenclature of References
         6 and 18 is used:

         "Remote"    =           CR80 LTU
         "DN355"     =           DN355 or DN6678
         SYN         =           sync. character, #16
         SOH         =           start of header, #01
         FC          =           varying function code
         SC          =           sequence code alternating at
                                  each side between #41 and
                                 #42 for each message sent except
                                 for IRD2 for which it is constant.
         AC          =           address code, #40
         OC          =           operation code. OC.(2:3)
                                 (bits 2,1,0)is a three bit
                                 field holding the operation
                                 code. OC. (5:3) (bits 5,4,3)
                                 is a three bit field with the
                                 binary value 000 for acknowledge
                                 or 001 for negative acknowledge.
         IC          =           identification code #40
         AUX         =           auxiliary field, #47 (only
                                 used in "Select", SRD3).
         STX         =           start of text
         MC          =           media code…06…1         …02…   …02…   …02…
                                   …02…                        
                                                   
         TEXT FIELD
             a)  from 1 up to 324 bytes of data sent to GRTS
                 using the IRD3 and/or IRD4 messages.
                 SUPERACK's, SUPERNAK's, and BUST messages will
                 be sent as IRD4 messages.

             b)  1 to 324 bytes of data received from GRTS in
                 IDR3 and/or IDR4 messages

             c)  $*$LOGID$PSWRD/DNM
                 where ID and PSWRD are two character strings
                 with lengths from 1 to 12 characters each ̲supplied
                 from CR80 together with the OPEN LINK command

             d)  LINE DISCONN. XXX and LINE TERMIN. XXX stands
                 for:
                 LINE DISCONNECTED XXX and
                 LINE TERMINATED XXX.
                 'XXX' is a character string of two or three
                 characters.




             e)  (*) DINDAC and (*) RSTRT are two optional character
                 strings. One of them is received during an
                 OPEN LINK sequence in an IDR2 subsegment. One
                 of them is sent from CLP in a TIRD2 message
                 when simulating DINDAC during tests.
                 (*)should be read as the hexadecimal characters:
                 #3C, #2A, and #3E. Cf. Reference 3, p.3-A-4-2.
                 

         RS          =   record separator

         ETX         =   end of text, no more subsegments in
                         segment

         ETB         =   end of text, more subsegments will
                     
                           follow to complete the segment

         BCC         =   block check, i.e. ex-or of characters
                         following SOH and including ETX. Denoted
                         "**" in the figures.

         AL          =   alternating independently at both sides
                         between #41 and #42.

         C0          =   constant and equal to the previous
                         value used. The first "WAIT" segment
                         has a SC field equal to the previous
                         message sent.

         DA          =   alternating differently compared to
                         "AL" in the usual SRD, CRD, and IRD
                         messages. Messages with SC equal to
                         "DA" are used in simulation of GRTS
                         with values of #41 and #42.

         All numbers in Figures 4.2.6.1-1 and 4.2.6.1-2 are
         hexadecimal except for the "SC" column as explained
         above. Unused fields are marked "-- " and "---".  


         CLP recognizes incoming messages from GRTS and assigns
         a constant value taken from the constants declared
         as "grts ̲messages" in section 4.2.6.3

         F̲u̲r̲t̲h̲e̲r̲m̲o̲r̲e̲, each incoming message is checked for the
         occurence of one of the following events:

         -   OC.(5:3) = 001 (binary) and the SC field is changed
             from SC of the previous message and characters
             are present in the text field. This is an implied
             ACK.

         -   OC.(5:3) = 001 (binary) but the message is not
             an implied ACK.

         -   the incoming message contains an error. Check of
             messages is described in subsequent sections. Checks
             are performed according to References 6 and 18.

         CLP is able to send the messages denoted SRD, CRD and
         IRD as shown in Figures 4.2.6.1-1 and 4.2.6.1-2. 

         Any of these messages may furthermore be retransmitted
         any required number of times. 

         Retransmission is performed with the SC value equal
         to the one of the previous message sent.

         For ordinary messages and frames to be retransmitted
         the ACK/NAK field, OC.(5:3) is set to either 000 or
         001 (binary).

         Functionally, the CLP is divided into an OPEN LINK
         sequence and a DATA TRANSMISSION sequence.

         A state/event description of each of these sequences
         is given in section 4.2.6.1.1 and 4.2.6.1.2, respectively.





4.2.6.1.1    O̲P̲E̲N̲ ̲L̲I̲N̲K̲ ̲S̲e̲q̲u̲e̲n̲c̲e̲


        a)   S̲t̲a̲t̲e̲s̲ ̲i̲n̲ ̲O̲P̲E̲N̲ ̲L̲I̲N̲K̲ ̲(̲S̲O̲L̲)̲

         SOL0    Initial state entered after power-up/masterclear
                 and bootloading.

         SOL1    Before sending RFD to GRTS.

         SOL2    Before sending SELECT to GRTS

         SOL3    Before sending ID and PSWRD in LOGON message

         SOL4    Before sending $*$DACDINDAC in LOGON message

         SOL5    Before sending ACK on DINDAC or RSTRT message

         SOL6    Closing state

         SDT0    Starting state of Data Transmission sequence



        b)   E̲v̲e̲n̲t̲ ̲c̲l̲a̲s̲s̲e̲s̲ ̲i̲n̲ ̲O̲P̲E̲N̲ ̲L̲I̲N̲K̲ ̲(̲E̲O̲L̲)̲

         EOL0    start ̲protocol, open ̲link ̲timeout, naks ̲exceeded
                 or logon ̲error is true. Cf. section 4.2.6.3
                 concerning the use of these variables.

         EOL1    CR80 OPEN LINK command

         EOL2    CR80 CLOSE LINK command

         EOL3    READY FOR DISCONNECT, SDR1

         EOL4    TRANSMIT DATA, IDR1

         EOL5    DINDAC or RSTRT, IDR2

         EOL6    Bits 5,4,3, OC.(5:3) is NAK. No text field
                 is present and/or the SC field is constant.

         EOL7    Bits 5,4,3, OC.(5:3) is NAK and SC is changed
                 and text is present.

         EOL8    Message is in error. Message checking will
                 be performed during analysis of input according
                 to Reference 18.

         EOL9    Disconnect SDR2

         EOL10   Line Down Control message, CDR1

         EOL11   Other events 


        c)   A̲c̲t̲i̲o̲n̲s̲ ̲p̲e̲r̲f̲o̲r̲m̲e̲d̲ ̲d̲u̲r̲i̲n̲g̲ ̲O̲P̲E̲N̲ ̲L̲I̲N̲K̲ ̲(̲A̲O̲L̲)̲

         AOL0    Initialize variables, reset and start timer
                 if power up then initializes the message counters.

         AOL1    Read and store the userid/password and baudrate
                 from CR80. Set baudrate according to value
                 given in OPEN LINK command. Send READY FOR
                 DISCONNECT, SRD1.

         AOL2    Not Used.

         AOL3    Update open ̲link ̲timeout. Send SELECT, SRD3.

         AOL4    Update open ̲link ̲timeout.
                 Send LOGON with userid and password previously
                 read from CR80, CRD1.

         AOL5    Update open ̲link ̲timeout
                 Send LOGON with $*$DACDINDAC, CRD1.

         AOL6    Reset OPEN LINK TIMEOUT.
                 Answer pending OPEN LINK request from CR80.
                 If line ̲down ̲message ̲code NE OK return this
                 value as result to the CR80.
                 Set flag for ACK ̲TO ̲BE ̲SENT:= TRUE

         AOL7    Update open ̲link ̲timeout. ACK/NAK field of
                 previous message sent is set to NAK and the
                 message is retransmitted without altering the
                 SC field.



         AOL8    Update naks ̲exceeded and open ̲link ̲timeout.
                 Retransmit previous frame with same SC and
                 ACK in the ACK/NAK field of OC.

         AOL9    Answer pending CR80 OPEN ̲LINK command with
                 reason code for closing. Send DISCONNECT, SRD2.

         AOL10   Answer CR80 CLOSE ̲LINK command. Cancel pending
                 OPEN ̲LINK command. Send DISCONNECT, SRD2.

         AOL11   Notify CR80 of error condition in response
                 to an OPEN ̲link command. 

         AOL12   Answer pending CR80 OPEN ̲LINK command with
                 error code.
                 Send READY FOR DISCONNECT, SRD1.

         AOL13   REJECT CR80 COMMAND with REASON CODE = Current
                 State

         AOL14   Update open ̲link ̲timeout

         States entered and events occurring during a typical
         OPEN LINK sequence are emphasized using fat lines in
         Figure 4.2.6.1.1-1.

         LTU system SW, which is used both in the X25 CSLP and
         CLP is described in Reference 15.















































                    FIGURE 4.2.6.1.1-1
          STATE/EVENT TABLE: OPEN LINK SEQUENCE


4.2.6.1.2    D̲A̲T̲A̲ ̲T̲R̲A̲N̲S̲M̲I̲S̲S̲I̲O̲N̲ ̲S̲e̲q̲u̲e̲n̲c̲e̲


        a)   S̲t̲a̲t̲e̲s̲ ̲i̲n̲ ̲D̲A̲T̲A̲ ̲T̲R̲A̲N̲S̲M̲I̲S̲S̲I̲O̲N̲ ̲(̲S̲D̲T̲)̲

         SDT0    Before for Request Input

         SDT1    Request Input Received 

         SDT2    Subsegment receiving and accumulation

         SDT3    Segment Received

         SDT4    Subsegments to be Sent

         SDT5    Segment Sent (but not fully acknowledged)

         SDT6    Transmit Data Received

         SDT7    Ready for Closing Link



        b)   E̲v̲e̲n̲t̲ ̲c̲l̲a̲s̲s̲e̲s̲ ̲i̲n̲ ̲D̲A̲T̲A̲ ̲T̲R̲A̲N̲S̲M̲I̲S̲S̲I̲O̲N̲ ̲(̲E̲D̲T̲)̲

         EDT0    Unrecoverable Error indicated by the variable
                 data ̲transmission ̲error

         EDT1    CR80 Close Link command

         EDT2    CR80 Request Input command

         EDT3    CR80 Request Output - data will have to be
                 sent as more than one subsegment (ETB), i.e.
                 data segment of more than 324 bytes.

         EDT4    CR80 Request Output - data can be sent as one
                 subsegment (ETX), e.g. BUST's or SUPER ACK's.

         EDT5    CR80 Cancel Input Request command

         EDT6    CR80 Cancel Output Request command

         EDT7    CR80 Show Statistics command

         EDT8    CR80 Reset Statistics command

         EDT9    READY FOR DISCONNECT, SDR1

         EDT10   DISCONNECT, SDR2

         EDT11   TRANSMIT DATA, IDR1 and subsegment ̲type:= 
                   
                 etb ̲subsegment           
                 CLP has received IDR1 and remaining data to
                 be sent exceed 324 bytes.

         EDT12   TRANSMIT DATA, IDR2 and subsegment ̲type:= 
                   
                 etx ̲subsegment. CLP has received IDR1 and data
                 to be sent can be held in one subsegment.

         EDT13   CLP has received a data subsegment which is
                 a mid- or first subsegment of a segment, IDR3.


         EDT14   CLP has received a data subsegment which is
                 the last subsegment or an entire segment, IDR4.

         EDT15   Bits 5,4,3, OC.(5:3) is 001 (binary) corresponding
                 to NAK.

         EDT16   Bits 5,4,3, OC.(5:3) is 001 (binary) and SC
                 is changed and text is present.

         EDT17   Message is in error. Message checking will
                 be performed during analysis of input according
                 to Reference 18.

         EDT18   Timeout. CLP has not received a response on
                 last message sent.

         EDT19   Illegal Request output.

         EDT20   Other Events.


        c)   A̲c̲t̲i̲o̲n̲s̲ ̲p̲e̲r̲f̲o̲r̲m̲e̲d̲ ̲d̲u̲r̲i̲n̲g̲ ̲D̲A̲T̲A̲ ̲T̲R̲A̲N̲S̲M̲I̲S̲S̲I̲O̲N̲ ̲(̲A̲D̲T̲)̲

         ADT0    Prepare for input from the line. Initialize
                 variables.
                 req ̲i ̲errors:= 0
                 dt ̲wait ̲count:= 0
                 IF ack ̲to ̲be ̲sent THEN send IRD1 and
                 ack ̲to ̲be ̲sent:= false

         ADT1    Accumulate ETB subsegment data from IDR3. Update
                 statistic counters. Send ACK, IRD1.
                 Reset counter for no response and start timer
                 for no response.

         ADT2    Accumulate ETX subsegment data from IDR4. Send
                 data segment to CR80 in reply to pending Request
                 Input Command. Update statistic counters. Set
                 flag ack ̲to ̲be ̲sent:= true;
                 Update c ̲status entry to not received.

         ADT3    Cancel pending Input Request identified in
                 command. Notify CR80 and clean up input buffers.
                 Reset c ̲status entry.

         ADT4    Cancel pending Output Request identified in
                 command. Notify CR80 and clean up output buffers.
                 Reset c ̲status entry.

         ADT5    Notify CR80 about the number of:

                 - messages transmitted
                 - messages retransmitted
                 - information messages
                   received error free
                 - messages received in error
                 Cf. Reference 15, section 3.1.2.
                 Reset c ̲status entry.

         ADT6    Reset counters:
                   messages ̲transmitted
                   messages ̲retransmitted
                   i ̲messages ̲received
                   messages ̲received ̲error
                 Cf. Reference 15, section 3.1.2
                 Reset c ̲status entry.

         ADT7    Reset counter for errors occurring during Request
                 Output.
                 Send BREAK, CRD2.
                 Clear flag ack ̲to ̲be ̲sent:= false.
                 Reset counter for no response and start timer
                 for no response.


         ADT8    Update statistics. Variable request ̲o ̲errors:=
                 0. Send ETB ̲subsegment in IRD3.
                 Reset counter for no response and start timer
                 for no response.

         ADT9    Update statistics. Variable request ̲o ̲er-
                 rors:= 0. Send last or entire ETX ̲subsegment
                 in IRD4 message. Set flag ack ̲to ̲be ̲sent: =
                 false.
                 Reset counter for no response and start timer
                 for no response.

         ADT10   Answer pending CR80 Request Output with OK
                 result code upon reception of ACK on last subsegment
                 in segment sent. Update statistics.
                 Set flag ack ̲to ̲be ̲sent:= true;
                 Update c ̲status entry to not received.

         ADT11   Update statistics. Send ACK, IRD1.
                 Reset counter for no response and start timer
                 for no response.

         ADT12   Answer pending CR80. Request Output with OK
                 result code upon reception of ACK on last subsegment
                 in segment. Accumulate ETB subsegment received.
                 Update c ̲status entry to not received. Send
                 ACK no request, IRD1.
                 Reset counter for no response and start timer
                 for no response.

         ADT13   Answer pending CR80 Request Output command
                 with OK result code upon reception of ACK on
                 last subsegment in segment. Send data segment
                 to CR80, i.e. generate OK result code to Request
                 Input. Set flag ack ̲to ̲be ̲sent:= true.
                 Update c ̲status entry to not received.

         ADT14   Cancel pending CR80 commands, notify CR80 of
                 closing. Clean up all input/output buffers.
                 Send READY FOR DISCONNECT, SRD1.
                 Reset counter for no response and start timer
                 for no response.

         ADT15   Cancel pending CR80 commands, notify CR80 of
                 closing. Clean up all input/output buffers.



         ADT16   Clean up input/output buffers. Reject pending
                 CR80 commands with reason code = fatal error.
                 Reset counters: req ̲i ̲errors, req  ̲o ̲errors,
                 data ̲transmission ̲error, and
                 dt ̲wait ̲count.

         ADT17   Update statistics.
                 Increment counter for WAIT messages,
                 dt ̲wait ̲count, send WAIT, IRD2 with previously
                 used SC.
                 Reset counter for no response and start timer
                 for no response.

         ADT18   IF ack ̲to ̲be ̲sent = true THEN (send IRD1 and
                 ack ̲to ̲be ̲sent:= false).
                 Reset counter for no response and start timer
                 for no response.

         ADT19   Reject CR80 command with reason code = current
                 state. Reset c ̲status entry.

         ADT20   Retransmit previous message with same SC and
                 OC.(5:3)= 001 (binary), NAK. Increment
                 req ̲i ̲errors, if greater than
                 req ̲io ̲error ̲limit, set data ̲transmission ̲error
                 to true. Update statistics.
                 Reset counter for no response and start timer
                 for no response.

         ADT21   Retransmit previous message with same SC and
                 OC.(5:3)= 000 (binary), ACK. 
                 Update statistics.
                 Reset counter for no response and start timer
                 for no response.

         ADT22   Change ACK/NAK field to ACK in incoming message.
                 Analyze it once again, i.e. use the modified
                 frame as input.

         ADT23   Increment req ̲i ̲errors, if then greater than
                 req ̲io ̲error ̲limit set data ̲transmission ̲error
                 to true.

         ADT24   Increment req ̲o ̲errors if greater than
                 req ̲io ̲error ̲limit set data ̲transmission ̲error
                 to true.

         ADT25   Send DISCONNECT to GRTS, SRD2.



             ADT26   If receiving an incoming message then return.
                     Update the number of no response.
                     If number of no response is greater than
                     no response unit then send Disconnect and
                     notify CR80 of closing.
                     If number of no response is less than no
                     response unit then retransmit the previous
                     message with the same SC and start the
                     timer for no response.
                     If disconnect is sent then reset, state
                     and sequence ̲id.

         Figures 4.2.6.1.2-1 and 4.2.6.1.2-2 depict typical
         receive segment and send segment sequences.

         Segments are received and sent by the CR80 commands
         Request Input and Request Output.

         The receive segment sequence emphasized in Figure 4.2.6.1.2-1
         consists of:

             - Request Input command
             - ETB subsegment
             - ETX subsegment
             - Request Input command
             - ETB subsegment
             - ETX subsegment
             - Request Input command
             - TRANSMIT DATA
             - Request Output command, e.g. for SUPER ACK.

         A typical send segment sequence is shown in Figure
         4.2.6.1.2-2. The events consist of:

             - Request Output command

             - TRANSMIT DATA, more than one subsegment left
               to be sent

             - TRANSMIT DATA, remaining data of segment is
               contained in one subsegment.

             - ETX subsegment (e.g. with SUPER ACK).

         An overview of the most commonly used state transistions
         is given in Figure 4.2.6.1.2-3.










































                    FIGURE 4.2.6.1.2-1
        STATE EVENT TABLE FOR DATA TRANSMISSION, 
                     RECEIVE SEGMENT










































                    FIGURE 4.2.6.1.2-2
         STATE/EVENT TABLE FOR DATA TRANSMISSION,
                       SEND SEGMENT















































                    FIGURE 4.2.6.1.2-3
           COMMONLY USED DT STATE TRANSISTIONS


4.2.6.1.3    C̲C̲I̲S̲ ̲S̲i̲m̲u̲l̲a̲t̲i̲o̲n̲ ̲S̲e̲q̲u̲e̲n̲c̲e̲

         The CCIS Simulatons is described in PC/PDS/002, Protocol
         Converter: CCIS Low Level Protocol Simulator Package
         Design Specification.



4.2.6.2  S̲o̲f̲t̲w̲a̲r̲e̲ ̲S̲t̲r̲u̲c̲t̲u̲r̲e̲

         The CLP Package consists of the following subpackages:

         a)  System Software
         b)  CR80 Handler
         c)  PC Handler
         d)  GRTS Handler
         e)  V24 Line Access
         f)  GRTS Driver

         The Line Access subpackage is responsible for handling
         the V24 status line signals according to the specifications
         in Reference 13.

         The GRTS Driver is responsible for line communication
         at the message level and generation of Block Check
         Code (BCC).

         Figure 4.2.6.2-1 overleaf depicts the process hierarchy
         in the CLP software.

         The contents of subpackages Line Access and GRTS Driver
         is outlined above.

         The protocol part of CLP reflects the functional description
         given in section 4.2.6.1.

         The Event Analyser assigns a value identifying the
         event class to which an incoming event belongs. Two
         sets of event classes are used depending on whether
         CLP is running an OPEN LINK sequence or a DATA TRANSMISSION
         sequence.

         At the Protocol Entry (cf. Figure 4.2.6.2-1) the next
         state entered and the action to be performed is found
         from the pertinent state/event table (SOL, AOL) or
         (SDT, ADT).



















































                     FIGURE 4.2.6.2-1
                  CLP SOFTWARE STRUCTURE


         Actions identified from one of the tables are implemented
         as procedures denoted open ̲link0,
         open ̲link1, etc. and data ̲transmission0,
         data ̲transmission1 .....

4.2.6.3  P̲a̲c̲k̲a̲g̲e̲ ̲D̲a̲t̲a̲

         The data description given here is based on the syntax
         for SWELL declarations even though the design is intended
         for implementation in Z80 code.

         CONST
           req ̲io ̲error ̲limit =    10; "max err./command
           dt ̲wait ̲count ̲limit=    10; "max wait counts
           norespons ̲limit    =     7; "max number of no response
           id ̲size            =    35; "char. in passwrd/id
           segment ̲size       =  1140; "max segment size
           subsegment ̲size    =   324; "max subsegm. size

         TYPE
           sequences = (           "const. for sequence id
             open ̲link,            "eol event
             data ̲transmission),   "edt event

           cr80 ̲commands = (       "used for open, close etc.
             illegal ̲command,      "used if multiple commands
             no ̲command,           "of the same type is present
             open,
             close,
             req ̲input,
             req ̲output,
             cancel ̲input,
             cancel ̲output,
             show ̲stat,
             reset ̲stat);


           command ̲state = (         "used in global table
             not ̲rec,                "not received
             already ̲rec);           "already received

           pending ̲commands =        "type used for check of
             RECORD                  "CR80 commands
               open ̲1,
               close ̲1,
               req ̲i,
               req ̲o,
               cancel ̲i,
               cancel ̲o,
               show ̲s,
               reset ̲s               : command ̲state;
             END;

           grts ̲frames =
             RECORD                  "define message format
               syn0,
               syn1,
               syn2,
               syn3,
               soh,
               fc,
               sc,
               ac,
               oc,
               ic,
               aux,
               stx,
               mc                    : char; "charaters
               text : array(0..323) of char;
               rs,
               etx,
               etb,
               bcc                   : char; "charaters
             END;


           grts ̲messages = (         "message analysis
             no ̲message,             "of grts events
             frame ̲error,
             nak,
             implied ̲ack,            "text, new sc, nak
             srd3,                   "select
             srd4,                   "no instruction
             sdr1,                   "RFD
             sdr2,                   "disconnect
             crd1 ̲pswrd,             "logon password
             crd1 ̲keywrd,            "logon keyword
             crd2,                   "break
             cdr1,                   "line down
             ird1,                   "ack no request
             ird2,                   "wait
             idr1,                   "transmit data
             idr2,                   "DIN start
             idr3,                   "mid subsegment
             idr4,                   "last subsegment
             seqcon);                "constant sequence number
           clp ̲messages = (          "msg. sent from CLP
             sr1,                    "ready for disconnect
             sr2,                    "disconnect
             sr3,                    "select
             sr4,                    "no instruction
             cr1 ̲passwrd,            "ID and PASSWORD
             cr1 ̲keywrd,             "program keyword
             cr2,                    "break
             ir1,                    "ACK no request
             ir2,                    "wait
             ir3,                    "first/mid subsegm.
             ir4);                   "last/entire subsegm.

           open ̲link ̲states = (      "constants for state id
             so10,                   "initial state
             so11,                   "boot load state
             so12,                   "before SELECT
             so13,                   "before id, passwrd
             so14,                   "before $*$DACDINDAC
             so15,                   "before ACK on DIN mes
             so16);                  "closing


           data ̲transmission ̲states = ("constants for state
           id
             sdt0,                   "await REQUEST INPUT
             sdt1,                   "REQUEST INPUT received
             sdt2,                   "subsegm. accumulation
             sdt3,                   "segment received
             sdt4,                   "subsegm. to be sent
             sdt5,                   "segm. sent (not ack…08…ed)
             sdt6,                   "TD. received
             sdt7);                  "ready for closing link

           open ̲link ̲events = (      "constants for event id
             eo10,                   "time out or error
             eo11,                   "OPEN LINK command
             eo12,                   "CLOSE LINK
             eo13,                   "RFD, SDR1
             eo14,                   "TD, IDR1
             eo15,                   "DIN/RST, IDR2
             eo16,                   "simple NAK
             eo17,                   "implied ACK
             eo18,                   "message error
             eo19,                   "disconnect received
             eo110,                  "line down, CDR1
             eo111);                 "other events

           data ̲trans ̲events = (     "constants for event id
             edt0,                   "error
             edt1,                   "CLOSE LINK
             edt2                    "REQUEST INPUT
             edt3,                   "REQUEST OUTPUT, ETB
             edt4,                   "REQUEST OUTPUT, ETX
             edt5,                   "CANCEL INPUT
             edt6,                   "CANCEL OUTPUT
             edt7,                   "SHOW STATISTICS
             edt8,                   "RESET STATISTICS
             edt9,                   "RFD, SDR1
             edt10,                  "DISCON., SDR2
             edt11,                  "TD, ETB
             edt12,                  "TD, ETX
             edt13,                  "ETB subsegm., IDR3
             edt14,                  "ETX subsegm., IDR4
             edt15,                  "simple NAK
             edt16,                  "implied ACK
             edt17,                  "message in error
             edt18,                  "time out
             edt 19,                 "illegal request output
             edt20);                 "other events


           open ̲link ̲actions = (   "action id…08…s
             ao10,                 "init variables
             ao11,                 "init baudrate, Send RFD,SRD1
             ao12,                 "not used
             ao13,                 "send SELECT, SRD3
             ao14,                 "send CRD1, IDPSW
             ao15,                 "send CRD1, PCTHDL
             ao16,                 "send IRD1, ACK
             ao17,                 "retransmit, NAK
             ao18,                 "retransmit, ACK
             ao19,                 "error in OPEN ̲LINK, disc.
             ao110,                "CLOSE LINK, disconnect
             ao111,                "error in OPEN ̲LINK
             ao112,                "send RFD
             ao113,                "Reject CR80 command
             aol14);               "update open ̲link ̲timeout

           line ̲down ̲message ̲codes= ("cf Ref 18 pp 34,35
             Ok,       "no error.
             CP,       "Central system disconnects.
             DIS,      "Received DIS GRTS II control record.
             ICC,      "Invalid command to/from central system.
             PAS,      "Did not receive user ID password.
             ABT,      "No SNUMB on Abort control card.
             S/I,      "Missing SNUMB or IDENT card.
             ONA,      "Output not available.
             INV,      "Invalid control card.
             IMF,      "Invalid message format.
             SLV,      "Slave program not in
                       "system (DAC only).
             OC,       "Output complete.
             SPD,      "Link space denied.
             NSA,      "No link space available.
             LNE,      "Link number error.
             6UA,      "Central system unavailable.
             RCE,      "Retry count exhausted.


             DOL,      "Device off-line.
             EOF,      "End-of-File (EOF status cannot recover).
             TNK,      "Terminal not known.
             RCM,      "Remote computer module.
             ACT,      "Line active.
             NDS,      "Line not completely disconnected.
             MCE,      "Media code error.
             XID,      "Blank or zero ID.
             "ID,      "Duplicate ID.
             PTF,      "No PAT entries available for input.
             SNB,      "Messing $ SNUMB card.
             SIZ,      "Job source too long.
             NUM,      "No available program number for job.
             DSC,      "Excessive disk errors.
             DUP,      "Duplicate SNUMB's
             LNK);     "No disk links available.



           data ̲transmission ̲actions=(
             adt0,                  "prepare for input
             adt1,                  "accumulate ETB subs.
             adt2,                  "accumulate ETX subs.
             adt3,                  "cancel INP. REQ.
             adt4,                  "cancel OUT. REQ.
             adt5,                  "deliver statistics
             adt6,                  "reset statistics
             adt7,                  "send BREAK, CRD2
             adt8,                  "send ETB subsegm.
             adt9,                  "send ETX subsegm.
             adt10,                 "answer REQUEST OUTPUT
             adt11,                 "send ACK, IRD1
             adt12,                 "acc. ETB subsegm.
             adt13,                 "answer REQUEST OUTPUT
             adt14,                 "close, send RFD
             adt15,                 "clean IO buffers
             adt16,                 "reject CR80 comm.
             adt17,                 "send WAIT IRD2
             adt18,                 "send ACK if req.
             adt19,                 "reject CR80 command
             adt20,                 "retransmit, NAK
             adt21,                 "retransmit, ACK
             adt22,                 "re-analyse with ACK
             adt23,                 "set ctrl. variables
             adt24,                 "inc. REQ ̲O ̲ERRORS
             adt25,                 "send DISCONNECT
             adt26);                "No response 

           subsegment ̲type = (      "ETB/ETX to be sent
             etb ̲subsegment,        "first/mid subsegm.
             etx ̲subsegment);       "last or entire

           table ̲element =
             RECORD
               state,
               action : integer;
             END;



           ol ̲table ̲column =         "column in state event
             RECORD                  "table for open link
               s0,                   
               s1,
               s2,
               s3,
               s4,
               s5,
               s6 : table ̲element;
             END;

           dt ̲table ̲column =…02…"column in state event
             RECORD                  "table for data transm.
               s0,
               s1,
               s2,
               s3,
               s4,
               s5,
               s6,
               s7 : table ̲element;
             END;

         clp ̲command ̲id = (          "identifies incoming cmd
           clp ̲open ̲link ̲id,
           clp ̲close ̲link ̲id,
           clp ̲request ̲input ̲id,
           clp ̲request ̲output ̲id,
           clp ̲cancel ̲input ̲id,
           clp ̲cancel ̲output ̲id,
           clp ̲show ̲statistics ̲id,
           clp ̲reset ̲statistics ̲id);

         clp ̲open ̲link ̲cmd =
           RECORD
             command ̲id: clp ̲command ̲id;
             addr: address; "pointer to parameters
           END;

         clp ̲logon ̲params =
           RECORD
             ccis ̲simulation: boolean;
             baudrate ̲ccis: integer;
             id ̲pass: array(0..35) of char;
           END;



         clp ̲close ̲cmd =
           RECORD
             command ̲id: clp ̲command ̲id;
           END;

         clp ̲request ̲input ̲cmd =
           RECORD
             command ̲id: clp ̲command ̲id:
             addr: address; "address of data buffer
           END;

         clp ̲request ̲output ̲cmd =
           RECORD
             command ̲id: clp ̲command ̲id;
             addr: address; "address of data buffer
             bytes: integer;
           END;

         clp ̲cancel ̲input ̲cmd =
           RECORD
             command ̲id: clp ̲command ̲id;
           END;

         clp ̲cancel ̲output ̲cmd =
           RECORD
             command ̲id: clp ̲command ̲id:
           END;

         clp ̲show ̲statistics ̲cmd =
           RECORD
             command ̲id: clp ̲command ̲id;
             addr: address; "address of clp ̲response ̲params
           END;

         clp ̲reset ̲statistics ̲cmd =
           RECORD
             command ̲id: clp ̲command ̲id;
           END;

         clp ̲response =
           RECORD
             command ̲id: clp ̲command ̲id;
             result,
             bytes: integer;
             fill: ARRAY(0..1) OF integer;
           END;


         clp ̲response ̲params =
           RECORD
             msg ̲transmitted,
             msg ̲retransmitted,
             info ̲msg ̲received,
             msg ̲in ̲error         :  integer
           END;


         VAR
           open ̲link ̲nak ̲count,      "count NAK's
           event ̲class,              "event recognized
           state,                    "state id
           action ̲id,                "action id
           req ̲o ̲errors,             "count err. in DT
           req ̲i ̲errors,             "count err. in DT
           data ̲transmission ̲error,  "ctrl. variable
           baudrate,                 "for HW initializ.
           messages ̲transmitted,     "statistics inform.
           messages ̲retransmitted,   "subsegm. retransm.
           i ̲messages ̲received,      "info messgs receiv.
           frames ̲received ̲error,    "incom. subs., error
           sequence ̲id,              "open, data, or ccis sim.
           cr ̲80 ̲command,            "of type ̲cr80 ̲commands
           grts ̲message,             "of type grts ̲message
           out ̲byte ̲count,           "bytes sent from segment
           actual ̲segment ̲size,      "size of segm. to be sent
           message ̲reference,        "pointer to msg. header
           text ̲reference            "pointer to text field
                                   :  integer;

           start ̲protocol,           "indicates RFD to be sent
           open ̲link ̲timeout,        "timeout flag in open link
           naks ̲exceeded,            "too many naks per transm.
           set ̲nak,                  "set nak before sending
                                     frame
           freeze ̲sc,                "don't change sc
           ack ̲to ̲be ̲sent            "flag outstanding ACK
                                   :  boolean;

           id ̲pass,                  "for holding char. strings
           test ̲id ̲pass              "fixed array for simulation
                                   :  array(0..id ̲size) of char;
                                     "35 characters & delimit.

           c ̲status                  "table for holding status
                                   :  pending ̲commands;


           grts ̲frame,               "grts msg. format
           clp ̲frame,                "clp message format
                                   :  grts ̲frames;

           message ̲status            "error, nak, implied ack.
                                   :  cr80 ̲commands;

           ol ̲state ̲table : array(0..eo111) OF ol ̲table ̲column;
           dt ̲state ̲table : array(0..edt18) OF dt ̲table ̲column;

           line ̲down ̲message ̲code:   line ̲down ̲message ̲codes;

         INIT                        "initialization of variables
           id ̲pass        = (:0:);   "fill with nulls
           test ̲id ̲pass   = '$*$LOGID$PASSWORD/DNM';
           ol ̲state ̲table = .......; "cf. section 4.2.6.1.1
           dt ̲state ̲table = .......; "cf. section 4.2.6.1.2
           ack ̲to ̲be ̲sent = true;

4.2.6.4  P̲a̲c̲k̲a̲g̲e̲ ̲D̲e̲s̲i̲g̲n̲

4.2.6.4.1  P̲r̲o̲t̲o̲c̲o̲l̲ ̲E̲n̲t̲r̲y̲ ̲P̲s̲e̲u̲d̲o̲ ̲C̲o̲d̲e̲

         input :
           none

         output:
           none

         function:
           the mainprogram analyzes events and acts according
           to the sequence invoked (open link or data transm.)
           and the current state.

           the new state and next event are fetched by external
           procedures.

         procedures called:
           event ̲analyzer
           update ̲ol ̲state
           update ̲dt ̲state
           open ̲link0 through open ̲link14 procedures
           data ̲transmission0 through data ̲transmission26
           procedures


         external data:
           sequence ̲id
           event ̲class
           state
           action ̲id
           ol ̲state ̲table
           dt ̲state ̲table

         local data:
           none

         BEGIN "of protocol entry (CLP mainprogram)
           initialize open link state event table;
           initialize data transmission state event table;
           initialize ccis state event table; "not implemented
           sequence ̲id:= open ̲link;
           state:= so10; "set initial state
           REPEAT

           BEGIN
             event ̲analyzer(sequence ̲id) "open link or data
             tr.
                           (event ̲class);"input found
             update ̲state(state, event class) "state, event
                                 (state, action id"new state
             
                                                  "and action


               CASE sequence ̲id OF
               open ̲link:
               BEGIN
                 CASE action ̲id OF
                 ao10  : open ̲link0 () (); "cf. PDS section
                 ao11  : open ̲link1 () (); "4.2.6.1.1 for content
                 ao12  : open ̲link2 () (); "of open link
                 ao13  : open ̲link3 () (); "procedures
                 ao14  : open ̲link4 () (); "
                 ao15  : open ̲link5 () (); "
                 ao16  : open ̲link6 () (); "


                 ao17  : open ̲link7 () (); "
                 ao18  : open ̲link8 () (); "
                 ao19  : open ̲link9 () (); "
                 ao110 : open ̲link10() (); "
                 ao111 : open ̲link11() (); "
                 ao112 : open ̲link12() (); "
                 ao113 : open ̲link13() (); "
                 ao114 : open ̲link14() (); "
                 END; "case action ̲id in open link sequence
               END; "servicing open link event

               data ̲transmission:
               BEGIN

                 CASE action ̲id OF
                 adt0  : data ̲transmission0 () (); "cf. PDS
                 sect.
                 adt1  : data ̲transmission1 () (); "4.2.6.1.2
                       for
                 adt2  : data ̲transmission2 () (); "content
                       of 
                                                   "data
                 adt3  : data ̲transmission3 () (); "transmission
                 adt4  : data ̲transmission4 () (); "procedures
                 adt5  : data ̲transmission5 () (); "
                 adt6  : data ̲transmission6 () (); "
                 adt7  : data ̲transmission7 () (); "
                 adt8  : data ̲transmission8 () (); "
                 adt9  : data ̲transmission9 () (); "
                 adt10 : data ̲transmission10() (); "
                 adt11 : data ̲transmission11() (); "
                 adt12 : data ̲transmission12() (); "
                 adt13 : data ̲transmission13() (); "
                 adt14 : data ̲transmission14() (); "
                 adt15 : data ̲transmission15() (): "
                 adt16 : data ̲transmission16() (); "
                 adt17 : data ̲transmission17() (); "
                 adt18 : data ̲transmission18() (); "
                 adt19 : data ̲transmission19() (); "
                 adt20 : data ̲transmission20() (); "
                 adt21 : data ̲transmission21() (); "
                 adt22 : data ̲transmission22() (); "
                 adt23 : data ̲transmission23() (); "
                 adt24 : data ̲transmission24() (); "
                 adt25 : data ̲transmission25() (): "
                 adt26 : data ̲transmission26() (): "
                 END; "end data transmission actions
               END; "data transmission sequence


               END; "case sequence id
             END  until A   A"forever

           END; "protocol entry.


4.2.6.4.2    E̲v̲e̲n̲t̲ ̲A̲n̲a̲l̲y̲z̲e̲r̲ ̲P̲s̲e̲u̲d̲o̲ ̲C̲o̲d̲e̲

        a)   PROCEDURE event ̲analyzer
                   (sequence ̲id: sequences) "kept at return
                   (event ̲class: integer)

         input :
           sequence ̲id        which type of event should be
                              searched for, open link, data
                              transmission, or ccis simulation

         output :
           event ̲class        event class found

         function:
           find the event class according to the sequence
           identifier entered telling which state event table
           is currently used.

         procedures called:
           get ̲cr80 ̲command
           get ̲grts ̲message

         external data :
           refer to the data description

         local data    :
           none


         BEGIN  "procedure start
           line ̲down ̲message ̲code:= OK; "initialize result code
           IF sequence ̲id = open ̲link THEN
           BEGIN
             event ̲class:= eo111;
             IF open ̲link ̲timeout = true LOGOR
                naks ̲exceeded = true THEN
                event ̲class:= eo10
                ELSE
                BEGIN "message decoding
                 get ̲grts ̲message()(grts ̲message);
                 IF grts ̲message NE no ̲message THEN
                 BEGIN
                   CASE grts ̲message OF
                   frame ̲error : event ̲class:= eo18;
                   nak : event ̲class:= eo16;
                   implied ̲ack : event ̲class:= eo17;
                   sdr1 : event ̲class:= eo13;
                   sdr2 : event ̲class:= eol9;
                   cdr1 : event ̲class:= eo110;
                   idr1 : event ̲class:= eo14;
                   idr2 : event ̲class:= eo15;
                   OTHERWISE event ̲class:= eo111;
                 END; "end case clause
               ELSE
                 BEGIN "get ̲cr80 ̲command
                   get ̲cr80 ̲command() (cr80 ̲command)
                   IF cr80 ̲command NE no ̲command THEN
                   BEGIN
                     CASE cr80 ̲command OF
                     open : event ̲class:= eo11;
                     close : event ̲class:= eo12;
                     OTHERWISE event ̲class:= eo111; "illegal
                 com
                   END  "end case clause
                 END; "end get cr80 message
             END; "end message decoding



           IF sequence ̲id = data ̲transmission THEN
           BEGIN
             event ̲class:= edt18; "other events are edt18
             IF data ̲transmission ̲error = true THEN
               event ̲class:= edt0
             ELSE
             BEGIN
             gets ̲grts ̲message()(grts ̲message);
                 IF grts ̲message NE no ̲message THEN
                 BEGIN
                   CASE grts ̲message OF
                   frame ̲error : event ̲class:= edt17;
                   nak : event ̲class:= edt15;
                   implied ̲ack : event ̲class:= edt16;
                   sdr1 : event ̲class:= edt9;
                   sdr2 : event ̲class:= edt10;
                   idr1 :
                   BEGIN "ETX or ETB to be sent?
                     IF actual ̲segment ̲size - out ̲byte ̲count
                     is less than or equal to subsegment ̲size
                     THEN
                       event ̲class:= edt12
                     ELSE
                       event ̲class:= edt11;
                   END; "end of idr1 analysis
                   idr3 : event ̲class:= edt13;
                   idr4 : event ̲class:= edt14;
                   OTHERWISE event ̲class:= edt18;
                 END
                 ELSE
                   event ̲class:= edt18; "no message from grts



               ELSE
               BEGIN "there was no new GRTS command
                 get ̲grts ̲message()(grts ̲message);
             BEGIN
             get ̲cr80 ̲command()(cr80 ̲command);
               IF cr80 ̲command NE no ̲command THEN
               BEGIN "new cr80 command has arrived
                 CASE cr80 ̲command OF
                 close : event ̲class:= edt1;
                 req ̲input : event ̲class:= edt2;
                 req ̲output :
                 BEGIN
                   IF actual ̲segment ̲size is less than or
                      equal to subsegment ̲size THEN 
                      event ̲class:= edt4
                   ELSE
                      event ̲class:= edt3;
                 END; "req output with ETX or ETB segment
                 cancel ̲input : event ̲class:= edt5;
                 cancel ̲output : event ̲class:= edt6;
                 show ̲stat : event ̲class:= edt7;
                 reset ̲stat : event ̲class:= edt8;
                 OTHERWISE event ̲class:= edt18;
               END  "end of cr80 command case clause

               END; "grts message analysis
             END; " event is not data transm. error
           END; " sequence ̲id is data ̲transmission

         END; " procedure event ̲analyser



        b) PROCEDURE get ̲cr80 ̲command
                   () "no input
                   (cr80 ̲command: cr80 ̲commands);

         input   :
           none

         output  :
           cr80 ̲command identified by constant contained
           in the type declaration cr80 ̲commands

         function:
           check for presence of a cr80 ̲command. Check
           to avoid multiple pending commands of the
           same type

         procedures called:
           cr80 communication module

         external data :
           command ̲status:  table with one entry for each
           possible cr80 command. Entries have values
           not ̲rec or already ̲rec  "received or not

         local data:
           temp ̲state: command ̲state "for local use

         BEGIN "of procedure get ̲cr80 ̲command
           cr80 ̲command:= no ̲command; "output if no comm.
           call cr80 communication module
           IF cr80 ̲command is present THEN
             cr80 ̲command:= constant; "constant of type
                                      "cr80 ̲commands
           temp ̲state:= not ̲rec;

           CASE cr80 ̲command OF "see if already pending
           no ̲command: ; "no action
           open: temp ̲state:= c ̲status.open ̲1;
           close: temp ̲state:= c ̲status.close ̲1;
           req ̲input: temp ̲state:= c ̲status.req ̲i;
           req ̲output: temp ̲state:= c ̲status.req ̲o;
           cancel ̲input: temp ̲state:= c ̲status.cancel ̲i;
           cancel ̲output: temp ̲state:= c ̲status.cancel ̲o;
           show ̲stat: temp ̲state:= c ̲status,show ̲s;
           reset ̲stat: temp ̲state:=c ̲status.reset ̲s;


           OTHERWISE  ; "no action

           IF temp ̲state = already ̲rec THEN
           BEGIN
             cancel the command received (clear RAM area
             of the excessive command)

             CASE cr80 ̲command OF "restore table entry
             no ̲command: ; "no action
             open: c ̲status.open ̲1:= not ̲rec;
             close: c ̲status.close ̲1:=not ̲rec;                      req
                                                                    ̲input:
                                                                    c
                                                                    ̲status.req
                                                                    ̲i:=
                                                                    not
                                                                    ̲rec;
             req ̲output: c ̲status.req ̲o:= not ̲rec;
             cancel ̲input: c ̲status.cancel ̲i:= not ̲rec;
             cancal ̲output: c ̲status.cancel ̲o:= not ̲rec;
             show ̲stat: c ̲status.show ̲s:= not ̲rec;
             reset ̲state: c ̲status.reset ̲s:= not ̲rec;
             OTHERWISE  : "no action

             cr80 ̲command:= illegal ̲command;
           END
           ELSE
           BEGIN "normal update of command status
             CASE cr80 ̲command OF "restore table entry
             no ̲command: ; "no action
             open: c ̲status.open ̲1:= already ̲rec;
             close: c ̲status.close ̲1:= already ̲rec;
             req ̲input: c ̲status.req ̲i:= already ̲rec;
             req ̲output: c ̲status.req ̲o:= already ̲rec;
             cancel ̲input: c ̲status.cancel ̲i:= already ̲rec;
             cancel ̲output: c ̲status.cancel ̲o:= already rec;
             show ̲stat: c ̲status.show ̲s:= already ̲rec;
             reset ̲stat: c ̲status.reset ̲s:= already ̲rec;
             OTHERWISE  ; "no action
           END; "end of normal table update
         END; "end procedure get ̲cr80 ̲command


        c) PROCEDURE get ̲grts ̲message
                   ( )  "no input
                   (grts ̲message : grts ̲messages)

         input   :
           none

         output  :
           constant identifying grts message event
           (no ̲message, nak, or regular messages).
           Refer to Package Data, section 4.2.6.3

         function:
           see if a grts message has arrived.
           Return with message- or error identification
           or the value no ̲message.

         procedures called:
           check ̲grts ̲buffer

         external data:
           none

         local data:
           message ̲group : integer of TYPE =(service,
                                       control, info);
           fc ̲code, oc ̲code : integer;

         BEGIN "of get ̲grts ̲message
           "check for incoming message"
           check ̲grts ̲buffer() (message ̲status,
                                message ̲reference,
                                text ̲reference);

           grts ̲message:= message ̲status;
           IF  LOGAND
              grts ̲message NE frame ̲error LOGAND
              grts ̲message NE nak LOGAND
              grts ̲message NE implied ̲ack LOGAND 
              grts ̲message NE seqcon THEN 
           BEGIN "ordinary message
             fc ̲code:= grts ̲frame.fc; "get function code
             oc ̲code:= grts ̲frame.oc; "get operation code
             IF fc ̲code = #42 LOGOR
                fc ̲code = #43 THEN
               message ̲group:= service;
             IF fc ̲code = #44 THEN message ̲group:= control;
             IF fc ̲code = #4D THEN message ̲group:= info;


             grts ̲message:= frame ̲error;
             CASE message ̲group OF
             service:
             BEGIN "service message validation
               IF oc ̲code = #44 THEN
                 grts ̲message:= sdr1; "RFD
               IF oc ̲code = #46 THEN
                 grts ̲message:= sdr2; "disconnect
               IF oc ̲code = #42 THEN
                 grts ̲message:= srd3; "select
               IF oc ̲code = #40 THEN
                 grts ̲message:= srd4; "no instruction
             END; "service message validation

             control:
             BEGIN "ctrl. msg. validation
               IF oc ̲code NE #40 LOGOR
               (grts ̲frame.sc NE #41 LOGAND "cf.Ref. 18,p33
                grts ̲frame.sc NE #42) LOGOR
                grts ̲frame.stx NE #02 LOGOR
               (grts ̲frame.mc NE #48 LOGAND
                grts ̲frame.mc NE #4E) LOGOR
                grts ̲frame.rs NE #1E THEN
                grts ̲message:= frame ̲error;
               IF grts ̲frame.text = …08…$*$LOGID$PSWRD/DNM…08… THEN
                 grts ̲message:= crd1 ̲pswrd; "simulation
               IF grts ̲frame.text = …08…$*$DACDINDAC…08… THEN
                 grts ̲message:= crd1 ̲keywrd; "simulation
               IF grts ̲frame.text = #31 THEN
                 grts ̲message:= crd2; "break
               IF grts ̲frame.text = …08…LINE DISCONNECTED XXX…08…
                                                    LOGOR
                  grts ̲frame.text = …08…LINE TERMINATED XXX…08…
                                                    THEN
               BEGIN "line down control message received
                 grts ̲message:= cdr1; "line down message
                 look up the constant of type
                 line ̲down ̲message ̲codes corresponding
                 to the string XXX. Store the
                 constant in the variable
                 line ̲down ̲message ̲code.
               END;
             END; "ctrl message validation


             info:
             BEGIN
               IF (oc ̲code NE #40 LOGAND "validation
                  oc ̲code NE #42 LOGAND "Ref.18,p33
                  oc ̲code NE #44) LOGOR
                  (grts ̲frame.sc NE #41 LOGAND
                  grts ̲frame.sc NE #42) LOGOR
                  grts ̲frame.stx NE #02 LOGOR
                  (grts ̲frame.etb NE #03 LOGAND
                  grts ̲frame.etx NE #17) THEN
                  grts ̲message:= frame ̲error;
               ELSE
               BEGIN " valid message
                 IF oc ̲code = #40 THEN
                    grts ̲message:= idr2; "transmit data
                 IF oc ̲code = #42 THEN
                    BEGIN "no request message
                      IF grts ̲frame.text = …08……08… THEN "no text
                        grts ̲message:= ird1; "ack no request
                      IF oc ̲code = #44 THEN
                        IF grts ̲frame.text = …08…(*)DINDAC…08… LOGOR
                          grts ̲frame.text = …08…(*)RSTRT…08… THEN
                        grts ̲message:= idr2; "DIN/RST msg.
                      IF grts ̲message NE idr2 LOGAND
                      grts ̲frame.text NE …08……08… THEN
                      BEGIN
                      IF grts ̲frame.etb = #17 THEN
                        grts ̲message:= idr3; "etb subsegm.
                      IF grts ̲frame.etx = #03 THEN
                        grts ̲message:= idr4; "etx subsegm.
                   END;
                 END; "no request message
               END; "valid message
              END; "information message
            END; "end case message group
           END; "end of normal message validation
         END; "procedure get ̲grts ̲message


        d) PROCEDURE check ̲grts ̲buffer
                   ()
                   (message ̲status : grts ̲messages,
                    message ̲reference,
                    text ̲reference : integer)

         input   :
           none

         output  :
           message ̲status which holds a constant from the
           constants listed in …08…grts ̲messages…08…, i.e.
           no ̲message, frame ̲error, nak, implied ̲ack

         function:
           check incoming message buffer for the arrival
           of a message

         procedures called:
           TBD during coding phase

         external data:
           grts ̲frame: grts ̲frames; "cf. Package Data

         local ̲data:
           fc ̲code, oc ̲code, old ̲sc, new ̲sc : integer;
           parity ̲ok, block ̲check ̲ok : boolean;

         BEGIN
           message ̲status:= no ̲message;
           check for incoming message in buffer
           IF no message present THEN
             message ̲status:= no ̲message
           ELSE
           BEGIN "grts message is present
             check for odd parity computed by HW (bit 4 of
             …08…read…08… register #1 on LTU SIO circuit)
             IF no parity error THEN
               parity ̲ok:= true
             ELSE
               parity ̲ok:= false;


             compute a vertical ex ̲OR on characters following
             SOH (#01) and including ETX(#03) or ETB(#17)
             IF grts ̲frame.bcc = BCC computed THEN
               block ̲check ̲ok:= true
             ELSE
               block ̲check ̲ok:= false;

             fc ̲code:= grts ̲frame.fc; "check function code

             IF (fc ̲code NE #42 LOGAND
                 fc ̲code NE #43 LOGAND "used in SELECT
                 fc ̲code NE #44 LOGAND
                 fc ̲code NE #4D) LOGOR
                 parity ̲ok = false LOGOR
                 block ̲check ̲ok = false THEN
                   message ̲status:= frame ̲error
             ELSE
             BEGIN "check for nak and implied ack
               message ̲reference:= ADDRESS(grts ̲frame); "pointer
               text ̲reference:= ADDRESS(grts ̲frame.text);
               new ̲sc:= grts ̲frame.sc; "sequence code
               message ̲status:= idr3; "arbitrary NE nak
               oc ̲code:= grts ̲frame.oc;
               IF oc ̲code.(5:3) = 001 (binary) THEN
               BEGIN
                 message ̲status:= nak;
                 IF new ̲sc NE old ̲sc LOGAND
                    grts ̲frame.text NE …08……08…THEN "text is present
                      message ̲status:= implied ̲ack;
               END  "oc ̲code investigation
               ELSE
               BEGIN
                 IF old ̲sc = new ̲sc
                 then message ̲status = seqcon,
               END;
             END; "implied ack and nak check
           END; "grts message present
         old ̲sc:= new ̲sc;
         END; "procedure


        e) PROCEDURE update ̲state
                   (state, event ̲class) "input
                   (state, action ̲id) "output

         input   :
           current state to be updated
           event class identified in procedure event ̲analyzer

         output  :
           new state
           action identifier

         function:
           update state and find action ̲id from
           ol ̲state ̲table or dt ̲state ̲table

         external data:
           ol ̲state ̲table, dt ̲state ̲table

         BEGIN
           Case sequence ̲id of

           open ̲link:

             BEGIN "update ̲ol ̲state
               (state, action ̲id):= ol ̲state ̲table(state, 
                event ̲class);
             END; "end procedure

           data ̲transmission:

             BEGIN "update ̲dt ̲state
               (state, action ̲id):= dt ̲state ̲table(state, 
                event ̲class);
             END; "end procedure update ̲dt ̲state

           END "case sequence ̲id
         END;


4.2.6.4.3  S̲e̲n̲d̲ ̲C̲L̲P̲ ̲M̲e̲s̲s̲a̲g̲e̲ ̲P̲s̲e̲u̲d̲o̲ ̲C̲o̲d̲e̲

         PROCEDURE send ̲clp ̲message
                   (clp ̲message: clp ̲messages,
                   set ̲nak,
                   freeze ̲sc: boolean)
                   ( )

         input   :
           constant of type clp ̲messages (see section
           4.2.6.3) identifying which message is to
           be sent. Userid and password are given
           in global variables userid and passwrd.

           set ̲nak = true causes nak field to be set

           freeze ̲sc = true will cause the sc field
           to remain constant compared to previous
           message sent from CLP

         output  :
           none

         function:
           send a particular message to grts according
           to the message identification held in the
           variable clp ̲message.
           set sequence code field and nak field according to
           input booleans 

         procedures called:
           link driver module

         external data:
           clp ̲message: clp ̲messages; "constant
           clp ̲frame: grts ̲frames; "format of message
           set ̲nak, freeze ̲sc: boolean;

         local data:
           old ̲sc: integer; "previous SC
                            "used by PC


         BEGIN "procedure send ̲clp ̲message
           CASE clp ̲message OF
           sr1       : prepare ready for disconnect, SRD1
           sr2       : prepare disconnect, SRD2
           sr3       : prepare select, SRD3
           sr4       : prepare no instruction, SRD4
           cr1 ̲passwrd: prepare userid, password, CRD1
           cr1 ̲keywrd: prepare program keyword, CRD1
           cr2       : prepare break, CRD2
           ir1       : prepare ack no request, IRD1
           ir2       : prepare wait, IRD2
           ir3       : prepare first, mid subsegm., IRD3
           ir4       : prepare last/entire subsegment, IRD4
           tcrd1     : prepare line down ctrl. msg., TCRD1
           tird1     : prepare transmit data, TIRD1
           tird2     : prepare DINDAC start msg., TIRD2
           OTHERWISE ; " end case

           IF set ̲nak = true THEN
             clp ̲frame.oc(5:3):= 001 (binary);
           IF freeze ̲sc = false THEN
           BEGIN
             IF old ̲sc = #41 THEN
               clp ̲frame.sc:= #42
             ELSE
               clp ̲frame.sc:= #41;
           END
           ELSE
             clp ̲frame.sc:= old ̲sc; "previous sc from CLP side

           send message prepared in buffer clp ̲frame
         END; "procedure send ̲clp ̲message



4.2.6.5  P̲a̲c̲k̲a̲g̲e̲ ̲I̲n̲t̲e̲r̲f̲a̲c̲e̲s̲

         CLP receives the following commands from CPA:

         -   logon
         -   close link
         -   request input
         -   request output
         -   cancel input request
         -   cancel output request


         CLP receives the following commands from CI:

         -   show statistics

         -   reset statistics

         All commands are issued to CLP through the LTU driver
         which passes command records to the LTU.

         Generally, commands consist of records. In each record
         the first item is an integer identifying the command.

         This command identification is followed by one or more
         parameters. The format of a Request Output command
         is shown below.

         TYPE
             clp ̲request ̲output ̲cmd =
             RECORD
                 command ̲id: clp ̲command ̲id;
                 addr: address; "integer pointer to output buffer
                 bytes: integer;
             END;

         The type clp ̲command ̲id consists of simple integer
         constants.

         Similarly responses are communicated to CR80 using
         formats such as

         TYPE
             clp ̲request ̲output ̲rsp =
             RECORD
                 command ̲id: clp ̲command ̲id;
                 result: integer;
                 ...     "additional
                 ...     "parameters
             END;

         A complete description of command formats is given
         in section 4.2.6.3.

         A detailed description of formats and command response
         diagrams is given in PC/AUX/009: Protocol Converter
         CR80 - LTU I/F