From:	CSBVAX::MRGATE!@KL.SRI.Com,@wiscvm.wisc.edu:SYSTEM@CRNLNS.BITNET@SMTP 20-OCT-1987 00:51
To:	EVERHART
Subj:	re: lines 0 and 1 on a dmf32?

Received: from wiscvm.wisc.edu by KL.SRI.COM with TCP; Mon 19 Oct 87 15:31:45-PDT
Received: from CRNLNS.BITNET by wiscvm.wisc.edu ; Mon, 19 Oct 87 16:50:04 CDT
Date:     Mon, 19 Oct 87 16:43 EDT
From:     <SYSTEM%CRNLNS.BITNET@wiscvm.wisc.edu>
Subject:  re: lines 0 and 1 on a dmf32?
To:       INFO-VAX@KL.SRI.COM
X-Original-To:  AAD+@ANDREW.CMU.EDU,AD0R@TB.CC.CMU.EDU,INFO-VAX@KL.SRI.COM,
   SYSTEM

Anthony,

I am appending a copy of a program that we received a few years
ago. It makes it possible to use a DMF32 modem port for a local
terminal after you have manufactured an appropriate cable
(described in the source code).

I hope this helps.

Selden E. Ball, Jr.
(Wilson Lab's network and system manager)

Cornell University                 NYNEX: +1-607-255-0688
Laboratory of Nuclear Studies     BITNET: SYSTEM@CRNLNS
Wilson Synchrotron Lab              ARPA: SYSTEM%CRNLNS.BITNET@WISCVM.WISC.EDU
Judd Falls & Dryden Road          HEPnet/SPAN:
Ithaca, NY, USA  14853             LNS61::SYSTEM = 44283::SYSTEM (node 43.251)
---------------------------
1       SETMODEM

     SETMODEM allows the RTS and DTR bits on ports 0 and 1 of a DMF32
to be turned on.  This is necessary if one wants to 1) connect a a
local terminal to port 0 or 1 of a DMF32, 2)use only a 4 wire cable,
and 3)Use a special purpose pigtail on port 0 and 1 to strap one of
the forced high lines (RTS or DTR) to Carrier Detect.  If carrier
Detect is not high, terminals will not talk to a DMF32 on ports 0 or 1.

     To use SETMODEM define it as a foreign command, ie.

        $SETMODEM:=$SETMODEM
and
        $SETMODEM ddcu:
where
        ddcu:   is the PHYSICAL device name of port 0 or 1 of a DMF32, ie
                TXA0: or TXA1:

----------------
      PROGRAM SET_MODEM
C+
C The function of this program is to turn on the modem control lines
C DTR and RTS comming from the DMF-32.  This is necessary because the
C DMF-32 port 0 and 1 require carrier detect (pin 8) to be present in order to
C work. We achieve this by hooking up a special null modem cable with RTS
C (pin 4) strapped to carrier detect (pin 8) so as to fool the DMF-32 into
C thinking that a modem is attached.
C
C Now if we were using a complete RS232 cable with all the wires running
C from a DMF-32 to a VT100, this would not be necessary.  However,
C we typically run only 4 wires, and ports 0 and 1 are unique in that they
C will not work unless carrier detect is present.
C
C The function of this program is to force RTS and DTR high so that they
C can be used for strapping to other lines which want to see a high signal.
C Both lines are force high so that a general purpose modem fakeout pigtail
C can be used:  Pin 4 (RTS)-to- pin 5 (CTS)  and pin 20 (DTR) -to- pin 6 (DSR)
C -to- pin 8 (CAR).  Note dip switch 8 on the DMF32 is closed which ties pin 6
C to pin 8 internally.
C
C Written by:   James G. Downward       19-Jul-1983     Make DMF32 work right
C
C-
      CHARACTER*5       Cterminal               !
      Integer*2 TTchan                  ! For assigning channel
      INTEGER*2 IOSB(4),PP1(2)          ! For QIO IOSB and param block
      INTEGER*4 P1                      ! param block needs long word
      INTEGER*4 SYS$ASSIGN              !
      INTEGER*4 SYS$QIOW                !
      INTEGER*4 LIB$GET_FOREIGN         !
      EQUIVALENCE       (P1,PP1(1))             ! only want upper half
      EXTERNAL  IO$_SETMODE,            ! For QIO function code
     -                  IO$M_SET_MODEM,         !
     -                  IO$M_MAINT              !
      EXTERNAL  TT$M_DS_DTR,TT$M_DS_RTS ! Control bits to set
      Istatus=LIB$GET_FOREIGN(Cterminal,'Terminal: ',Ilength)
      IF(.NOT. Istatus) THEN            ! If can not get command
         WRITE(*,5)                             !  then warn user
5        FORMAT(' SETMODEM  -- FATAL. No terminal specified')
         GOTO 9999                              ! Common exit
      END IF                                    !
c     Cterminal='TXA0:'
      Istatus = SYS$ASSIGN(Cterminal(1:Ilength),TTCHAN,,)! Assign channel
      IF(.NOT.Istatus)  THEN            ! If assign fails then let
         WRITE(*,10)Cterminal(1:Ilength)        ! user know which term coule
10       FORMAT(' SETMODEM  -- FATAL. Channel could not be ',
     -            'assigned to terminal ',A)    ! not be properly set up
         WRITE(*,20)Istatus                     ! and give the error code
20       FORMAT('                      Error status = ',Z10)
         GOTO 9999                              ! common exit
      END IF                                    !

C
C     The set modem function is not well explained in the manual.
C     Here is how I think it works.  A quad word is passed as a parameter
C     of the QIO call.  Nothing matters now in this quad word except the
C     bits set in the high order part of the word (bits 16-31) but
C     who knows what VMS will use the rest of the bits for.
C     If one has not explicitly set the terminal to be connected to a modem,
C     one may issue the QIO call to set and unset the various modem control
C     signals.  The bits to set to turn on or off these signals are defined
C     by TT$M_DS_RTS, TT$M_DS_DTR, and TT$M_DS_SECTX.  These bit values
C     should be applied to either the low byte of the bits 16-31 of the
C     quad word to enable the modem control bits to turn on, or the
C     high byte (bits 24-31) of the high order part of the quad word
C     to turn the modem control bits off.  Other TT$M_DS_XXXX values
C     seem defined in TT$DEF, but who knows what they are for.
C
C     Set to Set modem on bits but don't flag terminal as using modem
C
      PP1(2)=%loc(TT$M_DS_rts).or.%loc(TT$M_DS_DTR)
C
C     Pp1(2)=pp1(2)*(2**8)                      ! Shift right 8 to turn off bit
C
      IO_FUNC = %LOC(IO$_SETMODE)       .OR.    ! Set the I/O function code
     -            %LOC(IO$M_SET_MODEM)  .OR.    !
     -            %LOC(IO$M_MAINT)              !
      Istatus = SYS$QIOW (, %VAL(TTCHAN),       ! Issue the QIO
     -                     %VAL(IO_FUNC),       !
     -                     IOSB,,,              !
     -                     %REF(P1),,,,,)       !
      IF(.NOT. Istatus) THEN            ! If things do not work
         WRITE(*,30)Cterminal(1:Ilength)        !  let everyone know which
30       FORMAT(' SETMODEM  -- FATAL. Modem control bits could not',
     -            ' be set for terminal ',A)    !  terminal failed to be set
         WRITE(*,40)Istatus                     !  And give user the error code
40       FORMAT('                      Error status = ',Z10)
      END IF                                    !
      Istatus = SYS$DASSGN ( TTCHAN)            ! Deassing the channel
9999  END
-------------------------
