 |
» |
|
|
 |
Ask the Wizard Questions
DCL: Access a modem
The Question is:
Is there a DCL way to talk to a modem hanging off a
serial port on a VAXstation? I need to write some code
that will sequentially dial a series of numbers, wait
for answer, check for correct response from, hang up
and then go to the next modem. I know I can manually
do this with the SET HOST/DTE TTA2.
Thanks
The Answer is:
The following should get you started.
$ open/read/write modem _tta0:
$ write modem "ATDT ''number'"
$ read modem response
$ close modem
You need to add the logic to check the response move on to the next
number etc. You should be able to dial, hang up, and read messages
from the modem with no problems. Doing real data communications this
will leave you a little short.
I like to use a timeout on the READ and a read loop to handle
multi line responses. Here's part of a command procedure I use to
dial out. Of course, you could quieten it down a bit by removing the
SHOW SYMBOL commands, but I like to see what's going on.
$ SET NOON
$ modem="TTA2:"
$ cr[0,8]=13
$ Retry: ON WARNING THEN GOTO Retry
$ ALLOCATE 'modem'
$ SET NOON
$ SET TERMINAL/HOSTSYNC/TTSYNC/TYPEAHEAD/NOLOCAL/PASTHRU/NOECHO 'modem'
$ SHOW TERM 'modem'
$ INQUIRE ans "turn modem on and hit return"
$ WRITE SYS$OUTPUT "Setting up modem""
$ OPEN/READ/WRITE modem 'modem'
$ CALL TellModem "atq0v1e1"
... other setups...
$ CLOSE modem
$ DEFINE/USER SYS$INPUT SYS$COMMAND
$ SET HOST/DTE 'modem'
...
$ EXIT
$!
$!
$ TellModem: SUBROUTINE
$ WRITE SYS$OUTPUT "Sending modem ''p1'"
$ READ/TIME=1/ERR=noresp/PROMPT="''p1'''cr'" modem response
$ SHOW SYMBOL response
$ retry: READ/TIME=1/ERR=endresponse/PROMPT="" modem response
$ SHOW SYMBOL response
$ GOTO retry
$ noresp:
$ stat=$STATUS
$ WRITE SYS$OUTPUT "No response, status=''stat'"
$ endresponse: EXIT
$ ENDSUBROUTINE
|