home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / computervision / kermit.rpack < prev    next >
Text File  |  2020-01-01  |  3KB  |  118 lines

  1. ; 16 jly 85 esj converted
  2. ;;;;;;    RPACK     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3.       E'F A:S(NWLS)
  4.       E'O RPACK.(LEN,NUM,XDATA)
  5.  
  6. ;     read a packet from other KERMIT
  7.  
  8. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
  9. /INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
  10.  
  11.       I'R LEN,NUM,UNIT
  12.       I'R XDATA(1)
  13.       I'R COUNT,STATUS,J,K,T
  14.       I'R TV1,TV2,TV3, LCLSTATE
  15.       I'R BUFFER(132),CHKSUM,XTYPE,GAPTRY,MGAPTRY
  16.  
  17.       G'L TIMEOUT(1)       ; temp for lblset call
  18.  
  19. ;------------------------------< debugging stubs >----------------------------
  20.  
  21. #   LEN = 0
  22. #   NUM = N
  23. #   XDATA = 0
  24. #   E'E TGETCH.(XTYPE,$SD$)
  25. #   E'E FILL.(132,0,XDATA)
  26. #   F'N XTYPE
  27.  
  28. ;------------------------------< real code >----------------------------
  29. ;     setup lblset for handling deadlock condition
  30.       E'E LBLSET.(TIMEOUT, WAYOUT)
  31.  
  32.       UNIT=RMTDEV                           ;this is the input channel to
  33.                                            ;a packet from
  34.       GAPTRY=1
  35.       MGAPTRY=2
  36.       CHKSUM=0
  37.  
  38. ;     read me a packet that begins with a SOH and ends with MYEOL
  39.  
  40.       W'E (GAPTRY.LE.MGAPTRY)
  41.          W'R (IBMON.EQ.YES)
  42.             STATUS=IBMGETLN.(BUFFER,UNIT)    ;get a packet and waits for t
  43.          O'E                              ;prompt
  44.             STATUS=KGETLIN.(BUFFER,UNIT)       ;get a packet without waitin
  45.          E'L                             ;for a prompt
  46. ;        E'E HEXDMP.(0,45,0,BUFFER)
  47.  
  48.          COUNT=0
  49.  
  50. ;        skips all other characters until we see one with a SOH in it
  51.  
  52.          W'E ((BUFFER(COUNT).NE.SOH).AND.(BUFFER(COUNT).NE.EOS))
  53.             COUNT=COUNT+1                  ;wait for a SOH or EOS
  54.          E'W
  55.          W'R (BUFFER(COUNT).EQ.SOH)      ;we got the SOH
  56.  
  57. ;           we got a line that begins with a SOH
  58.  
  59.             K=COUNT+1
  60.             CHKSUM=BUFFER(K)
  61.             LEN=UNCHAR.(BUFFER(K))-3        ;get the length of the packet
  62.  
  63.             K=K+1
  64.             CHKSUM=CHKSUM+BUFFER(K)
  65.             NUM=UNCHAR.(BUFFER(K))          ;get the sequence number of
  66.                                            ;the frame packet
  67.             K=K+1
  68.             XTYPE=BUFFER(K)                ;get the data type
  69.             CHKSUM=CHKSUM+BUFFER(K)
  70.             K=K+1
  71.  
  72. ;           get the data
  73.  
  74. ;           ZERO OUT THE XDATA ARRAY
  75. ;            E'E FILL.(132,0,XDATA)
  76.  
  77.             T'H L1 FOR J=0, 1, J .GE. LEN
  78.                XDATA(J)=BUFFER(K)
  79.                CHKSUM=CHKSUM+BUFFER(K)
  80.                K=K+1
  81. L1          C'E
  82.             COUNT = J
  83.  
  84.             XDATA(COUNT+1)=EOS
  85.             T=BUFFER(K)
  86.  
  87. ;           calculate the checksum of the incoming packet
  88.  
  89.             TV1=CHKSUM.LAND.192
  90.             TV2=TV1/64
  91.             TV3=CHKSUM+TV2
  92.             CHKSUM=TV3.LAND.63
  93.  
  94. ;           does the checksum matches
  95.  
  96.             W'R (CHKSUM.NE.UNCHAR.(T))
  97. #              E'E TYPEMSG.($ BAD CHECKSUM !$)
  98.                LCLSTATE=BAD                   ;bad checksum
  99.                F'N LCLSTATE
  100.  
  101.             O'E
  102.                 LCLSTATE=XTYPE
  103.                 F'N LCLSTATE
  104.             E'L
  105.          E'L
  106.  
  107. ;        we got the EOS, the packet has no SOH, read another one
  108.  
  109.          GAPTRY=GAPTRY+1
  110.       E'W
  111. #     E'E TYPEMSG.($ SOME OTHER BAD STATE !$)
  112.       LCLSTATE=BAD
  113.       F'N LCLSTATE
  114.  
  115. WAYOUT  F'N BAD     ; wayout of a deadlock situation
  116.  
  117.       E'N
  118.