# rpack - receive a packet from the remote system # integer function rpack(len,num,xdata) include ratdef include kerdef include kercom # integer len,num,ch integer kgetlin character xdata(1) # integer i,count,status,unchar,j,k,idc1,t1,ibyte integer xcount,temp,mailid character chksum,t,xtype,buffer(MAXLINE) # idc1=03400k #the bell chksum=0 if(ibm==TRUE)xcount=8 else xcount=2 i=1 ch=rmtinfd while(i<=xcount){ # we are talking to CMS, get a packet, but also wait for the DC1 # before returning back to here if(ibm==TRUE)status=ibmgetlin(buffer,ch) else status=getlin(buffer,ch) # else we are not talking to CMS, just get a packet, no need to wait count=1 # skip all other character until you see a SOH which is a numeric 1 while((buffer(count)^=SOH)&(buffer(count)^=EOS))count=count+1 if(buffer(count)==SOH){ k=count+1 # get the length chksum=buffer(k) len=unchar(buffer(k))-3 k=k+1 # get the sequence of the frame packet chksum=chksum+buffer(k) num=unchar(buffer(k)) k=k+1 # get the data type xtype=buffer(k) chksum=chksum+buffer(k) k=k+1 # get the data for(j=1;j<=len;j=j+1){ xdata(j)=buffer(k) chksum=chksum+buffer(k) k=k+1 count=j } xdata(count+1)=0 t=buffer(k) # calculate the checksum of the incoming packet chksum=(chksum+(chksum&192)/64)&63 # is my checksum the same as the one send from the other KERMIT if(chksum!=unchar(t)){ rpack=FALSE return } rpack=xtype return } i=i+1 } rpack=FALSE return end