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

  1. ; FILE MEGAHERTZ.SCR
  2. ; An MS-DOS Kermit script program for dialing the Megahertz X-Jack 3144 or
  3. ; CC6144 modem, to be used with MS-DOS Kermit 3.15 or later.  The modem is set
  4. ; for RTS/CTS flow control, fixed interface speed of 57600, and to negotiate
  5. ; highest modulation, compression, with error correction with all types of
  6. ; fallback.
  7. ;
  8. ; To use: SET MODEM=MEGAHERTZ (in DOS, before starting Kermit)
  9. ; or:     SET MODEM MEGAHERTZ (in Kermit)
  10. ; and:    Make sure Kermit executes the standard MSKERMIT.INI file.
  11. ;
  12. ; Variables - define these prior to dialing if desired;
  13. ; they can be either Kermit variables or DOS environment variables:
  14. ;   DIALPORT    - COM port to use for dialing (COM1, COM2, BIOS1, BIOS2, ...)
  15. ;   DIALSPEED   - Speed for dialing (57600 by default)
  16. ;   DIALMETHOD  - TONE or PULSE (modem's default method is used by default)
  17. ;   DIALRETRIES - Maximum times to redial the call
  18. ;
  19. if < VERSION 315 errfail {MS-DOS Kermit 3.15 or later required.}
  20. def ERRFAIL echo \%1, forward FAIL
  21. def CHKOK input 3 OK, if fail stop 1 \%1
  22.  
  23. local __dm __parity __retries    ; Local variables
  24.  
  25. set carrier off                 ; Don't require carrier during dialing.
  26. set input echo on        ; So we can watch what happens.
  27. set input timeout proceed       ; Allow IF SUCCESS, IF FAILURE.
  28. set input case ignore        ; Use caseless string comparisons
  29.  
  30. :PORT
  31. if not def DIALPORT if def \$(DIALPORT) asg DIALPORT \$(DIALPORT)
  32. if not def DIALPORT forward SPEED
  33. set port \m(DIALPORT)
  34. if success forward SPEED
  35. echo SET PORT \m(DIALPORT) failed 
  36. end 1
  37.  
  38. :SPEED
  39. asg __parity \v(parity)        ; Save parity setting
  40. set parity none            ; Switch to none while dialing
  41. set flow none            ; Avoid flow control deadlocks
  42. hangup                ; Begin by dropping DTR
  43.  
  44. if not def DIALSPEED if def \$(DIALSPEED) asg DIALPORT \$(DIALSPEED)
  45. if not def DIALSPEED asg DIALSPEED 57600
  46. set speed \m(dialspeed)
  47. echo Configuring Megahertz modem on \v(line).
  48.  
  49. :INIT
  50. output ATQ0V1&S0\13        ; Enable word result codes, turn on DSR
  51. chkok {Can't get modem's attention}
  52. output ATE1X4&D2&C1\13        ; Set echoing, result codes, etc.
  53. chkok {Can't initialize modem}
  54. output AT &K3\13        ; RTS/CTS hardware flow control
  55. chkok {Can't enable RTS/CTS}    ; On modem
  56. wait 5 cts
  57. if fail errfail {Modem is not asserting CTS!}
  58. set flow rts/cts        ; And in Kermit too, but only now
  59. output AT \\N3\13        ; Enable modulation fallback
  60. chkok {Can't enable modulation fallback}
  61. output AT &Q5%C3\13        ; Compression and EC enabled
  62. chkok {Can't enable compression and EC}
  63. output AT S82=128\13        ; Make modem pass BREAK transparently
  64. chkok {Can't become transparent to BREAK}
  65. mpause 500
  66. clear input            ; Clear INPUT buffer.
  67. clear device            ; Clear device buffer.
  68.  
  69. echo Dialing \%1 on \v(line) at \v(speed) bps, wait...
  70. echo
  71. xif numeric \fsubstr(\%1,1,1) {
  72.     if eq "\m(DIALMETHOD)" "TONE" asg __dm T
  73.     if eq "\m(DIALMETHOD)" "PULSE" asg __dm P
  74. }
  75. asg __retries \m(DIALRETRIES)
  76. if not def __retries asg __retries \$(DIALRETRIES)
  77. if not def __retries asg __retries 5
  78.  
  79. for \%i 1 \m(__retries) 1 {
  80.     xif > \%i 1 {
  81.         echo Redialing...       ; Message for redialing.
  82.         hangup            ; Hang up first
  83.     }
  84.     pause 1            ; Wait a sec for modem to settle
  85.     output ATD\m(__dm)\%1\13    ; Dial the number.
  86.     minput 90 -
  87.       CONNECT BUSY ERROR {NO CARRIER} {NO ANSWER} {NO DIALTONE} -
  88.       DELAYED RING BLACKLISTED FAX
  89.     xif fail { echo Call timed out, hangup, out \13, continue }
  90.     switch \v(minput) {
  91.       :1, forward done
  92.       :2, Echo Line is busy - will dial again in 30 seconds.
  93.           echo Press any key to cancel...
  94.           output \13
  95.           pause 30
  96.           if fail errfail Canceled
  97.           break
  98.       :3, errfail {Dialing command error}
  99.       :4, errfail {Call failed - no carrier}
  100.       :5, errfail {No answer - try again later}
  101.       :6, errfail {No dialtone - is your modem connected to the phone line?}
  102.       :7, errfail {Call delayed - try again later}
  103.       :8, errfail {Call failed - your phone is ringing}
  104.       :9, errfail {Call failed - blacklisted}
  105.       :10, errfail {Call failed - answered by fax}
  106.       :default, break
  107.     }    
  108. }
  109. errfail {It never answers!  I give up.} ; Too many tries.
  110.  
  111. :DONE                           ; Connected.
  112. echo \7                         ; Celebrate with a beep.
  113. set carrier on            ; Require carrier from now on.
  114. set parity \m(__parity)        ; Restore host parity setting
  115. undef errfail            ; Erase local macro definitions...
  116. end 0                ; Finished, return success code.
  117.  
  118. :FAIL
  119. undef errfail            ; Erase local macro definitions...
  120. set carrier off            ; Let them reconnect to see what's up.
  121. hangup
  122. end 1                ; Return failure code.
  123.  
  124. ; End of MEGAHERTZ.SCR
  125.