	SUBROUTINE DIAL_DF03
C
C	This routine dials the phone number for the DEC DF03 modem.
C
	INCLUDE 'COM.INC/NOLIST'

	CHARACTER*(*) AUTO_NFG, CONNECTION_NFG

	INTEGER*4 AUTO_RETRY, STATUS

	PARAMETER (AUTO_NFG = SS//
	1 '*** The modem is not responding, aborting... ***'
	1 //BELL//SS)
	PARAMETER (CONNECTION_NFG = SS//
	1 '*** Connection was not established. ***'//BELL//SS)

	AUTO_RETRY = 0			! Initialize the retry count.
C
C	We now have the phone number.  First, we send a CTRL/A to put the
C	ACU in a known state (this aborts the ACU).
C
200	CALL SEND_SOH			! Send a CTRL/A (SOH).
C
C	Now dial the phone number.  The number is preceeded by a CTRL/B.
C
	CALL SEND_STX			! Send the CTRL/B (STX).
	CALL WRITE_BYTE(%REF(PHONE_NUMBER),PHONE_SIZE)
	XBUFFER(1) = '<'		! Transfer line immediatly.
	CALL WRITE_REMOTE(XBUFFER(1),1)	! Send the "<" and RETURN.
C
C	The response from the ACU will be one of the following:
C
C	A - connection has been established.
C	B - connection was not established.
C	G - the ACU has control.  Must send CTRL/A to abort.
C
C	Our DF03 is configured to timeout after 27 seconds.  In case
C	the ACU doesn't respond, we have our own timer.
C
	RBUFFER(1) = 0			! Init receive buffer.
	STATUS = SYS$QIOW(%VAL(REFN_IN),%VAL(RCHAN_IN),
	1	%VAL(IO$_READLBLK + IO$M_NOECHO + IO$M_TIMED),
	1	RIOSB,,,RBUFFER,%VAL(1),
	1	%VAL(AUTODIAL_TIMEOUT),NOTERM,,)
	IF (CONTROLC_TYPED) RETURN	! Return if aborted.
C
C	Now, check the response from the ACU.
C
	IF (RBUFFER(1) .EQ. 'A') THEN	! ASCII 'A' = success.
		REMOTE = .TRUE.		! Show modem is connected.
		MODEM_ONLINE = .TRUE.	! Show the modem is online.
	ELSEIF (RBUFFER(1) .EQ. 'B') THEN ! ASCII 'B' = failure.
		AUTO_RETRY = AUTO_RETRY + 1 ! Bump the retry count.
		IF (AUTO_RETRY .EQ. AUTODIAL_LIMIT) THEN
			CALL WRITE_USER (CONNECTION_NFG)
		ELSE
			GO TO 200	! Try it again ...
		ENDIF
	ELSE
		CALL WRITE_USER (AUTO_NFG) ! Givem the bad news.
	ENDIF
	RETURN
	END
