home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / mskscripts / t3000.kds < prev   
Text File  |  2020-01-01  |  6KB  |  177 lines

  1. ; FILE T3000.SCR
  2. ; An MS-DOS Kermit script program for dialing the Telebit T3000 and similar
  3. ; modems (e.g. T1600, QBlazer), to be used with MS-DOS Kermit 3.15 or later.
  4. ; The modem is set for RTS/CTS flow control, fixed interface speed, and to
  5. ; negotiate highest modulation, error correction, compression, and all types
  6. ; of fallback.
  7. ;
  8. ; Authors: C. Gianone & F. da Cruz, Columbia U, December 1996
  9. ;
  10. ; To use: SET MODEM=T3000 (in DOS, before starting Kermit or in AUTOEXEC.BAT)
  11. ; or:     SET MODEM T3000 (in Kermit, or in MSCUSTOM.INI)
  12. ; and:    Make sure Kermit has executed the standard MSKERMIT.INI file,
  13. ;         and then DIAL the desired number.
  14. ;
  15. ; Variables - define these prior to dialing if desired; they can be either
  16. ; Kermit variables or DOS environment variables:
  17. ;   DIALPORT    - COM port to use for dialing (COM1, COM2, etc)
  18. ;   DIALSPEED   - Speed for dialing (57600 by default)
  19. ;   DIALMETHOD  - TONE or PULSE (modem's default method is used by default)
  20. ;   DIALRETRIES - Maximum times to redial the call (default 5)
  21. ;   DIALTIMEOUT - How long to wait for result from modem (default 90 seconds)
  22. ;
  23. if < VERSION 315 stop 1 MS-DOS Kermit 3.15 or later required.
  24. def ERRFAIL echo \%1, forward FAIL
  25. def CHKOK input 3 OK, if fail stop 1 \%1
  26.  
  27. local __dm __parity atok max_speed s51 \%i \%j
  28.  
  29. define max_speed 57600        ; T3000 interface speed
  30. define s51 7            ; T3000 S51 register setting for this speed
  31.  
  32. define ATOK {
  33.     if not def \%1 assign \%1 \v(speed)
  34.     set speed \%1
  35.     echo Trying \%1...
  36.     output \B
  37.     output \17
  38.     output ATQ0V1\13
  39.     input 3 OK
  40.     if success end 0
  41.     end 1
  42. }
  43.  
  44. set carrier off                 ; Don't require carrier during dialing.
  45. set input echo on        ; So we can watch what happens.
  46. set input timeout proceed       ; Allow IF SUCCESS, IF FAILURE.
  47. set input case ignore        ; Use caseless string comparisons
  48.  
  49. :PORT
  50. if not def DIALPORT asg DIALPORT \$(DIALPORT)
  51. if not def DIALPORT forward SPEED
  52. set port \m(DIALPORT)
  53. if success forward SPEED
  54. echo SET PORT \m(DIALPORT) failed 
  55. end 1
  56.  
  57. :SPEED
  58. asg __parity \v(parity)        ; Save parity setting
  59. set parity none            ; Switch to none while dialing
  60. set flow none            ; Avoid flow control deadlocks
  61. hangup                ; Begin by dropping DTR
  62.  
  63. ; Dial method, retry limit, and timeout...
  64.  
  65. xif numeric \fsubstr(\%1,1,1) {
  66.     if eq "\m(DIALMETHOD)" "TONE" asg __dm T
  67.     if eq "\m(DIALMETHOD)" "PULSE" asg __dm P
  68. }
  69. if not def DIALRETRIES asg DIALRETRIES \$(DIALRETRIES)
  70. if not def DIALRETRIES asg DIALRETRIES 5
  71.  
  72. if not def DIALTIMEOUT asg DIALTIMEOUT \$(DIALTIMEOUT)
  73. if not def DIALTIMEOUT asg DIALTIMEOUT 90
  74.  
  75. ; Begin the modem dialog...
  76.  
  77. echo Configuring Telebit T3000 on \v(line)...
  78.  
  79. clear input            ; Clear input buffer
  80. clear device
  81. if > \v(speed) \m(max_speed) set speed \m(max_speed)
  82. atok            ; Try to connect at current speed, whatever it is.
  83. if success forward gotok
  84. atok 9600         ; Try to connect at 9600.
  85. if success forward gotok
  86. atok 19200        ; 19200...
  87. if success forward gotok
  88. atok 2400        ; etc...
  89. if success forward gotok
  90. atok 38400        ; ...
  91. if success forward gotok
  92. atok 57600        ; Last resort for T3000.
  93. if fail stop 1 Can't get modem's attention
  94.  
  95. :GOTOK
  96. output ATE1&C1&D2S59=15X12\13    ; Set echoing, result codes, etc.
  97. chkok {Can't initialize modem}
  98. output ATS51=\m(s51)\13
  99. chkok {Can't fix interface speed}
  100. set speed \m(max_speed)
  101.  
  102. for \%i 1 3 1 {
  103.     msleep 500
  104.     output AT\13
  105.     input 3 OK
  106.     if success break
  107. }
  108. if > \%i 3 stop 1 Can't communicate with modem at \m(max_speed)
  109.  
  110. output AT S58=2 S68=255 &R3\13    ; Tell modem to use RTS/CTS
  111. chkok {Can't enable RTS/CTS}
  112. wait 5 cts
  113. if fail errfail {Modem is not asserting CTS!}
  114. set flow rts/cts        ; Tell Kermit to use RTS/CTS
  115. output AT S50=0 S94=1\13    ; Enable modulation speed negotiation
  116. chkok {Can't enable modulation speed negotiation}
  117. output AT S60=0 S61=0 S63=0\13    ; Make modem ignore break
  118. chkok {Can't be transparent to BREAK}
  119. output AT S180=2 S181=1 S190=1\13 ; Enable error correction & compression
  120. chkok {Can't enable compression EC and fallback}
  121.  
  122. mpause 500
  123. clear input            ; Clear INPUT buffer.
  124. clear device            ; Clear device buffer.
  125.  
  126. echo Dialing \%1 on \v(line) at \v(speed) bps, wait...
  127. echo
  128.  
  129. for \%i 1 \m(DIALRETRIES) 1 {    ; Redial loop
  130.     xif > \%i 1 {
  131.         echo Redialing...       ; Message for redialing
  132.         hangup            ; Hang up first
  133.     }
  134.     pause 1            ; Wait a sec for modem to settle
  135.     output ATD\m(__dm)\%1\13    ; Dial the number.
  136.     for \%j 1 10 1 {
  137.         minput \m(DIALTIMEOUT) -
  138.           CONNECT BUSY ERROR {NO CARRIER} {NO ANSWER} {NO DIALTONE} RRING RING
  139.         xif fail { echo Call timed out, hangup, out \13, continue }
  140.         if not = \v(minput) 7 break
  141.     }
  142.     switch \v(minput) {
  143.       :1, forward done
  144.       :2, Echo Line is busy - will dial again in 30 seconds.
  145.           echo Press any key to cancel...
  146.           output \13
  147.           pause 30
  148.           if fail errfail Canceled
  149.           break
  150.       :3, errfail {Dialing command error}
  151.       :4, errfail {Call failed - no carrier}
  152.       :5, errfail {No answer - try again later}
  153.       :6, errfail {No dialtone - is your modem connected to the phone line?}
  154.       :7, errfail {Call failed - too many rings}
  155.       :8, errfail {Call failed - your phone is ringing}
  156.       :default, break
  157.     }    
  158. }
  159. errfail {It never answers!  I give up.} ; Too many tries.
  160.  
  161. :DONE                           ; Connected.
  162. echo \7                         ; Celebrate with a beep.
  163. set carrier on            ; Require carrier from now on.
  164. set parity \m(__parity)        ; Restore host parity setting
  165. undef errfail            ; Erase local macro definitions...
  166. end 0                ; Finished, return success code.
  167.  
  168. :FAIL
  169. undef errfail            ; Erase local macro definitions...
  170. set carrier off            ; Let them reconnect to see what's up.
  171. hangup
  172. end 1                ; Return failure code.
  173.  
  174. ; End of T3000.SCR
  175.