[mod.computers.vax] Raising DTR

stokes%cmc.cdn%ubc.CSNET@RELAY.CS.NET (Peter Stokes) (01/08/87)

Hello,

Does anybody have a piece of code (MACRO, FORTRAN, C or other) to 
manually raise and drop DTR on a terminal port?  The port can  
either be a DZ-11 or DMF32 device and DTR will be low by default
(SYSGEN parameter TTY_DIALTYPE bit 1 set to 1).  It does not matter
if the port is set to MODEM or NOMODEM when this code is run.
I know I should probably make use of the IO$_MAINT function
modifier but none on the stuff on page 8.4.3.3 of the I/O Users Guide
Part One makes any sense to me... Help!


Thanks,

Peter 

Canadian Microelectronics Corporation
Envoy100: cmc.vlsiic
CDNnet:   stokes@cmc.cdn
BITNET:   stokes@qucdncmc.bitnet

McGuire_Ed@GRINNELL.MAILNET (01/08/87)

You're right, the documentation on modem control is lousy.  I went through
what you are going through last year.  CSC was some help, and they
eventually submitted an SPR on my behalf suggesting changes and
improvements to the documentation.

Rather than try to explain the whole process (and probably get some of it
wrong because it's been awhile), I'm including an example of code that
toggles DTE modem control signals on a DMZ-32, and then tests the modem's
DCE signals in order to determine whether the right thing happened.  I'm
assuming that if you were

This code is extracted from a program I developed in BASIC (permission
granted to stare in disbelief) which supports autodial from a VAX/VMS
system, including security features such as restricted access to specific
remote services by username.

Cooincidentally, I have just been asked to make some enhancements to the
program.  This means that I will be refamiliarizing myself with the
operation of all this stuff, and you're welcome to ask specific questions
if you think there is a chance I might be of some help.

Ed McGuire

McGuire_Ed%GRINNELL.MAILNET@MULTICS.MIT.EDU (MIT-MULTICS.ARPA)

********************************************************************************
Code fragment which declares some structures necessary for example
********************************************************************************

          option type=explicit

          record quad
              variant
                    case
                        byte byte0, byte1, byte2, byte3, byte4, byte5, byte6, byte7
                    case
                        word word0, word2, word4, word6
                    case
                        long long0, long4
                    end variant
              end record quad

          external long constant &
                    dia_notidle

          external long constant &
                    tt$m_ds_carrier, &
                    tt$m_ds_cts, &
                    tt$m_ds_dsr, &
                    tt$m_ds_dtr, &
                    tt$m_ds_ring, &
                    tt$m_ds_rts, &
                    tt$m_ds_secrec, &
                    tt$m_ds_sectx

          external sub &
                    lib$signal

          common &
                    quad      sensemode_block, &
                              setmode_block

********************************************************************************
Fragment of code which clears RTS, DTR, and SECTX, then tests DSR, RING,
CARRIER, and SECREC.
********************************************************************************

 idle_modem:

          ! DROP ALL MODEM SIGNALS
          setmode_block::word0 = 0%
          setmode_block::byte2 = 0%
          setmode_block::byte3 = tt$m_ds_rts or tt$m_ds_dtr or tt$m_ds_sectx
          setmode_block::long4 = 0%
          call set_modem

          ! WAIT FOR A MOMENT
          call timed_wait ("0 0:00:00.10")

          ! READ MODEM SIGNALS TO BE SURE IT'S IDLE
          call sense_modem
          call lib$signal by value (dia_notidle) if sensemode_block::byte2 and &
            (tt$m_ds_dsr or tt$m_ds_ring or tt$m_ds_carrier or tt$m_ds_secrec)

          return

********************************************************************************
Fragment of code which raises DTR and RTS.
********************************************************************************

 dial_remote:

          ! RAISE DTR AND RTS
          setmode_block::word0 = 0%
          setmode_block::byte2 = tt$m_ds_rts or tt$m_ds_dtr
          setmode_block::byte3 = 0%
          setmode_block::long4 = 0%
          call set_modem

********************************************************************************
Subroutines SET_MODEM and SENSE_MODEM, which set signals according to the
values stored in SETMODE_BLOCK
********************************************************************************

          sub set_modem

 !----------------------------------------------------------------------
 ! DECLARATIONS
 !----------------------------------------------------------------------

          %include 'common'

          ! LOCAL STORAGE
          declare &
              long &
                    s

 !----------------------------------------------------------------------
 ! MAIN CODE
 !----------------------------------------------------------------------

          s = sys$qiow (!efn!, modem_chan, io$_setmode or io$m_set_modem or &
            io$m_maint, x_iosb, !astadr!, !astprm!, loc (setmode_block), !p2!, &
            !p3!, !p4!, !p5!, !p6!)
          call lib$signal by value (dia_bugcheck, 1%, "Set_Modem" by desc, &
            dia_bugsta, 1%, "$QIOW" by desc, s) unless s and 1%
          call lib$signal by value (dia_bugcheck, 1%, "Set_Modem" by desc, &
            dia_bugsta, 1%, "$QIOW" by desc, x_iosb::s) unless x_iosb::s and 1%

          end sub
1
 !----------------------------------------------------------------------
 ! SENSE_MODEM.BAS  SENSE MODEM CONTROL SIGNALS   26-FEB-1986
 !
 !        Edward K. McGuire
 !        Grinnell College
 !        Grinnell, IA  50112
 !
 ! DESCRIPTION
 !        This routine senses the state of the modem control signals.
 !
 ! IMPLICIT INPUTS
 !        modem_chan          Channel assigned to modem
 ! SIDE EFFECTS
 !        sensemode_block     Overwritten by new modem control signal states
 !
 !----------------------------------------------------------------------

          sub sense_modem

 !----------------------------------------------------------------------
 ! DECLARATIONS
 !----------------------------------------------------------------------

          %include 'common'

          ! LOCAL STORAGE
          declare &
              long &
                    s, &
              iosb &
                    sense_iosb

 !----------------------------------------------------------------------
 ! CODE SECTION
 !----------------------------------------------------------------------

          s = sys$qiow (!efn!, modem_chan, io$_sensemode or io$m_rd_modem, &
            sense_iosb, !astadr!, !astprm!, loc (sensemode_block), !p2!, &
            !p3!, !p4!, !p5!, !p6!)
          call lib$signal by value (dia_bugcheck, 1%, "SENSE_MODEM" by desc, &
            dia_bugsta, 1%, "$QIOW" by desc, s) unless s and 1%
          call lib$signal by value (dia_bugcheck, 1%, "SENSE_MODEM" by desc, &
            dia_bugsta, 1%, "$QIOW" by desc, sense_iosb::s) unless sense_iosb::s &
            and 1%
          %if %debug
              %then
                    print "[Modem signals:";
                    print " DSR"; if sensemode_block::byte2 and tt$m_ds_dsr
                    print " RING"; if sensemode_block::byte2 and tt$m_ds_ring
                    print " CARRIER"; if sensemode_block::byte2 and tt$m_ds_carrier
                    print " CTS"; if sensemode_block::byte2 and tt$m_ds_cts
                    print " SECREC"; if sensemode_block::byte2 and tt$m_ds_secrec
                    print "]"
              %end %if

          end sub

********************************************************************************
End of example
********************************************************************************

yerazuws@CSV.RPI.EDU.UUCP (01/09/87)

In article <1314*stokes@cmc.cdn>, stokes%cmc.cdn%ubc.CSNET@RELAY.CS.NET (Peter Stokes) writes:
> Hello,
> 
> Does anybody have a piece of code (MACRO, FORTRAN, C or other) to 
> manually raise and drop DTR on a terminal port?  
	
I have an application which (from a command file) must raise and lower
DTR several times (to get the attention of the modem, insure the 
phone line disconnects, etc.).  
	
SET TERM /MODEM/PERM and SET TERM /NOMODEM/PERM raise and lower
DTR respectively.  Note that another process can do this while one 
process is running (but this needs privs).
	
This is VMS 4.4 on an AI VAXstation (uVAX II), with a DHV-11.  The
DMF32 device driver should respond similarly. 
	
	-Bill Yerazunis