$compact $optimize(3) conn$module: do; /* CONNECT: Establish a "virtual terminal" connection through a */ /* specified serial i/o port. */ $INCLUDE(:INC:LTKSEL.LIT) declare status word external; declare (in$conn,out$conn) token external; declare (ci$conn,co$conn) token external; declare debug byte external; declare break literally '1DH'; declare ctly literally '19H'; /* ^C by typing ^]^Y */ declare ctlq literally '11H'; declare ctls literally '13H'; declare ctlc literally '03H'; declare true literally '0FFH'; declare false literally '00H'; declare null literally '0'; declare cr literally '0DH'; declare lf literally '0AH'; declare crlf literally 'cr,lf,null'; $INCLUDE(:INC:UREAD.EXT) $INCLUDE(:INC:UWRITE.EXT) declare iobuff(1024) byte public; check$error: procedure(fatal) byte external; declare fatal byte; end check$error; print: procedure(msg) external; declare msg pointer; end print; newline: procedure external; end newline; sbreak: procedure byte external; end sbreak; send$setup: procedure external; end send$setup; connect: procedure public; declare (c,i,qbreak) byte; qbreak=false; if debug then do; call print(@('connecting to serial port $')); /* something about which terminal line */ call newline; call print(@('to exit CONNECT mode type ^] C$')); call newline; end; do while (1); c=DQ$READ(ci$conn,@iobuff,80,@status); if check$error(0) then return; loop: if c>0 then do; if qbreak then do; qbreak=false; if iobuff(0)='C' then return; else if iobuff(0)='c' then return; else if iobuff(0)=ctly then iobuff(0)=ctlc; else if iobuff(0)='0' then iobuff(0)=null; else if iobuff(0)='?' then do; call print(@('Special characters are: B,C,?,^Y,0',crlf)); c=c-1; if i>0 then call movb(@iobuff(1),@iobuff(0),c); goto loop; end; else if (iobuff(0)='B' or iobuff(0)='b') then do; call send$setup; i=sbreak; c=c-1; if i>0 then call movb(@iobuff(1),@iobuff(0),c); goto loop; end; /* add check for other characters.....otherwise ignore */ end; do i=0 to c-1; if iobuff(i)=break then do; if i>0 then do; call DQ$WRITE(out$conn,@iobuff,i,@status); if check$error(0) then return; end; c=c-i-1; if c>0 then call movb(@iobuff(i+1),@iobuff,c); qbreak=true; goto loop; end; end; call DQ$WRITE(out$conn,@iobuff,c,@status); if check$error(0) then return; end; c=DQ$READ(in$conn,@iobuff,40,@status); if check$error(0) then return; if c>0 then do; call DQ$WRITE(co$conn,@iobuff,c,@status); if check$error(0) then return; end; end; end connect; end conn$module;