[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

Fortran sys$qiow IO$_SETMODE TT$M_PARITY?

» close window

The Question is:

 
I use a modem connected on a serial port.
 
I try to change length buffer from 7 to 8, and parity from even to none, using
 IO$_SETCHAR command.
The programmation language is Fortran.
 
Length buffer change works correctly, but parity change is unsuccessfull.
 
Can you tell me if the following program is correct, specially for changing
 parity ?
 
 
        STRUCTURE /Characteristics/
           INTEGER*1 Class,Type
           INTEGER*2 Width
           INTEGER*4 Basic
        END STRUCTURE
 
        RECORD /Characteristics/ CharBuf
 
        INTEGER*2 Channel
        INTEGER*4 IO_Function,Io_Parity
        REAL*8    Iost_q
 
        IO_Function = %LOC(IO$_SENSECHAR)
        Sta = SYS$QIOW(,%VAL(Channel ),%VAL(IO_Function)
        1,             %REF(iost_q),,,CharBuf,%VAL(8),,,,)
 
 
        CharBuf.Basic = IBSET(CharBuf.Basic,%LOC(TT$V_EIGHTBIT))
 
c translation in fortran of the instruction given in IO User's Reference c
 Manuel, Section 5.4.3,  "insv    iosb+6, #4, #8, flags", supposing "iosb" is c
 the address of the buffer issued c  from IO$_SENSECHAR command
        CALL MVBITS(CharBuf.Basic,20,8,Io_Parity,0)
 
        IO_Parity = IBCLR(IO_Parity,%LOC(TT$V_PARITY))
        IO_Function = %LOC(IO$_SETCHAR)
 
        Sta = SYS$QIOW(,%VAL(Channel ),%VAL(IO_Function)
        1,            REF(iost_q),,,%REF(Charbuf),%VAL(8),,,%VAL(IO_Parity),)
 
 
To perform the reverse change, the program is the same except :
 
        CharBuf.Basic = IBCLR(CharBuf.Basic,%LOC(TT$V_EIGHTBIT))
        IO_Parity = IBSET(IO_Parity,%LOC(TT$V_PARITY))
 
 
Thanks you for your help.
 
 


The Answer is :

 
 
PROGRAM:
 
 
c                            COPYRIGHT (C) 1996 BY
c                      DIGITAL EQUIPMENT CORPORATION, MAYNARD
c                       MASSACHUSETTS.  ALL RIGHTS RESERVED.
 
c    THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
c    ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE INCLUSION
c    OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY OTHER COPIES
c    THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER
c    PERSON.  NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED.
 
c    THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
c    SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
 
c    DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
c    SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY DIGITAL.
 
c    NO RESPONSIBILITY IS ASSUMED FOR THE USE OR RELIABILITY OF SOFTWARE
c    ON EQUIPMENT THAT IS NOT SUPPLIED BY DIGITAL EQUIPMENT CORPORATION.
 
c    SUPPORT FOR THIS SOFTWARE IS NOT COVERED UNDER ANY DIGITAL SOFTWARE
c    PRODUCT SUPPORT CONTRACT, BUT MAY BE PROVIDED UNDER THE TERMS OF THE
c    CONSULTING AGREEMENT UNDER WHICH THIS SOFTWARE WAS DEVELOPED.
 
 
c      To demonstrate this program at your terminal, set the parity of
c      the current terminal port to NONE, like this:
 
c      $ SET TERMINAL/PARITY=NONE
 
c      and enter
 
c      $ SHOW TERMINAL
 
c      to verify that your parity is set to NONE.  Next run this
c      program, and enter
 
c      $ SHOW TERMINAL
 
c      again to verify that the terminal is set to ODD parity.  You
c      may then reset your terminal to the parity that you normally
c      run at.
 
c      NOTE:  Setting the terminal parity is NOT supported by LAT terminals.
 
      program set_par
      implicit none
 
      structure / iosb_struct /      ! IOSB data structure
            integer*2 status
            byte        transmit_speed
            byte        receive_speed
            byte        cr_fill_count
            byte        lf_fill_count
            byte        parity_flags
            byte        always_zero
      end structure
 
      structure / term_char_struct /      ! Terminal Characteristics
            byte        class
            byte        type
            integer*2   buffer_size
            byte        basic_term_char(3)
            byte        page_length
            integer*4   extended
      end structure
 
      integer*4   set_parity, istat, qio_chan, sys$assign,
     1            sys$qiow, lib$stop
 
      record / iosb_struct / iosb
      record / term_char_struct / term_char
 
      include         '($iodef)'
      include         '($ttdef)'
 
c     Get the QIO channel number
 
      istat=sys$assign('tt',qio_chan,,)
      if (.not. istat) call lib$stop(%val(istat))
 
c     Get the current terminal characteristics using a
c     SENSEMODE QIOW
 
      istat=sys$qiow(,%val(qio_chan),%val(io$_sensemode),iosb,
     *                  ,,term_char,%val(12),,,,)
      if (.not. istat) call lib$stop (%val(istat))
 
c     Display the current parity flags
 
      write (6,50)iosb.parity_flags
50    format(' Current parity of terminal:',z3,' (HEX)')
      type *
 
c     Set the SET_PARITY variable to indicate that you desire
c     to set the parity of the current terminal to ODD.
 
      set_parity = (tt$m_altrpar .or. tt$m_odd .or. tt$m_parity)
 
c     Do a SETMODE QIOW to set the terminal to ODD parity
c     as indicated by the P5 parameter of the QIOW.
 
      istat=sys$qiow(,%val(qio_chan),%val(io$_setmode),,
     *                  ,,term_char,%val(12),,,%val(set_parity),)
      if (.not. istat) call lib$stop (%val(istat))
 
c     Get the terminal characteristics again.
 
      istat=sys$qiow(,%val(qio_chan),%val(io$_sensemode),iosb,
     *                  ,,term_char,%val(12),,,,)
      if (.not. istat) call lib$stop (%val(istat))
 
c     Print out the present terminal characteristics.
 
      type *,'The following IOSB values are all in HEXADECIMAL:'
      type *
      write(6,10)' iosb - status:          ',iosb.status
      write(6,10)' iosb - transmit speed:  ',iosb.transmit_speed
      write(6,10)' iosb - receive speed:   ',iosb.receive_speed
      write(6,10)' iosb - CR fill count:   ',iosb.cr_fill_count
      write(6,10)' iosb - LF fill count:   ',iosb.lf_fill_count
      write(6,10)' iosb - parity flags:    ',iosb.parity_flags
      write(6,10)' iosb - always zero:     ',iosb.always_zero
      type *
      type *,'The following TERMINAL CHARACTERISTICS are all in',
     *             ' HEXADECIMAL, except for'
      type *,' BUFFER SIZE and PAGE LENGTH, which are in DECIMAL:'
      type *
      write(6,10)' term char - class:      ',term_char.class
      write(6,10)' term char - type:       ',term_char.type
      write(6,20)' term char - buffer size:',term_char.buffer_size
      write(6,40)' term char - basic term: ',
     *            term_char.basic_term_char(1),
     *            term_char.basic_term_char(2),
     *            term_char.basic_term_char(3)
      write(6,20)' term char - page length:',term_char.page_length
      write(6,30)' term char - extended:   ',term_char.extended
 
10    format (a,'  ',z2.2)
20    format (a,'  ',i4.4)
30    format (a,'  ',z8.8)
40    format (a,'  ',z2.2,z2.2,z2.2)
 
      end
 

answer written or last revised on ( 21-JUN-2001 )

» close window