home *** CD-ROM | disk | FTP | other *** search
/ ftp.uni-stuttgart.de/pub/systems/acorn/ / Acorn.tar / Acorn / acornet / dev / forth / forthmacs / serial / serial~ / !Forthmacs.lib.connect next >
Text File  |  1995-01-26  |  2KB  |  70 lines

  1. \ Virtual terminal program.
  2. \ Edit  line-modes  to reflect your serial line configuration.
  3. \
  4. \ line-modes    initializes the serial line.
  5. \ connect       go into virtual terminal mode.
  6. \
  7. \ Type  ESC CR   to get back to Forth.
  8.  
  9. only forth also definitions
  10. \ needs modem  fload ??environment??\modem.fth before this
  11.  
  12. only forth also  modem also definitions decimal
  13.  
  14. 27 constant escchar
  15.  2 constant connect#channel
  16. variable help?  help? on
  17.  
  18. : >modem  ( -- )
  19.     help? @ if ??cr ." ascii terminal connection ... ESC quits" cr then
  20.     multi
  21.     begin    begin    key dup escchar <>
  22.         while    m-emit
  23.         repeat drop
  24.         help? @ if ??cr ." CR quits terminal connection" cr then
  25.         key upc
  26.         case
  27.            carret  of    ??cr exit    endof
  28.            dup m-emit           
  29.         endcase
  30.     again ;
  31. : ascii-emit    ( char -- )
  32.     single dup bl <
  33.     if    case
  34.         d# 00 of            endof    \ nothing
  35.         d# 07 of    beep        endof    \ bell
  36.         d# 08 of    1 backspaces    endof    \ bs
  37.         d# 09 of    1 .tab        endof    \ tab
  38.         d# 10 of    down        endof    \ lf
  39.         d# 11 of    ??cr cr        endof    \ vt
  40.         d# 12 of    erase-screen    endof    \ ff
  41.         d# 13 of    at? drop 0 at    endof    \ cr
  42.         h# 11 of    beep        endof
  43.         h# 18 of    delete-line    endof    \ can
  44.             dup dark ascii @ + emit  light
  45.                 endcase
  46.     else    emit
  47.     then    multi ;
  48.  
  49. \ Listen to the modem and send the characters to the display
  50. forth definitions
  51. task: listener
  52. : modem>    ( -- )
  53.     listener activate multi
  54.     connect#channel use-channel
  55.     begin m-key ascii-emit again ;
  56. : line-modes    ( -- )
  57.     9600-baud 1-stop-bit 8-bits no-parity no-flow-control  set-line ;
  58.  
  59. defer log-in    ' noop is log-in
  60. : connect    ( -- )
  61.     connect#channel m-open
  62.     multi line-modes modem>
  63.     log-in >modem
  64.     listener sleep m-close ;
  65.  
  66. : (test
  67.     p" ATZ0 M0 V1 X5 &V1" m-". m-cr
  68.     p" OK" d# 4000 string-wait if beep then ;
  69. : test    ['] (test is log-in ;
  70.