SUBROUTINE DIAL_VENTEL C C This routine dials the phone number for the VENTEL R212A or C the VENTEL 1200-31 modems. C INCLUDE 'COM.INC/NOLIST' CHARACTER*(*) NFG_MSG, BAD_MSG PARAMETER TMO = 10 ! Read timeout count. INTEGER*4 AUTO_RETRY, STATUS PARAMETER (NFG_MSG = SS// 1 '*** The modem is not responding, aborting... ***'//BELL//SS) PARAMETER (BAD_MSG = SS// 1 '*** Bad response from the modem, aborting... ***'//BELL//SS) IF (PHONE_SIZE .EQ. 0) RETURN ! No phone number to dial. C C Setup the terminator table to terminate the read on the C VENTEL prompt character (dollar sign "$" = 36 decimal). C CALL SET_TERMINATOR(TPTR,TTBL,%REF('$')) AUTO_RETRY = 0 ! Initialize retry counter. C C Now queue up a read to the remote. C 100 IF (.NOT. POST_READ(RBUFFER,TMO,TPTR)) RETURN C C To put the VENTEL in autodial (interactive) mode, we must C send two carriage returns and then wait for the read. C XBUFFER(1) = CR ! Fill in a carraige return. CALL WRITE_REMOTE(XBUFFER(1),1) ! Second gets appended later. IF (.NOT. WAIT_FOR_READ(RBUFFER,RDESC,.TRUE.)) THEN IF (CONTROLC_TYPED) RETURN ! Return if aborted. AUTO_RETRY = AUTO_RETRY + 1 ! Bump the retry count. IF (AUTO_RETRY .EQ. AUTODIAL_LIMIT) THEN CALL WRITE_USER(NFG_MSG) RETURN ELSE GO TO 100 ! Try it again ... ENDIF ENDIF AUTO_RETRY = 0 ! Reinitialize the retry counter. C C Now we'll do a keyboard dial command. C C $ K C *** NUMBER: C CALL SET_TERMINATOR(TPTR,TTBL,%REF(':'))! Terminate read on colon. IF (.NOT. POST_READ(RBUFFER,TMO,TPTR)) RETURN ! Read the prompt echo. CALL WRITE_VENTEL(%REF('K'),1) ! Doing a keyboard dial. C C The VENTEL 212A needs a carriage return after the "K" command, C the VENTEL 1200-31 does not. C IF (AUTODIAL_TYPE .EQ. VENTEL) THEN CALL WRITE_VENTEL(CR,1) ! VENTEL needs a CR after the "K". ENDIF IF (.NOT. WAIT_FOR_READ(RBUFFER,RDESC,.TRUE.)) THEN CALL WRITE_USER(BAD_MSG) ! Tell user its no good. RETURN ENDIF C C For the VENTEL 1200-31 modem, we set the read terminator to "G" C to terminate at the end of the "DIALING" string since this modem C doesn't include a colon ":" at the end of this string. C IF (AUTODIAL_TYPE .EQ. VENTEL31) THEN CALL SET_TERMINATOR (TPTR,TTBL,%REF('G')) ! Terminate on "G". ENDIF C C Now send the phone number. C IF (.NOT. POST_READ(RBUFFER,TMO,TPTR)) RETURN ! Read "DIALING:". CALL WRITE_VENTEL(%REF(PHONE_NUMBER),PHONE_SIZE) ! Send the number. CALL WRITE_VENTEL(CR,1) ! Finish with RETURN. 300 IF (.NOT. WAIT_FOR_READ(RBUFFER,RDESC,.TRUE.)) THEN 310 CALL WRITE_VENTEL(CR,1) ! Any character to abort. CALL WRITE_USER(BAD_MSG) ! Tell user its no good. RETURN ENDIF C C Now set the read terminator to '!' or '$'. The VENTEL will display C one of the following messages after dialing: C C *** DIALING: phone_number Online! C RINGING...NO ANSWER...CALL ABORTED C DEAD PHONE....CALL ABORTED C BUSY. c If the online message was not seen, the $ prompt will appear. C c NOTE: We set 2 terminators here so either ! or $ will work. C CALL SET_TERMINATOR(TPTR,TTBL,%REF('!')) CALL SET_TERMS(TPTR,TTBL,%REF('$')) IF (.NOT. POST_READ(RBUFFER,30,TPTR)) RETURN ! Get the dial response. IF (.NOT. WAIT_FOR_READ(RBUFFER,RDESC,.TRUE.)) GO TO 310 C C If the response from the modem was no answer, try again. C If we need to redial, the response from the VENTEL is: C C $ R C *** DIALING: phone_number C IF (FIND_SUBSTRING('No answer',RDESC) .GT. 0) THEN AUTO_RETRY = AUTO_RETRY + 1 ! Bump the retry counter. IF (AUTO_RETRY .EQ. AUTODIAL_LIMIT) RETURN CALL WRITE_VENTEL(%REF('R'),1) ! Tell VENTEL to redial. CALL write_ventel(cr,1) CALL SET_TERMINATOR(TPTR,TTBL,%REF(':')) IF (.NOT. POST_READ(RBUFFER,TMO,TPTR)) RETURN GO TO 300 ENDIF C C If the modem is really online, set the flags to say so. C IF (FIND_SUBSTRING('Online!',RDESC) .GT. 0) THEN MODEM_ONLINE = .TRUE. ! Show modem is online. REMOTE = .TRUE. ! Make VMS look online. C C The VENTEL also echos once online. These C characters must be cleared to prevent auto login problems. C CALL SET_TERMINATOR(TPTR,TTBL,%REF(BELL)) IF (.NOT. POST_READ(RBUFFER,2,TPTR)) RETURN CALL WAIT_FOR_READ(RBUFFER,RDESC,.TRUE.)! Wait for the read. ENDIF RETURN END SUBROUTINE SIGNOFF_VENTEL C C This routine is used to signoff the VENTEL (place in auto-answer) C mode after hanging up the modem. C INCLUDE 'COM.INC/NOLIST' C C Since the terminal driver turns DTR off for approximatly 5 seconds, C we issue a read with this timeout. The read will be terminated by C a VENTEL prompt ($) if we were online. C CALL SET_TERMINATOR(TPTR,TTBL,%REF('$')) IF (.NOT. POST_READ(RBUFFER,5,TPTR)) RETURN ! Read the prompt (if any). CALL WAIT_FOR_READ(RBUFFER,RDESC,.TRUE.) ! Wait for the read. C C Now signoff the VENTEL by send a Q for quit. The response from C the VENTEL takes up to 3 seconds at 300 baud. C CALL WRITE_VENTEL(%REF('Q'),1) ! Tell the VENTEL to quit. CALL WRITE_VENTEL(CR,1) ! send cr to get it to terminate IF (.NOT. POST_READ(RBUFFER,5,TPTR)) RETURN ! Read the prompt (if any). CALL WAIT_FOR_READ(RBUFFER,RDESC,.TRUE.) ! Wait for the read. RETURN END SUBROUTINE WRITE_VENTEL(BUFF,BYTES) C C This routine is used to write characters to the VENTEL modem. C Each character is written with .25 second delays between them C so the VENTEL doesn't get overrun. Although the documentation C states that three nulls can be sent between characters, our C VENTEL still gets overrun. Also the computer mode sending C characters between angle brakets <...> gets overrun. C INTEGER*4 BYTES, I LOGICAL*1 BUFF(1) DO 100 I = 1,BYTES CALL WAITABIT('00.25') ! Wait for a short time. CALL WRITE_BYTE(BUFF(I),1) ! Write the next character. 100 CONTINUE RETURN END