home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / msr313src.zip / msmt3000.scr < prev    next >
Text File  |  1993-07-12  |  7KB  |  200 lines

  1. ; FILE T3000.SCR (MSMT3000.SCR)
  2. ;
  3. ; An MS-DOS Kermit script program for dialing Telebit T3000 and similar
  4. ; modems (T1600 and QBlazer, possibly WorldBlazer), to be used with MS-DOS
  5. ; Kermit 3.11 or later.  See T3000.DOC (MSMT3000.DOC) for documentation.
  6. ;
  7. ; Authors: Christine M. Gianone, Frank da Cruz; Columbia U, June 1993
  8. def errfail echo \%1, hangup, goto fail ; Macro to handle failures.
  9. if < VERSION 312 errfail {MS-DOS Kermit 3.12 or later required.}
  10. if eq "\v(system)" "UNIX" if = \v(local) 0 stop 1 Please SET LINE first.
  11.  
  12. define chkerr if fail stop 1 \%1
  13. define chkok input 3 OK, if fail stop 1 \%1
  14.  
  15. define max_speed 57600        ; T3000 interface speed
  16. define s51 7            ; T3000 S51 register setting for this speed
  17.  
  18. ; Macro to try to get attention of modem's command processor
  19. ; at the given speed, or if no speed given, at the current speed.
  20. ;
  21. define atok -
  22.  if not def \%1 assign \%1 \v(speed), -
  23.  set speed \%1, -
  24.  echo Trying \%1..., -
  25.  output \B, -
  26.  output \17, -
  27.  output ATQ0\13, -
  28.  input 3 OK, -
  29.  if success goto gotok
  30.  
  31. set input echo on        ; So we can watch what happens.
  32. set input timeout proceed       ; Allow IF SUCCESS, IF FAILURE.
  33. set input case ignore        ; Use caseless string comparisons
  34.  
  35. set parity none        ; Avoid parity foulups
  36. set flow none        ; Avoid flow control deadlocks
  37. hangup            ; Begin by dropping DTR
  38. pause 1            ; for one second
  39.  
  40. echo Configuring Telebit T3000 on \v(line).
  41.  
  42. clear            ; Clear input buffer
  43. wait 0 DSR        ; Check modem signals that should be on
  44. chkerr {No DSR signal - check your modem and cable}
  45. wait 0 CTS
  46. chkerr {No CTS signal - check your modem and cable}
  47.  
  48. if > \v(speed) \m(max_speed) set speed \m(max_speed)
  49.  
  50. atok            ; Try to connect at current speed, whatever it is.
  51. atok 9600         ; Try to connect at 9600.
  52. atok 19200        ; 19200...
  53. atok 2400        ; etc...
  54. atok 38400        ; ...
  55. atok 57600        ; Last resort for T3000.
  56. stop 1 Can't get modem's attention
  57.  
  58. ; Telebit T3000 modem setup, should apply to all connections:
  59. ;
  60. ; X12          Result code selection, wait for dialtone, recognize busy signal.
  61. ; &D2          Disconnect call and return to command mode if DTR drops;
  62. ;                this allows HANGUP to work if cable properly wired.
  63. ; S50=0        Automatic modulation speed determination.
  64. ; S94=1        Allow connection at any speed and allow modulation fallback.
  65. ; S58=2S68=255 Use RTS/CTS hardware flow control.
  66. ; S60=0        Data format: 8 data bits, no parity.
  67. ; S61=0S63=0   Pass BREAK through transparently.
  68.  
  69. :GOTOK            ; Got OK from modem
  70.  
  71. ;;output AT&F\13    ; Restore factory settings (no, this changes speed!)
  72. ;;chkok {Can't restore factory settings}
  73.  
  74. output AT E1 Q0 V1 &D2 S59=15 X12\13  ; Set echo and response modes.
  75. chkok {Can't initialize modem}
  76.  
  77. echo Locking interface speed at \m(max_speed)...
  78. output ATS51=\m(s51)\13
  79. chkok {Can't set modem's speed to \m(max_speed)}
  80. set speed \m(max_speed)
  81.  
  82. ; Try 3 times to get OK response to AT at new speed.
  83. ;
  84. set count 3
  85. :LOOP
  86. pause
  87. output AT\13
  88. input 3 OK
  89. if success goto ok
  90. if count goto loop
  91. Stop 1 Can't communicate with modem at \m(max_speed)
  92.  
  93. :OK
  94. echo Enabling hardware flow control...
  95. output AT S58=2 S68=255 &R3\13    ; Tell modem to use RTS/CTS
  96. chkok {Can't enable RTS/CTS}
  97. set flow rts/cts        ; Tell Kermit to use RTS/CTS
  98. echo Enabling modulation negotiation...
  99. output AT S50=0 S94=1\13    ; Enable modulation speed negotiation
  100. chkok {Can't enable modulation speed negotiation}
  101. echo Configuring modem to ignore BREAK...
  102. output AT S60=0 S61=0 S63=0\13    ; Make modem ignore break
  103. chkok {Can't be transparent to BREAK}
  104. echo Enabling error correction and data compression...
  105. output AT S180=2 S181=1 S190=1\13 ; Enable error correction & compression
  106. chkok {Can't enable compression EC and fallback}
  107.  
  108. if def \%1 if not equal "\%1" "=" goto BEGIN
  109. echo T3000 initialized OK:
  110. output AT&V\13
  111. input 10 OK
  112. echo
  113. echo Firmware version:
  114. output ATI3\13
  115. input 4 OK
  116. end 0
  117.  
  118. :BEGIN                ; Now DIAL.
  119. clear                ; Clear INPUT buffer.
  120. set count 5                     ; Dialing retry counter, 5 tries allowed.
  121. echo Dialing \%1 on \v(line) at \v(speed) bps, wait...
  122. echo
  123. pause 1
  124. goto dial                       ; 1st time, skip pause and Redialing message
  125.  
  126. :REDIAL
  127. set alarm 30
  128. pause 30            ; Wait 30 seconds before redialing.
  129. if not alarm errfail {Dialing canceled.}
  130. echo Redialing...
  131. pause 1
  132.  
  133. :DIAL
  134. output ATD\%1\13                ; Dial the number.
  135. set alarm 90            ; (For detecting keyboard interruptions.)
  136. if > VERSION 312 clear input    ; Clear echo from INPUT buffer.
  137. if < VERSION 313 clear
  138. pause 1                ; Wait a sec
  139. input 30 \10                    ; Wait for the linefeeds...
  140.  
  141. :GETMSG
  142. input 60 \10            ; ...that surround the response message.
  143. if success goto gotmsg        ; Got a message.
  144. if alarm errfail {No response from modem.} ; No response in 90 seconds.
  145. hangup                ; User interrupted from keyboard,
  146. output \13            ; cancel dialing by sending carriage return,
  147. goto again            ; and go try again right away.
  148.  
  149. :GOTMSG
  150. reinput 1 CONNECT               ; Got a message, was it CONNECT?
  151. if success goto done            ; If so, we're done.
  152.  
  153. reinput 1 DIALING        ; Modem says it's dialing...
  154. if fail goto g2
  155. if > VERSION 312 clear input    ; Clear echo from INPUT buffer.
  156. if < VERSION 313 clear
  157. goto getmsg            ; message again, then go get next message.
  158.  
  159. :G2
  160. reinput 1 RRING            ; Remote phone is ringing...
  161. if fail goto g3
  162. clear                ; Clear INPUT buffer.
  163. goto getmsg            ; Go wait for another message.
  164.  
  165. :G3
  166. reinput 1 BUSY            ; Line is busy.
  167. if success goto busy        ; Go wait a while and then dial again.
  168.  
  169. :G4
  170. reinput 1 ERROR            ; Command syntax error.
  171. if success errfail {Dialing command error}
  172. reinput 1 NO CARRIER        ; Phone didn't answer or no carrier.
  173. if success errfail {No answer or no carrier}
  174. reinput 1 NO DIALTONE        ; No dialtone when phone taken off hook.
  175. if success errfail {No dialtone - Is your modem connected to the phone line\63}
  176. goto getmsg            ; None of the above, get another message.
  177.  
  178. :BUSY
  179. if < \v(count) 2 goto quit    ; Don't wait 30 seconds if tries are used up.
  180. echo Line is busy, will dial again in 30 seconds.
  181. echo Press any key to cancel...
  182. output \13            ; CR cancels dialing
  183. hangup                          ; Hang up.
  184. :AGAIN
  185. if count goto redial            ; Then go redial.
  186. :QUIT
  187. errfail {It never answers!  I give up.} ; Too many tries.
  188.  
  189. :DONE                           ; Connected.
  190. echo \7                         ; Celebrate with a beep.
  191. define errfail            ; Erase local macro definitions...
  192. end 0                ; Finished, return success code.
  193.  
  194. :FAIL                ; Dialing failed, no beep.
  195. define errfail            ; Erase local macro definitions...
  196. end 1                ; Return failure code.
  197.  
  198. ; End of T3000.SCR
  199.