home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
computervision
/
kermit.rpack
< prev
next >
Wrap
Text File
|
1987-02-18
|
3KB
|
118 lines
; 16 jly 85 esj converted
;;;;;; RPACK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
E'F A:S(NWLS)
E'O RPACK.(LEN,NUM,XDATA)
; read a packet from other KERMIT
/INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERCOM
/INCLUDE BYU.PROG.KERMIT.SYM.EQU.KERDEF
I'R LEN,NUM,UNIT
I'R XDATA(1)
I'R COUNT,STATUS,J,K,T
I'R TV1,TV2,TV3, LCLSTATE
I'R BUFFER(132),CHKSUM,XTYPE,GAPTRY,MGAPTRY
G'L TIMEOUT(1) ; temp for lblset call
;------------------------------< debugging stubs >----------------------------
# LEN = 0
# NUM = N
# XDATA = 0
# E'E TGETCH.(XTYPE,$SD$)
# E'E FILL.(132,0,XDATA)
# F'N XTYPE
;------------------------------< real code >----------------------------
; setup lblset for handling deadlock condition
E'E LBLSET.(TIMEOUT, WAYOUT)
UNIT=RMTDEV ;this is the input channel to
;a packet from
GAPTRY=1
MGAPTRY=2
CHKSUM=0
; read me a packet that begins with a SOH and ends with MYEOL
W'E (GAPTRY.LE.MGAPTRY)
W'R (IBMON.EQ.YES)
STATUS=IBMGETLN.(BUFFER,UNIT) ;get a packet and waits for t
O'E ;prompt
STATUS=KGETLIN.(BUFFER,UNIT) ;get a packet without waitin
E'L ;for a prompt
; E'E HEXDMP.(0,45,0,BUFFER)
COUNT=0
; skips all other characters until we see one with a SOH in it
W'E ((BUFFER(COUNT).NE.SOH).AND.(BUFFER(COUNT).NE.EOS))
COUNT=COUNT+1 ;wait for a SOH or EOS
E'W
W'R (BUFFER(COUNT).EQ.SOH) ;we got the SOH
; we got a line that begins with a SOH
K=COUNT+1
CHKSUM=BUFFER(K)
LEN=UNCHAR.(BUFFER(K))-3 ;get the length of the packet
K=K+1
CHKSUM=CHKSUM+BUFFER(K)
NUM=UNCHAR.(BUFFER(K)) ;get the sequence number of
;the frame packet
K=K+1
XTYPE=BUFFER(K) ;get the data type
CHKSUM=CHKSUM+BUFFER(K)
K=K+1
; get the data
; ZERO OUT THE XDATA ARRAY
; E'E FILL.(132,0,XDATA)
T'H L1 FOR J=0, 1, J .GE. LEN
XDATA(J)=BUFFER(K)
CHKSUM=CHKSUM+BUFFER(K)
K=K+1
L1 C'E
COUNT = J
XDATA(COUNT+1)=EOS
T=BUFFER(K)
; calculate the checksum of the incoming packet
TV1=CHKSUM.LAND.192
TV2=TV1/64
TV3=CHKSUM+TV2
CHKSUM=TV3.LAND.63
; does the checksum matches
W'R (CHKSUM.NE.UNCHAR.(T))
# E'E TYPEMSG.($ BAD CHECKSUM !$)
LCLSTATE=BAD ;bad checksum
F'N LCLSTATE
O'E
LCLSTATE=XTYPE
F'N LCLSTATE
E'L
E'L
; we got the EOS, the packet has no SOH, read another one
GAPTRY=GAPTRY+1
E'W
# E'E TYPEMSG.($ SOME OTHER BAD STATE !$)
LCLSTATE=BAD
F'N LCLSTATE
WAYOUT F'N BAD ; wayout of a deadlock situation
E'N