# TRANS - Transmit a line of the file to the remote. Cadnet V. 3.0. # # Calling Sequence: # call trans (line, linlen, ids) # # Where: # line - the line of data to be transmitted # linlen - length of line # ids - status code # # Note: # In the following notes, the string transmitted to the remote is listed # first, followed by the response string sent by the remote back to XMT. # # The format of a data line representing a logical record of length 0 is: # # [logical record length] # # The format of a data line not holding the end of the logical record is: # [data subsequences] # # # The format of a data line holding the end of the logical record is: # [data subsequences] # [logical record length] # subroutine trans (line, linlen, ids) byte line (transmissionlength) integer*2 linlen, ids byte sndlin (1024), respon (responselength) integer*2 icount, ihigh, low, lnsize, trsize # Encode and send the record to the remote. if (linlen == 0) { # zero length logical record # Send data line to remote write (rem, 100) null # Wait for and decode response string from remote. call readln (respon, icount) trsize = 2 + oct100 ihigh = respon (3) low = respon (4) lnsize = (ihigh - oct100) * oct100 + (low - oct100) if ((icount != 4) \ (respon(2) != trsize) \ (linlen != lnsize)) { # Illegal response from remote. ids = -1 write (err, 101) return } return } else { # non-zero length logical record # Translate the logical record into the appropriate subsequences j = 1 # j next position in sndlin (transmit line) do i = 1, linlen { if ((line (i) >= null) & (line (i) < space)) { # Control character # Send ' ' sndline (j) = enq sndline (j + 1) = line (i) + oct100 j = j + 2 } else if ((line (i) >= space) & (line (i) < oct200)) { # Printing character # Send '' sndlin (j) = line (i) j = j + 1 } else if ((line (i) >= oct200) & (line (i) < oct237)) { # Negative character (lower values) # Send ' ' sndlin (j) = bs sndlin (j + 1) = (line (i) & oct177) \ oct100 j = j + 2 } else if ((line (i) >= oct237) & (line (i) < oct400)) { # Negative character (higher values) # Send ' ' sndlin (j) = bel sndlin (j + 1) = line (i) & oct177 j = j + 2 } else { # Logic error: unrecognized character write (error, 103) line (i) call exst (4) } } # Write logical record as a set of data lines of length linsiz. i = 1 while (j - i > linsiz) { # Data line doesn't contain end of logical record # Send data line to remote write (rem, 100) (sndlin (ii), ii=i,i+linsiz-1), so i = i + linsiz # Wait for and decode response string from remote. call readln (respon, icount) if ((icount != 2) \ (respon (2) != linsiz + 1 + oct100)) { # Illegal response from remote. ids = - 1 write (err, 101) return } } # Write rest of logical record as a data line of length < linsiz # Send data line to remote write (rem, 100) (sndlin (ii), ii=i,j-1) # Wait for and decode response string from remote. call readln (respon, icount) trsize = j - i + oct100 ihigh = respon (3) low = respon (4) lnsize = (ihigh - oct100) * oct100 + (low - oct100) if ((icount != 4) \ (respon(2) != trsize) \ (linlen != lnsize)) { # Illegal response from remote. ids = -1 write (err, 101) return } return } 100 format (x, 251a1) 101 format (' remote not receiving properly, aborting communiction') 103 format (' Unrecognized character in subroutine TRANS:', i5) end