home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95 / ckepage.ksc < prev    next >
Text File  |  2020-01-01  |  7KB  |  186 lines

  1. ; File APAGE.KSC
  2. ; Version 4.0-K95
  3. ;
  4. if < \v(xversion) 1119 end 1 K95 1.1.19 or later required.
  5.  
  6. ; TAP/IXO alphanumeric paging script for Kermit 95 and C-Kermit.
  7. ; Authors: F. da Cruz and C. Gianone, Columbia University, September 1996.
  8. ;
  9. ; For use with C-Kermit 7.0 / K95 1.1.17 or later.
  10. ; For a detailed explanation, consult "Using C-Kermit", 2nd Ed., pp.454-456.
  11. ;
  12. ; Version 2.0: July 1997:
  13. ;  1. To make TAPMSG fit into 1K for small C-Kermit versions.
  14. ;  2. Change END to STOP within SWITCH to work around bug.
  15. ; Version 3.0: September 1997:
  16. ;  1. Change STOP back to END because bug is fixed.
  17. ;  2. Added robustness.
  18. ; Version 4.0: August 1998:
  19. ;  1. Additional robustness - requires 2K command buffer.
  20. ;  2. Diagnostics.
  21. ;
  22. ; WARNING: Automatic redialing is restricted or illegal in some
  23. ; countries.  Modify the lines marked "IF LEGAL!" if below this applies
  24. ; in your location.
  25. ;
  26. ; TAPMSG, defined below, is an alphanumeric pager dialing script that
  27. ; implements the Telocator Alphanumeric Protocol (TAP), also known as IXO,
  28. ; for sending one-line alphanumeric pages.  TAPMSG assumes the connection
  29. ; to the paging service is already made.
  30. ;
  31. ; The APAGE macro makes a connection to the paging service and then uses
  32. ; TAPMSG to send the page.  Here is a SAMPLE; you will need to adjust it
  33. ; to work with your paging service.  Hint: Some paging services are very
  34. ; picky about modem configurations.  For example, experience has shown
  35. ; that to dial a certain service successfully with a USR 28.8 modem, just
  36. ; about all of the modem's features must be turned off prior to dialing.
  37. ; If you have trouble connecting to your service and staying connected,
  38. ; try removing the ";" from the left margin of the commands marked
  39. ; UNCOMMENT below.
  40. ;
  41. ; Replace values in lines marked (*) with the ones appropriate for your
  42. ; computer, modem, and paging service:
  43. ;
  44. ; GENERAL INSTRUCTIONS
  45. ;
  46. ; Edit this file to contain the phone number of your paging service
  47. ; plus any special communications parameters (lines marked "(*)" below).
  48. ; Then whenever you want to send an alpha page, tell Kermit to "take" the
  49. ; file (which installs the APAGE and TAPMSG definitions) and then to send
  50. ; a page, just type:
  51. ;
  52. ;   apage number { this is a message }
  53. ;
  54. ; at the K-95> prompt, for example:
  55. ;
  56. ;   apage 99997654321 { Please call the office }
  57. ;
  58. ; If you always want the APAGE macro available, add a TAKE command for this
  59. ; file to your K95CUSTOM.INI file.
  60. ;
  61. ; Note: the pager ID number should not contain any spaces or else you must
  62. ; enclose it in braces:
  63. ;
  64. ;   apage { 999 76 543 21 } { This is a message }
  65. ;
  66. ; Ditto for the message.
  67. ;
  68. ; DEBUGGING: If you want to see diagnostic and progress messages, type
  69. ; "define testing 1" at the Kermit prompt before trying to send a page.
  70. ;
  71. local usage \%m
  72. assign \%m \fbasename(\%0)
  73.  
  74. define usage { stop 1 {usage: \%m <phonenumber> <message>} }
  75.  
  76. if not def TESTING def TESTING 0 ; Set to 1 for testing / debugging
  77. if \m(TESTING) {         ; So we can watch what happens
  78.     set dial display on
  79.     set input echo on
  80.     set terminal echo local    ; So output goes in session log
  81.     log session                ; Creates session.log in current directory
  82.     log transact               ; Creates transact.log in current directory
  83. }
  84.  
  85. define APAGE {
  86.     local rc number            ; rc = Return code for this macro
  87.     if < \v(argc) 2 end 1 PIN required
  88.     asg number 5554321         ; (*) Paging service phone number
  89.     set tapi line              ; (*) on this device (default TAPI device)
  90.     if fail end 1 SET TAPI LINE failed
  91.     set speed 1200             ; (*) Must use 1200 bps for paging
  92.     set parity even            ; (*) and even parity
  93.     set flow none              ; (*) and no flow control
  94.     set modem flow none        ; (*) ...
  95.     set modem error-correction off
  96.     set modem data-compression off
  97.     set modem speed-matching off
  98.     set output pacing 200      ; Talk s-l-o-w-l-y to the paging service
  99.     set dial retries 20        ; (*) Allow 20 redials (IF LEGAL!)
  100.     set dial interval 1        ; (*) 1 sec between redial attempts (IF LEGAL!)
  101.     dial \m(number)            ; Call the pager service
  102.     asg rc \v(status)           ; Save DIAL status
  103.     if = \m(rc) 0 {            ; If the call is answered
  104.         tapmsg \%1 {\%2}       ; Send the page
  105.         asg rc \v(status)      ; Save the result
  106.     } else {                   ; Otherwise
  107.         echo Page failed.      ; Fail.
  108.     }
  109.     hangup                     ; Hang up the phone
  110.     ;
  111.     ; For shared in-out ports you might need to reset the port's original
  112.     ; speed here and maybe also send it some kind of reset command like ATZ0.
  113.     ;
  114.     set modem type \v(modem)   ; Restore default modem settings
  115.     end \m(rc)                 ; Return
  116. }
  117.  
  118. ; TAPMSG Telocator Alphanumeric Protocol execution.  Call with:
  119. ;   \%1 = Pager ID (PIN)
  120. ;   \%2 = Message (single line)
  121. ;  Assumes connection is made.  Uses TAP to send PIN and 1-line message.
  122. ;
  123. def TAPMSG {
  124.     local \%i \%m \%s blk        ; Local variables
  125.     asg \%m \2\%1\13\%2\13\3        ; <STX>ID<CR>msg<CR><ETX>
  126.     asg \%s \fchecksum(\%m)        ; Get checksum and make block
  127.     asg blk \%m\fchar(\fmod(\%s/256,16)+48)-
  128. \fchar(\fmod(\%s/16,16)+48)-
  129. \fchar(\fmod(\%s,16)+48)\13        ; Checksummed TAP block
  130.     if \m(TESTING) xecho WAITING FOR ID= PROMPT...
  131.     for \%i 1 6 1 {            ; Try six times to get prompt
  132.     out \13                ; Send <CR>
  133.     in 3 ID=            ; Wait for "ID="
  134.     if succ break
  135.         if \m(TESTING) xecho NO ID= PROMPT - TRYING AGAIN
  136.     }
  137.     if > \%i 6 end 1 FAILED: No "ID=" prompt after 6 tries
  138.     for \%i 1 8 1 {            ; Send <ESC>PG1, get <ACK>
  139.     msleep 500
  140.     output \{27}PG1\13
  141.         if \m(TESTING) echo SENT <ESC>PG1(\%i)...
  142.     minput 3 {\6\13} {\21\13} {ID=} {\27\4\13}
  143.         if \m(TESTING) echo RESULT=\v(minput)
  144.     switch \v(minput) {
  145.       :0, continue            ; Timeout
  146.       :1, break            ; <ACK>
  147.       :2, continue            ; <NAK>
  148.       :3, out \{27}PG1\13, continue
  149.       :4, end 1 Forced disconnect    ; Forced disconnect - fatal
  150.     }
  151.     break
  152.     }
  153.     if > \%i 8 end 1 Timeout during TAP
  154.     in 10 \27[p\13            ; Wait for go-ahead
  155.     if fail end 1 No go-ahead        ; Didn't get it
  156.     for \%i 1 8 1 {            ; Try eight times
  157.     msleep 500
  158.     output \m(blk)            ; Send block
  159.         if \m(TESTING) echo SENT BLOCK (\%i)...
  160.     minput 8 {\6\13} {\21\13} {\13\27\4\13} {\30\13}
  161.         if \m(TESTING) echo RESULT=\v(minput)
  162.     switch \v(minput) {             ; Get response
  163.       :0, continue                  ; Timeout
  164.       :1, break                     ; <ACK> - success
  165.       :2, continue                  ; <NAK>
  166.       :3, end 1 Forced Disconnect
  167.       :4, echo ERROR - RETRYING, continue
  168.     }
  169.     out \4\13                       ; Sign off with <EOT>
  170.     in 8 \27\4\13                   ; Get <ESC><EOT> back
  171.     break                           ; But ignore timeout
  172.     }
  173.     if > \%i 8 end 1 Too many retries
  174. }
  175.  
  176. ; If invoked as a "kerbang" script execute it now.
  177.  
  178. if equal "\%0" "\v(cmdfil)" {
  179.     if not def \%1 usage
  180.     if not def \%2 usage
  181.     apage {\%1} {\%2}
  182.     exit \v(status)
  183. }
  184.  
  185. ; (End)
  186.