KLASXMIT ;RTM;MSM CPU<->CPU TRANSMIT; [ 08/12/92 3:25 PM ]
; COPYRIGHT MICRONETICS DESIGN CORP. @1985
; If you need to send $C(1) or $C(2) through as data,
; pick another character and change the line INIT+1.
; %HT = wait time for READs (0 or 1)
; %DT = # of READs from IO device since last terminal read
; %DC = # iterations thru fast loop with no data received
; %RS = 1 if recording, 0 if not
S %INT=0 K %MSM ; $D(%MSM) flag for calling from %TRANS
S $ZT="ERROR^%XMIT"
GO S %HT=0,%DT=0,%DC=0,%RS=0 G:%INT INIT
W !?10,$P($P($ZV,","),"-")," - Transmission Utility"
ASK R !!,"I/O PORT? > ",%IO G:%IO="" EXIT G:%IO?1"^".E EXIT I %IO?1"?".E D QUE G ASK
I $I=%IO!'%IO W !!,"Cannot select your own device.",*7 G ASK
S $ZT="NOPEN^%XMIT"
B 1 O %IO::0 E W *7,"..line in use..waiting.." O %IO W "ready"
S $ZT="ERROR^%XMIT"
U %IO I $ZB($ZA,2,1) U 0 W !,"Device ",%IO," is an output only device.",*7 G ASK
INIT U 0 S %ESC=$ZB($ZA,64,1) ; save escape processing status
S %EXIT=$C(1),%RECORD=$C(2)
; Turn off pass-all, esc processing, & tab control. Set terminators
OPEN U %IO:(0::::#001001:#800040:::$C(3,8,13,21,24,27,127))
U 0:(0::::#000001:#800040:::$C(3,8,13,15,18,21,24,27,127)) W !
TERM ;
U 0 R %X:%HT
S %CR=$ZB ; get READ terminator
G:$E(%X)=%EXIT EXIT D:$E(%X)=%RECORD
.D @$S(%RS:"HALT",1:"RECORD") S %X=$E(%X,2,$L(%X)) Q
U %IO W:$L(%X) %X W:$T $C(%CR) S:$L(%X)!$T %DC=0,%HT=0 S %DT=0
PORT ;
U %IO R %Y:%HT G:%INT&(%Y=$C(1)) EXIT S %CR=$ZB U 0 W:$L(%Y) %Y W:$T $C(%CR) S:$L(%Y)!$T %DC=0,%HT=0,%DT=%DT+1
S:$L(%Y)&%RS %XS=%XS_%Y I $T,%RS S ^XMIT(%XN,%XE)=%XS,%XE=%XE+1,%XS=""
PORT1 I %DT>20 G TERM ; heavy incoming data, force check of CRT
G TERM:$L(%X),PORT:$L(%Y)
S %DC=%DC+1 G:%DC<500 TERM S %HT=1 ; READ timeout 1, goto slow mode
TERMWAIT ; TERMWAIT and PORTWAIT handle periods in which no data has been
; received from either side for %DC iterations through the
; TERM & PORT loop.
U 0 R %X#1:%HT E G PORTWAIT
G:%X=%EXIT EXIT
I %X=%RECORD D @$S(%RS:"HALT",1:"RECORD") S (%DC,%DT,%HT)=0 G TERM
S %CR=$ZB
U %IO W %X W:'$L(%X) $C(%CR) S (%DC,%DT,%HT)=0 G TERM
PORTWAIT ;
U %IO R %Y#1:%HT E G TERMWAIT
G:%INT&(%Y=%EXIT) EXIT ; %TRANS rtn or gbl selection finished
S %CR=$ZB
U 0 W %Y W:'$L(%Y) $C(%CR) S (%DC,%DT,%HT)=0
; If recording...
S:$L(%Y)&%RS %XS=%XS_%Y ; add to captured string
; or terminate & file captured string
I '$L(%Y),%RS S ^XMIT(%XN,%XE)=%XS,%XE=%XE+1,%XS=""
G PORT
EXIT ;
D:%RS HALT I $D(%ESC),%ESC U 0:(::::64)
K %ESC,%X,%Y,%RS,%XN,%XE,%XS,%DC,%DT,%HT,%CR,%EXIT,%RECORD
U:(%IO?.N)&(%IO'="") %IO:(:::::#001001:::$C(13,27))
U 0:(:::::#000001:::$C(13,27))
I %INT!$D(%MSM) B 1 K %INT Q ; return to %TRANS
I %IO?.N&(%IO'="") C %IO U 0 K %IO,%INT
W:'$F($ZE,"<DSCON>") !,"Transmission Complete",!!
Q
RECORD ;
S:'$D(^XMIT) ^XMIT(0)=1
S %XN=^XMIT(0),^XMIT(0)=%XN+1,%RS=1,%XS="",%XE=1,%X=$E(%X,2,999),^XMIT(%XN)=$H
U 0 W !!,"Recording Started in ^XMIT(",%XN,",1)",!
Q
HALT ;
S:$L(%XS) ^XMIT(%XN,%XE)=%XS S %RS=0
U 0 W !!,"Recording halted, last node is ^XMIT(",%XN,",",%XE,")",!!
Q
NOPEN S %IO="" ; avoid <NOPEN> on <INRPT>
ERROR ;
I $F($ZE,"<MXSTR>") F %XE=%XE:1 G:%XS="" ERROR1 S ^XMIT(%XN,%XE)=$E(%XS,1,255),%XS=$E(%XS,256,9999)
I $F($ZE,"<INRPT>") U 0 W !!,"...Aborted." D EXIT V 0:$J:$ZB($V(0,$J,2),#0400,7):2
I $F($ZE,"<DSCON>") DO:$I'=$P D EXIT V 0:$J:$ZB($V(0,$J,2),#0400,7):2
.U 0 W !!,"...Disconnected."
ZQ
ERROR1 S $ZT="ERROR^%XMIT" G PORT1 ; resume after <MXSTR>
INT ;FROM TRANSFER UTILS
S %INT=1 B 0 G GO
;
QUE W !! F %IO=1:1 S %X=$T(TEXT+%IO) Q:%X="" W $P(%X,";",2),!
Q
TEXT ;
;Enter the port number to be used for the transmission.
;While the transmission is in progress, all characters except CTRL/A
;and CTRL/B will be passed through to the port.
;Use CTRL/B to start or stop recording of the information in the XMIT
;global, and CTRL/A to exit the program.
KLASXMIT ;RTM;MSM CPU<->CPU TRANSMIT; [ 08/12/92 3:25 PM ]
+1 ; COPYRIGHT MICRONETICS DESIGN CORP. @1985
+2 ; If you need to send $C(1) or $C(2) through as data,
+3 ; pick another character and change the line INIT+1.
+4 ; %HT = wait time for READs (0 or 1)
+5 ; %DT = # of READs from IO device since last terminal read
+6 ; %DC = # iterations thru fast loop with no data received
+7 ; %RS = 1 if recording, 0 if not
+8 ; $D(%MSM) flag for calling from %TRANS
SET %INT=0
KILL %MSM
+9 SET $ZT="ERROR^%XMIT"
GO SET %HT=0
SET %DT=0
SET %DC=0
SET %RS=0
IF %INT
GOTO INIT
+1 WRITE !?10,$PIECE($PIECE($ZV,","),"-")," - Transmission Utility"
ASK READ !!,"I/O PORT? > ",%IO
IF %IO=""
GOTO EXIT
IF %IO?1"^".E
GOTO EXIT
IF %IO?1"?".E
DO QUE
GOTO ASK
+1 IF $IO=%IO!'%IO
WRITE !!,"Cannot select your own device.",*7
GOTO ASK
+2 SET $ZT="NOPEN^%XMIT"
+3 BREAK 1
OPEN %IO::0
IF '$TEST
WRITE *7,"..line in use..waiting.."
OPEN %IO
WRITE "ready"
+4 SET $ZT="ERROR^%XMIT"
+5 USE %IO
IF $ZB($ZA,2,1)
USE 0
WRITE !,"Device ",%IO," is an output only device.",*7
GOTO ASK
INIT ; save escape processing status
USE 0
SET %ESC=$ZB($ZA,64,1)
+1 SET %EXIT=$CHAR(1)
SET %RECORD=$CHAR(2)
+2 ; Turn off pass-all, esc processing, & tab control. Set terminators
OPEN USE %IO:(0::::#001001:#800040:::$CHAR(3,8,13,21,24,27,127))
+1 USE 0:(0::::#000001:#800040:::$CHAR(3,8,13,15,18,21,24,27,127))
WRITE !
TERM ;
+1 USE 0
READ %X:%HT
+2 ; get READ terminator
SET %CR=$ZB
+3 IF $EXTRACT(%X)=%EXIT
GOTO EXIT
IF $EXTRACT(%X)=%RECORD
Begin DoDot:1
+4 DO @$SELECT(%RS:"HALT",1:"RECORD")
SET %X=$EXTRACT(%X,2,$LENGTH(%X))
QUIT
End DoDot:1
+5 USE %IO
IF $LENGTH(%X)
WRITE %X
IF $TEST
WRITE $CHAR(%CR)
IF $LENGTH(%X)!$TEST
SET %DC=0
SET %HT=0
SET %DT=0
PORT ;
+1 USE %IO
READ %Y:%HT
IF %INT&(%Y=$CHAR(1))
GOTO EXIT
SET %CR=$ZB
USE 0
IF $LENGTH(%Y)
WRITE %Y
IF $TEST
WRITE $CHAR(%CR)
IF $LENGTH(%Y)!$TEST
SET %DC=0
SET %HT=0
SET %DT=%DT+1
+2 IF $LENGTH(%Y)&%RS
SET %XS=%XS_%Y
IF $TEST
IF %RS
SET ^XMIT(%XN,%XE)=%XS
SET %XE=%XE+1
SET %XS=""
PORT1 ; heavy incoming data, force check of CRT
IF %DT>20
GOTO TERM
+1 IF $LENGTH(%X)
GOTO TERM
IF $LENGTH(%Y)
GOTO PORT
+2 ; READ timeout 1, goto slow mode
SET %DC=%DC+1
IF %DC<500
GOTO TERM
SET %HT=1
TERMWAIT ; TERMWAIT and PORTWAIT handle periods in which no data has been
+1 ; received from either side for %DC iterations through the
+2 ; TERM & PORT loop.
+3 USE 0
READ %X#1:%HT
IF '$TEST
GOTO PORTWAIT
+4 IF %X=%EXIT
GOTO EXIT
+5 IF %X=%RECORD
DO @$SELECT(%RS:"HALT",1:"RECORD")
SET (%DC,%DT,%HT)=0
GOTO TERM
+6 SET %CR=$ZB
+7 USE %IO
WRITE %X
IF '$LENGTH(%X)
WRITE $CHAR(%CR)
SET (%DC,%DT,%HT)=0
GOTO TERM
PORTWAIT ;
+1 USE %IO
READ %Y#1:%HT
IF '$TEST
GOTO TERMWAIT
+2 ; %TRANS rtn or gbl selection finished
IF %INT&(%Y=%EXIT)
GOTO EXIT
+3 SET %CR=$ZB
+4 USE 0
WRITE %Y
IF '$LENGTH(%Y)
WRITE $CHAR(%CR)
SET (%DC,%DT,%HT)=0
+5 ; If recording...
+6 ; add to captured string
IF $LENGTH(%Y)&%RS
SET %XS=%XS_%Y
+7 ; or terminate & file captured string
+8 IF '$LENGTH(%Y)
IF %RS
SET ^XMIT(%XN,%XE)=%XS
SET %XE=%XE+1
SET %XS=""
+9 GOTO PORT
EXIT ;
+1 IF %RS
DO HALT
IF $DATA(%ESC)
IF %ESC
USE 0:(::::64)
+2 KILL %ESC,%X,%Y,%RS,%XN,%XE,%XS,%DC,%DT,%HT,%CR,%EXIT,%RECORD
+3 IF (%IO?.N)&(%IO'="")
USE %IO:(:::::#001001:::$CHAR(13,27))
+4 USE 0:(:::::#000001:::$CHAR(13,27))
+5 ; return to %TRANS
IF %INT!$DATA(%MSM)
BREAK 1
KILL %INT
QUIT
+6 IF %IO?.N&(%IO'="")
CLOSE %IO
USE 0
KILL %IO,%INT
+7 IF '$FIND($ZE,"<DSCON>")
WRITE !,"Transmission Complete",!!
+8 QUIT
RECORD ;
+1 IF '$DATA(^XMIT)
SET ^XMIT(0)=1
+2 SET %XN=^XMIT(0)
SET ^XMIT(0)=%XN+1
SET %RS=1
SET %XS=""
SET %XE=1
SET %X=$EXTRACT(%X,2,999)
SET ^XMIT(%XN)=$HOROLOG
+3 USE 0
WRITE !!,"Recording Started in ^XMIT(",%XN,",1)",!
+4 QUIT
HALT ;
+1 IF $LENGTH(%XS)
SET ^XMIT(%XN,%XE)=%XS
SET %RS=0
+2 USE 0
WRITE !!,"Recording halted, last node is ^XMIT(",%XN,",",%XE,")",!!
+3 QUIT
NOPEN ; avoid <NOPEN> on <INRPT>
SET %IO=""
ERROR ;
+1 IF $FIND($ZE,"<MXSTR>")
FOR %XE=%XE:1
IF %XS=""
GOTO ERROR1
SET ^XMIT(%XN,%XE)=$EXTRACT(%XS,1,255)
SET %XS=$EXTRACT(%XS,256,9999)
+2 IF $FIND($ZE,"<INRPT>")
USE 0
WRITE !!,"...Aborted."
DO EXIT
VIEW 0:$JOB:$ZB($VIEW(0,$JOB,2),#0400,7):2
+3 IF $FIND($ZE,"<DSCON>")
IF $IO'=$PRINCIPAL
Begin DoDot:1
+4 USE 0
WRITE !!,"...Disconnected."
End DoDot:1
DO EXIT
VIEW 0:$JOB:$ZB($VIEW(0,$JOB,2),#0400,7):2
+5
*** ERROR ***
ERROR1 ; resume after <MXSTR>
SET $ZT="ERROR^%XMIT"
GOTO PORT1
INT ;FROM TRANSFER UTILS
+1 SET %INT=1
BREAK 0
GOTO GO
+2 ;
QUE WRITE !!
FOR %IO=1:1
SET %X=$TEXT(TEXT+%IO)
IF %X=""
QUIT
WRITE $PIECE(%X,";",2),!
+1 QUIT
TEXT ;
+1 ;Enter the port number to be used for the transmission.
+2 ;While the transmission is in progress, all characters except CTRL/A
+3 ;and CTRL/B will be passed through to the port.
+4 ;Use CTRL/B to start or stop recording of the information in the XMIT
+5 ;global, and CTRL/A to exit the program.