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

  1. ; File QBLAZER.SCR (MSMQBLAZ.SCR)
  2. ;
  3. ; An MS-DOS Kermit script program for dialing Telebit QBlazer modems.
  4. ; Set up QBlazer for compression, error correction, all types of fallback,
  5. ; RTS/CTS flow control, fixed interface speed of 38400.
  6. ;
  7. ; Requires MS-DOS Kermit 3.12 or later
  8. ;
  9. ; Authors: Christine M. Gianone, Frank da Cruz; Columbia U, June 1993
  10. def errfail echo \%1, hangup, goto fail ; Macro to handle failures.
  11. if < VERSION 312 errfail {MS-DOS Kermit 3.12 or later required.}
  12. if eq "\v(system)" "UNIX" if = \v(local) 0 stop 1 Please SET LINE first.
  13.  
  14. define chkerr if fail stop 1 \%1
  15. define chkok input 3 OK, if fail stop 1 \%1
  16.  
  17. define max_speed 38400    ; Change these two if necessary
  18. define s51 6        ; ...
  19.  
  20. ; Macro to try to get attention of modem's command processor
  21. ; at the given speed, or if no speed given, at the current speed.
  22. ;
  23. define atok -
  24.  if not def \%1 assign \%1 \v(speed), -
  25.  set speed \%1, -
  26.  echo Trying \%1..., -
  27.  output \B, -
  28.  output \17, -
  29.  output ATQ0\13, -
  30.  input 3 OK, -
  31.  if success goto gotok
  32.  
  33. set input echo on        ; So we can watch what happens.
  34. set input timeout proceed       ; Allow IF SUCCESS, IF FAILURE.
  35. set input case ignore        ; Use caseless string comparisons
  36.  
  37. set parity none        ; Avoid parity foulups
  38. set flow none        ; Avoid flow control deadlocks
  39. hangup            ; Begin by dropping DTR
  40. pause 1            ; for one second
  41.  
  42. echo Configuring Telebit QBlazer on \v(line).
  43.  
  44. wait 0 DSR        ; Check modem signals that should be on
  45. chkerr {No DSR signal - check your modem and cable}
  46. wait 0 CTS
  47. chkerr {No CTS signal - check your modem and cable}
  48.  
  49. if > \v(speed) \m(max_speed) set speed \m(max_speed)
  50.  
  51. atok            ; Try to connect at current speed, whatever it is.
  52. atok 9600         ; Try to connect at 9600.
  53. atok 19200        ; 19200...
  54. atok 2400        ; etc...
  55. atok 38400        ; Last resort because no autobaud at this speed(?)
  56. stop 1 Can't get modem's attention
  57.  
  58. ; QBlazer modem setup, should apply to all connections:
  59. ;
  60. ; X4           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 X4\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 QBlazer 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...               ; Message for 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 QBLAZER.SCR
  199.