home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / vms / 17643 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  9.0 KB

  1. Path: sparky!uunet!comp.vuw.ac.nz!zl2tnm!don
  2. From: don@zl2tnm.gen.nz
  3. Newsgroups: comp.os.vms
  4. Subject: Re: Modem dialer for vms
  5. Message-ID: <1992Nov8.215519.2099@zl2tnm.gen.nz>
  6. Date: 8 Nov 92 21:55:19 +1300
  7. References: <1992Nov4.111515.1@musctn.monsanto.com>
  8. Organization: The Wolery
  9. Lines: 347
  10.  
  11. In article <1992Nov4.111515.1@musctn.monsanto.com>, rewise@musctn.monsanto.com (Richard Wiseman - VAX/VMS CraftsPerson) writes:
  12. >     with VMS dec supplies a modem dialer program... But of course
  13. >     It only speaks DMCL.. 
  14. >     What I'am looking for is a modified version that can talk to a HAYES
  15. >     compatible modem...
  16. >     OPerating system VAX_VMS
  17. >     version 5.5-1
  18. >     Modem type   Generic HAYEs
  19.  
  20. Here's DTE_HAYES.MAR, again.  Someone bung this on an archive somewhere.
  21.  
  22.  
  23. Don Stokes, ZL2TNM (DS555)                       don@zl2tnm.gen.nz (home)
  24. Network Manager, Computing Services Centre           don@vuw.ac.nz (work)
  25. Victoria University of Wellington, New Zealand             +64-4-495-5052
  26.  
  27.         .title DTE_HAYES   SET HOST/DTE dialler for Hayes "AT" modems
  28. ;++
  29. ;
  30. ; DTE_HAYES -- Hayes compatible dialler module for SET HOST/DTE
  31. ;
  32. ; This module allows a modem that understands the Hayes "AT" command set
  33. ; to be used with SET HOST/DTE/DIAL.
  34. ;
  35. ; To set up, compile and link as follows:
  36. ;
  37. ;    $ MACRO DTE_HAYES
  38. ;    $ LINK/SHARE DTE_HAYES
  39. ;
  40. ; To use, place DTE_HAYES.EXE into SYS$SHARE: and issue the command:
  41. ;
  42. ;    $ SET HOST/DTE modem/DIAL=(MODEM_TYPE=HAYES,NUMBER=number)
  43. ;
  44. ; Alternatively, assign the logical DTE_DF03 to point to DTE_HAYES (it doesn't
  45. ; need to be in SYS$SHARE:) and just use SET HOST/DTE/DIAL=number, eg:
  46. ;
  47. ;    $ ASSIGN SYS$LOGIN:DTE_HAYES DTE_DF03
  48. ;    $ SET HOST/DTE modem/DIAL=NUMBER=number
  49. ;
  50. ; (This works because DTE_DF03 is the default dialler module loaded if the
  51. ; MODEM_TYPE keyword is left off SET HOST/DTE.)  If you don't have any
  52. ; DF03s, you may wish to assign the logical systemwide.
  53. ;
  54. ;
  55. ;
  56. ;    Don Stokes                30-Oct-1991
  57. ;    Network manager, 
  58. ;    Computer Services Centre,        Email: don@vuw.ac.nz
  59. ;    Victoria University of Wellington,     Home:  don@zl2tnm.gen.nz
  60. ;    New Zealand.                Phone: +64 4 495-5052
  61. ;
  62. ; No warranty or support of any kind is expressed or implied, but bugfixes,
  63. ; suggestions or job offers are always welcome.  Copyright remains with the
  64. ; author.
  65. ;
  66. ;--
  67.  
  68.         .sbttl Macros and things
  69.  
  70.         $STSDEF
  71.         $SHRDEF
  72. ;
  73. ; CALL macro - call a subroutine, pass parameters on stack
  74. ; Usage:    CALL routine [,p1...,p20]
  75. ;
  76.         .macro call routine,                    -
  77.                 p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,        -
  78.                 p12,p13,p14,p15,p16,p17,p18,p19,p20
  79.         .narg call.argc
  80.         call.argc = call.argc - 1
  81.         call.argn = 20
  82.         .irp call.argv, <p20,p19,p18,p17,p16,p15,p14,p13,p12,    -
  83.                  p11,p10,p9,p8,p7,p6,p5,p4,p3,p2,p1>
  84.             .if less_equal call.argn - call.argc
  85.                 pushal call.argv
  86.             .endc
  87.             call.argn = call.argn - 1
  88.         .endr
  89.         calls #call.argc, G^routine
  90.         .endm
  91.  
  92. ;
  93. ; WANTS -- check if R0 is greater than or equal to value, abort if not
  94. ;
  95.         .macro wants, okmin, ?L1
  96.         cmpl R0, #okmin
  97.         bgeq L1
  98.         brw failed
  99. L1:        .endm
  100.  
  101. ;
  102. ; Status macro.
  103. ; Every good MACRO program has one of these; this is no exception.
  104. ;
  105.         .macro status, cond, ?L1
  106.         blbs cond, L1
  107.         $EXIT_S cond
  108. L1:        .endm
  109.  
  110.  
  111.  
  112.         .sbttl Data areas
  113.         .psect DTE_RW, long,noexe,wrt,noshr
  114.  
  115. ;
  116. ; Workings:
  117. ;
  118. iosb:        .blkw 4                ; Dogsbody iosb
  119. waittime:    .blkl                ; Temp storage for WAIT
  120. expect_buffer:    .blkb 32            ; Expect fifo
  121. expect_buffer_l = .-expect_buffer
  122. timeout:    .ascid "Timed out"        ; Time out message
  123. rem$_facility    = ^X1FE                ; REM-?-TEXT, message
  124. rem$_text    = SHR$_TEXT!<REM$_FACILITY@16>
  125.  
  126.  
  127.  
  128. ;
  129. ; Script stuff
  130. ;
  131. cr = 13
  132.  
  133. send_init:    .ascid "ATQ0"<cr>
  134. send_dial:    .ascid "ATDT"
  135. send_cr:    .ascid <cr>
  136. send_reset:    .ascid "ATZ"<cr>
  137.  
  138. init_expects:    .address expect_error        ; ERROR, didn't like something
  139.         .address expect_ring        ; RING, Abandon ship!
  140.         .address expect_ok        ; OK
  141.         .long 0
  142.  
  143. dial_expects:                ; 1 - 7 = failed
  144.         .address expect_busy        ; BUSY, engaged
  145.         .address expect_nocarr        ; NO CARRIER, multitude of sins
  146.         .address expect_error        ; ERROR, didn't like something
  147.         .address expect_nodial        ; NO DIALTONE, out of order
  148.         .address expect_noans        ; NO ANSWER, noone home
  149.         .address expect_voice        ; VOICE, Biological moduation
  150.         .address expect_ring        ; RING, oops!
  151.                     ; 8 onwards = success
  152.         .address expect_c38k        ; 38400bps, if ever 8-)
  153.         .address expect_c19k        ; 19200bps, eg Trailblazers?
  154.         .address expect_c12k        ; 12000bps, eg Compuspec M9600
  155.         .address expect_c9600        ; 9600bps, usually V32
  156.         .address expect_c4800        ; 4800 bps
  157.         .address expect_c2400        ; 2400 bps, usually V22bis
  158.         .address expect_c1200a        ; 1200 bps, usually V22
  159.         .address expect_c1200b        ; 1200 bps with other messages
  160.         .address expect_c1200c        ; 1200 bps with other messages
  161.         .address expect_c1275        ; 1200/75, V23
  162.         .address expect_c7512        ; 75/1200, V23
  163.         .address expect_c300        ; 300, V21 (or Bell 103)
  164.         .address expect_connect        ; Straight CONNECT
  165.         .long 0
  166.  
  167. expect_ok:    .ascid "OK"
  168. expect_busy:    .ascid "BUSY"
  169. expect_nocarr:    .ascid "NO CARRIER"
  170. expect_noans:    .ascid "NO ANSWER"
  171. expect_error:    .ascid "ERROR"
  172. expect_nodial:    .ascid "NO DIALTONE"
  173. expect_voice:    .ascid "VOICE"
  174. expect_ring:    .ascid "RING"
  175. expect_c38k:    .ascid "CONNECT 38400"
  176. expect_c19k:    .ascid "CONNECT 19200"
  177. expect_c12k:    .ascid "CONNECT 12000"
  178. expect_c9600:    .ascid "CONNECT 9600"
  179. expect_c4800:    .ascid "CONNECT 4800"
  180. expect_c2400:    .ascid "CONNECT 2400"
  181. expect_c1200a:    .ascid "CONNECT 1200"<cr>    ; To avoid it looking like
  182. expect_c1200b:    .ascid "CONNECT 1200/"        ; CONNECT 12000.
  183. expect_c1200c:    .ascid "CONNECT 1200 "
  184. expect_c1275:    .ascid "CONNECT 1275"
  185. expect_c7512:    .ascid "CONNECT 7512"
  186. expect_c300:    .ascid "CONNECT 300"
  187. expect_connect:    .ascid "CONNECT"<cr>
  188.  
  189.  
  190.  
  191.  
  192.         .sbttl Linkage
  193. ;
  194. ; Linkage code
  195. ;
  196.         .psect DTE_RE, long,exe,nowrt,shr
  197.         .transfer DIAL_ROUTINE
  198.         .mask DIAL_ROUTINE
  199.         brb DIAL_ROUTINE+2
  200.  
  201.  
  202.         .sbttl Mainline
  203. ;
  204. ; Main routine
  205. ; 4(AP) = Dial string
  206. ; 8(AP) = channel to modem
  207. ;12(AP) = channel to terminal
  208. ;
  209.         .entry DIAL_ROUTINE,^m<>
  210. ;
  211. ; Initialise modem
  212. ;
  213.         call wait @#1000        ; Let modem settle from shock
  214.         call flush @8(AP)        ; of being asked to do something
  215.         call send @8(AP), send_init    ; Initialise modem
  216.         call expect, @8(AP), init_expects, @#5
  217.         wants 3                ; Either OK, ERROR or RING
  218.  
  219. ;
  220. ; Dial number
  221. ;
  222.         call wait @#2000        ; Let modem recover from init
  223.         call send @8(AP), send_dial    ; Send ATDT
  224.         call send @8(AP), @4(AP)    ; Send phone
  225.         call send @8(AP), send_cr    ; Send cr
  226.         call expect, @8(AP), dial_expects, @#60
  227.         wants 8                ; Wait for CONNECT something
  228.  
  229. ;
  230. ; Connected.  Display connect message and hand control back to DTEPAD.
  231. ;
  232.         call LIB$SIGNAL @#rem$_text!STS$K_SUCCESS, @#1, (R1)
  233.         movl #SS$_NORMAL, R0        ; TA DA!
  234.         ret
  235.  
  236. ;
  237. ; Report status and die.  R1 = reason.
  238. ;
  239. failed:        call LIB$SIGNAL @#rem$_text!STS$K_ERROR, @#1, (R1)
  240.         movl #rem$_text!STS$M_INHIB_MSG!STS$K_ERROR, R0
  241.         ret
  242.  
  243.  
  244.  
  245.  
  246.         .sbttl Routine to send characters to the modem
  247. ;
  248. ; SEND chan, string
  249. ;
  250. ; Sends one character at a time to modem.
  251. ;
  252.         .entry send, ^m<R2,R3>
  253.         movl 8(AP), R0            ; R0 = descriptor addr
  254.         movl 4(R0), R2            ; R2 = pointer
  255.         cvtwl (R0), R3            ; R3 = counter
  256.  
  257. 1$:        $QIOW_S chan=4(AP), iosb=iosb, -
  258.             func=#IO$_WRITEVBLK!IO$M_NOFORMAT, -
  259.             p1=(R2), p2=#1
  260.         status R0
  261.         status iosb
  262.  
  263.         call wait @#100
  264.         status R0
  265.  
  266.         incl R2
  267.         decl R3
  268.         bneq 1$
  269.  
  270.         ret
  271.  
  272.  
  273.         .sbttl Routine to flush the typeahead buffer
  274. ;
  275. ; FLUSH channel
  276. ;
  277. ; Flushes the typeahead
  278. ;
  279.         .entry flush, ^m<>
  280. 1$:        $QIOW_S chan=4(AP), iosb=iosb, -
  281.             func=#IO$_READVBLK!IO$M_PURGE!IO$M_TIMED,-
  282.             p1=expect_buffer, p2=#0, p3=#0
  283.         status R0
  284.         ret
  285.  
  286.  
  287.  
  288.         .sbttl Routine to read characters and match expected strings
  289. ;
  290. ; EXPECT chan, expect_address, timeout
  291. ;
  292. ; Expects strings to come in through the port.  expect_address is a pointer
  293. ; to an array of pointers to descriptors; zero address terminates the array.
  294. ; R0 at end gives index (plus one) of the string that matched, or zero if it
  295. ; timed out.  R1 points to string that matched or "Timed out" if timeout.
  296. ;
  297.         
  298.         .entry expect, ^m<R2,R3,R4,R5,R6,R7,R8>
  299. ;
  300. ; Read character
  301. ;
  302.         movc5 #0,#0,#0, #expect_buffer_l, expect_buffer
  303. 1$:        movc3 #31, expect_buffer+1, expect_buffer
  304.         $QIOW_S chan=4(AP), iosb=iosb, -
  305.             func=#IO$_READVBLK!IO$M_TIMED!IO$M_NOECHO, -
  306.             p1=expect_buffer+expect_buffer_l-1, p2=#1, p3=12(AP)
  307.         status R0
  308. ;
  309. ; Exit if timeout
  310. ;
  311.         cmpw iosb, #SS$_TIMEOUT
  312.         bneq 2$
  313.         movaq timeout, R1        ; R1 = timeout message
  314.         clrl R0                ; R0 = 0
  315.         ret
  316. 2$:        status R0
  317.  
  318. ;
  319. ; Search expect list for string in expect buffer
  320. ;
  321.         movl 8(AP), R7            ; R7 = base of expect list
  322.         clrl R8                ; R8 = index into expect list
  323. 4$:        movl (R7)[R8], R6        ; R6 = address of expect string
  324.         beql 5$                ; If zero get next character
  325.         cvtwl (R6), R1            ; R1 = length of string
  326.         subl3 R1, #expect_buffer_l, R2    ; R2 = position of candidate
  327.         movab expect_buffer, R0
  328.         cmpc R1, @4(R6), (R0)[R2]
  329.         beql 6$                ; compare expect with candidate
  330.         incl R8                ; R8 = next expect number
  331.         brb 4$
  332.  
  333. 5$:        brw 1$                ; No match, next please
  334.  
  335. ;
  336. ; If found, R1 = address of string, R0 = index (plus 1)
  337. ;
  338. 6$:        movl R6, R1
  339.         movl R8, R0
  340.         incl R0
  341.         ret
  342.  
  343.  
  344.  
  345.         .sbttl Routine to wait for a period of time
  346. ;
  347. ; WAIT miliseconds
  348. ;
  349.         .entry wait, ^m<>
  350.         cvtlf 4(AP), R0
  351.         mulf3 #0.001, R0, waittime
  352.         call LIB$WAIT waittime
  353.         ret
  354.  
  355.  
  356.         .end
  357.