home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / mskscripts / hayes.kds < prev    next >
Text File  |  2020-01-01  |  5KB  |  154 lines

  1. ; FILE HAYES.SCR
  2. ; An MS-DOS Kermit script program for dialing a Hayes 1200 or 2400 SmartModem.
  3. ;
  4. ; Authors: C. Gianone & F. da Cruz, Columbia U, December 1996
  5. ;
  6. ; To use: SET MODEM=HAYES (in DOS, before starting Kermit or in AUTOEXEC.BAT)
  7. ; or:     SET MODEM HAYES (in Kermit, or in MSCUSTOM.INI)
  8. ; and:    Make sure Kermit has executed the standard MSKERMIT.INI file,
  9. ;         and then DIAL the desired number.
  10. ;
  11. ; Variables - define these prior to dialing if desired; they can be either
  12. ; Kermit variables or DOS environment variables:
  13. ;   DIALPORT    - COM port to use for dialing (COM1, etc, default current port)
  14. ;   DIALSPEED   - Speed for dialing (the port's current speed by default)
  15. ;   DIALMETHOD  - TONE or PULSE (modem's default method is used by default)
  16. ;   DIALRETRIES - Maximum times to redial the call (default 5)
  17. ;   DIALTIMEOUT - How long to wait for result from modem (default 90 seconds)
  18. ;
  19. if < VERSION 315 stop 1 MS-DOS Kermit 3.15 or later required.
  20.  
  21. local __dm __parity spdchg errfail ; Local variables
  22.  
  23. def ERRFAIL echo \%1, forward FAIL
  24. def SPDCHG echo Changing speed to \%1..., set speed \%1
  25.  
  26. set carrier off                 ; Don't require carrier during dialing.
  27. set input echo on        ; So we can watch what happens.
  28. set input timeout proceed       ; Allow IF SUCCESS, IF FAILURE.
  29. set input case ignore        ; Use caseless string comparisons
  30.  
  31. :PORT
  32. if not def DIALPORT asg DIALPORT \$(DIALPORT)
  33. if not def DIALPORT forward SPEED
  34. set port \m(DIALPORT)
  35. if success forward SPEED
  36. echo SET PORT \m(DIALPORT) failed 
  37. end 1
  38.  
  39. :SPEED
  40. asg __parity \v(parity)        ; Save parity setting
  41. set parity none            ; Switch to none while dialing
  42. set flow none            ; Avoid flow control deadlocks
  43. hangup                ; Begin by dropping DTR
  44.  
  45. if not def DIALSPEED asg DIALSPEED \$(DIALSPEED)
  46. if not def DIALSPEED asg DIALSPEED \v(speed)
  47. set speed \m(DIALSPEED)
  48. if fail end 1 \m(DIALSPEED) - Speed not supported
  49.  
  50. ; Dial method, retry limit, and timeout...
  51.  
  52. xif numeric \fsubstr(\%1,1,1) {
  53.     if eq "\m(DIALMETHOD)" "TONE" asg __dm T
  54.     if eq "\m(DIALMETHOD)" "PULSE" asg __dm P
  55. }
  56. if not def DIALRETRIES asg DIALRETRIES \$(DIALRETRIES)
  57. if not def DIALRETRIES asg DIALRETRIES 5
  58.  
  59. if not def DIALTIMEOUT asg DIALTIMEOUT \$(DIALTIMEOUT)
  60. if not def DIALTIMEOUT asg DIALTIMEOUT 90
  61.  
  62. ; Begin the modem dialog...
  63.  
  64. echo Configuring Hayes SmartModem \v(line)...
  65. if not def DIALSPEED asg DIALSPEED \$(DIALSPEED)
  66. if not def DIALSPEED asg DIALSPEED \v(speed)
  67. if eq \m(DIALSPEED) 2400 forward S2400
  68. if eq \m(DIALSPEED) 1200 forward S1200
  69.  
  70. echo Trying \v(speed)...
  71. output ATQ0V1\13        ; Try at current speed
  72. input 3 OK
  73. if success forward gotok
  74. set speed 2400
  75. :S2400
  76. echo Trying \v(speed)...
  77. clear
  78. output ATQ0V1\13        ; Try at 2400
  79. input 3 OK
  80. if success forward gotok
  81. set speed 1200
  82. :S1200
  83. echo Trying \v(speed)...
  84. clear
  85. output ATQ0V1\13        ; Try at 1200
  86. input 3 OK
  87. if fail stop 1 {No response from modem - is it turned on and connected?}
  88.  
  89. :GOTOK
  90. mpause 500
  91. clear input            ; Clear INPUT buffer.
  92. clear device            ; Clear device buffer.
  93.  
  94. if not > \v(speed) 2400 echo Hayes \v(speed) detected.
  95. echo Dialing \%1 on \v(line) at \v(speed) bps, wait...
  96. echo
  97.  
  98. xif not < \v(speed) 2400 {    ; Enable CONNECT <speed> result codes
  99.     out ATX4\13
  100.     inp 3 OK            ; But don't fail if there's an error
  101. }
  102. for \%i 1 \m(DIALRETRIES) 1 {    ; Redial loop
  103.     xif > \%i 1 {
  104.         echo Redialing...       ; Message for redialing
  105.         hangup            ; Hang up first
  106.     }
  107.     pause 1            ; Wait a sec for modem to settle
  108.     output ATD\m(__dm)\%1\13    ; Dial the number.
  109.     minput \m(DIALTIMEOUT) -
  110.       CONNECT BUSY ERROR {NO CARRIER} {NO ANSWER} {NO DIALTONE} RING
  111.     xif fail { echo Call timed out, hangup, out \13, continue }
  112.     switch \v(minput) {
  113.       :1, forward done
  114.       :2, Echo Line is busy - will dial again in 30 seconds.
  115.           echo Press any key to cancel...
  116.           output \13
  117.           pause 30
  118.           if fail errfail Canceled
  119.           break
  120.       :3, errfail {Dialing command error}
  121.       :4, errfail {Call failed - no carrier}
  122.       :5, errfail {No answer - try again later}
  123.       :6, errfail {No dialtone - is your modem connected to the phone line?}
  124.       :7, decr \%i, break
  125.       :8, errfail {Call failed - your phone is ringing}
  126.       :default, break
  127.     }    
  128. }
  129. errfail {It never answers!  I give up.} ; Too many tries.
  130.  
  131. :DONE                           ; Connected.
  132. xif > \v(speed) 1200 {
  133.     minput 2 1200 2400        ; Change speed if necessary.
  134.     xif success {
  135.     if = \v(minput) 1 if not = \v(speed) 1200 spdchg 1200
  136.     if = \v(minput) 2 if not = \v(speed) 2400 spdchg 2400
  137.     }
  138. }
  139.  
  140. :BEEP
  141. echo \7                         ; Celebrate with a beep.
  142. set carrier on            ; Require carrier from now on.
  143. set parity \m(__parity)        ; Restore host parity setting
  144. end 0                ; Finished, return success code.
  145.  
  146. :FAIL
  147. set carrier off            ; Let them reconnect to see what's up.
  148. hangup
  149. end 1                ; Return failure code.
  150.  
  151. ; End of HAYES.SCR
  152.