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

  1. ; FILE SPORT.SCR
  2. ; An MS-DOS Kermit script program for dialing the US Robotics Sportster or
  3. ; Courier 14400, 28800, or compatible modem, to be used with MS-DOS Kermit
  4. ; 3.15 or later.  The modem is set for RTS/CTS flow control, fixed interface
  5. ; speed, and to negotiate highest modulation, error correction, compression,
  6. ; and all types of fallback.
  7. ;
  8. ; Authors: C. Gianone & F. da Cruz, Columbia U, December 1996
  9. ;
  10. ; To use: SET MODEM=SPORT (in DOS, before starting Kermit or in AUTOEXEC.BAT)
  11. ; or:     SET MODEM SPORT (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        ; Local variables
  28. set carrier off                 ; Don't require carrier during dialing.
  29. set input echo on        ; So we can watch what happens.
  30. set input timeout proceed       ; Allow IF SUCCESS, IF FAILURE.
  31. set input case ignore        ; Use caseless string comparisons
  32.  
  33. :PORT
  34. if not def DIALPORT asg DIALPORT \$(DIALPORT)
  35. if not def DIALPORT forward SPEED
  36. set port \m(DIALPORT)
  37. if success forward SPEED
  38. echo SET PORT \m(DIALPORT) failed 
  39. end 1
  40.  
  41. :SPEED
  42. asg __parity \v(parity)        ; Save parity setting
  43. set parity none            ; Switch to none while dialing
  44. set flow none            ; Avoid flow control deadlocks
  45. hangup                ; Begin by dropping DTR
  46.  
  47. if not def DIALSPEED asg DIALSPEED \$(DIALSPEED)
  48. if not def DIALSPEED asg DIALSPEED 57600
  49. set speed \m(DIALSPEED)
  50. if fail end 1 \m(DIALSPEED) - Speed not supported
  51.  
  52. ; Dial method, retry limit, and timeout...
  53.  
  54. xif numeric \fsubstr(\%1,1,1) {
  55.     if eq "\m(DIALMETHOD)" "TONE" asg __dm T
  56.     if eq "\m(DIALMETHOD)" "PULSE" asg __dm P
  57. }
  58. if not def DIALRETRIES asg DIALRETRIES \$(DIALRETRIES)
  59. if not def DIALRETRIES asg DIALRETRIES 5
  60.  
  61. if not def DIALTIMEOUT asg DIALTIMEOUT \$(DIALTIMEOUT)
  62. if not def DIALTIMEOUT asg DIALTIMEOUT 90
  63.  
  64. ; Begin the modem dialog...
  65.  
  66. echo Configuring USR Sportster on \v(line)...
  67. output ATQ0V1\13        ; Enable word result codes
  68. chkok {Can't get modem's attention}
  69. output ATE1X4&A3&D2\13        ; Set echoing, result codes, etc.
  70. chkok {Can't initialize modem}
  71. output AT&B1\13            ; Fixed interface speed
  72. chkok {Can't fix interface speed}
  73. output AT &H1&R2\13        ; RTS/CTS hardware flow control
  74. chkok {Can't enable RTS/CTS}    ; On modem
  75. wait 5 cts
  76. if fail errfail {Configuration failed - no CTS from modem}
  77. set flow rts/cts        ; And in Kermit too, but only now
  78. output AT &N0\13        ; Enable modulation fallback
  79. chkok {Can't enable modulation fallback}
  80. output AT &K1&M4\13        ; Compression and EC enabled
  81. Chkok {Can't enable compression and EC}
  82. output AT &Y3\13        ; Make modem pass BREAK transparently
  83. chkok {Can't become transparent to BREAK}
  84. mpause 500
  85. clear input            ; Clear INPUT buffer.
  86. clear device            ; Clear device buffer.
  87.  
  88. echo Dialing \%1 on \v(line) at \v(speed) bps, wait...
  89. echo
  90.  
  91. for \%i 1 \m(DIALRETRIES) 1 {    ; Redial loop
  92.     xif > \%i 1 {
  93.         echo Redialing...       ; Message for redialing
  94.         hangup            ; Hang up first
  95.     }
  96.     pause 1            ; Wait a sec for modem to settle
  97.     output ATD\m(__dm)\%1\13    ; Dial the number.
  98.     for \%j 1 10 1 {
  99.         minput \m(DIALTIMEOUT) -
  100.           CONNECT BUSY ERROR {NO CARRIER} {NO ANSWER} {NO DIAL TONE} -
  101.           RINGING RING VOICE
  102.         xif fail { echo Call timed out, hangup, out \13, continue }
  103.         if not = \v(minput) 7 break
  104.     }
  105.  
  106.     switch \v(minput) {
  107.       :1, forward done
  108.       :2, Echo Line is busy - will dial again in 30 seconds.
  109.           echo Press any key to cancel...
  110.           output \13
  111.           pause 30
  112.           if fail errfail Canceled
  113.           break
  114.       :3, errfail {Dialing command error}
  115.       :4, errfail {Call failed - no carrier}
  116.       :5, errfail {No answer - try again later}
  117.       :6, errfail {No dialtone - is your modem connected to the phone line?}
  118.       :7, errfail {Call failed - too many rings}
  119.       :8, errfail {Call failed - your phone is ringing}
  120.       :9, errfail {Call failed - answered by voice}
  121.       :default, break
  122.     }    
  123. }
  124. errfail {It never answers!  I give up.} ; Too many tries.
  125.  
  126. :DONE                           ; Connected.
  127. echo \7                         ; Celebrate with a beep.
  128. set carrier on            ; Require carrier from now on.
  129. set parity \m(__parity)        ; Restore host parity setting
  130. undef errfail            ; Erase local macro definitions...
  131. end 0                ; Finished, return success code.
  132.  
  133. :FAIL
  134. undef errfail            ; Erase local macro definitions...
  135. set carrier off            ; Let them reconnect to see what's up.
  136. hangup
  137. end 1                ; Return failure code.
  138.  
  139. ; End of SPORT.SCR
  140.