[628] | 1 | XTKERM3 ;SF/RWF - Kermit protocol Send/Receive packet ;8/19/92 11:19 ;
|
---|
| 2 | ;;7.3;TOOLKIT;;Apr 25, 1995
|
---|
| 3 | ;Packet <Mark><Len><Seq><type><data><Check><Eol>
|
---|
| 4 | A ;Setup <Maxl><Timeout><Npad><Padc><Eol><Qctrl><Qbin>
|
---|
| 5 | RPACK ;Receive a packet
|
---|
| 6 | S XTKERR=0,XTKR("PT")="A",XTKR("PN")=99,XTKRDAT="",XTKRPK="" F I=0:0 R A:XTKR("TO") G:'$T RTO X XTKR("TRMRD") Q:Y=XTKR("SOH")
|
---|
| 7 | R XTKRPK:XTKR("TO") G RTO:'$T X XTKR("TRMRD") I Y=XTKR("SOH") S XTKERR="1 SOH in record" Q
|
---|
| 8 | I $D(XTKDEBUG) S XTKDEBUG=XTKDEBUG+1,^TMP("XTKERM",$J,XTKDEBUG)="R:"_XTKRPK
|
---|
| 9 | RCK S L=$A(XTKRPK)-32,XTKR("PN")=$A(XTKRPK,2)-32,XTKR("PT")=$E(XTKRPK,3),XTKRDAT=$E(XTKRPK,4,L) I $L(XTKRPK)-1-L S XTKERR="3 Size error" Q
|
---|
| 10 | S C=0 F I=1:1:L S C=C+$A(XTKRPK,I)
|
---|
| 11 | S C=C\64#4+C#64 I $A(XTKRPK,L+1)-32-C S XTKERR="4 Bad checksum"
|
---|
| 12 | Q
|
---|
| 13 | RTO S XTKERR="2 Receiver timeout" Q
|
---|
| 14 | SPACK S XTKSPK=$C($L(XTKSDAT)+35)_$C(XTKS("PN")+32)_XTKS("PT")_XTKSDAT,C=0 F I=1:1:$L(XTKSPK) S C=C+$A(XTKSPK,I)
|
---|
| 15 | S C=C\64#4+C#64,XTKSPK=$C(XTKS("SOH"))_XTKSPK_$C(C+32)
|
---|
| 16 | I $D(XTKDEBUG) S XTKDEBUG=XTKDEBUG+1,^TMP("XTKERM",$J,XTKDEBUG)="S:"_XTKSPK
|
---|
| 17 | I XTKS("NPAD")>0 W $TR($J("",XTKS("NPAD"))," ",XTKS("PADC")) ;Send pad char.
|
---|
| 18 | W XTKSPK,$C(XTKS("EOL"))
|
---|
| 19 | Q
|
---|