Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ucbvax.berkeley.edu.BERKELEY.EDU Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!ihnp4!ucbvax.berkeley.edu!info-vax From: info-vax@ucbvax.berkeley.edu.UUCP Newsgroups: mod.computers.vax Subject: (none) Message-ID: <8601230626.AA13794@vu-vlsi.UUCP> Date: Thu, 23-Jan-86 01:26:07 EST Article-I.D.: vu-vlsi.8601230626.AA13794 Posted: Thu Jan 23 01:26:07 1986 Date-Received: Sun, 26-Jan-86 05:42:11 EST Sender: daemon@ucbvax.berkeley.edu.BERKELEY.EDU Organization: The ARPA Internet Lines: 249 Approved: info-vax@sri-kl.arpa Subject: Re: Sensing terminal speeds on VMS Newsgroups: mod.computers.vax Summary: Here's some FORTRAN code to get the terminal baud rate References: <8601161049.AA03261@ucbvax.berkeley.edu> In article <8601161049.AA03261@ucbvax.berkeley.edu>, doug@JPL-VLSI.ARPA writes: > > How do you sense the read and write baud rates of a terminal line from > a program? It isn't reported by sensse-mode QIOs or GETDVI that I can find in > the manual. We are running VMS 4.2. It's hidden in the return status longword of sense-mode QIO! > > (-)NX in advance, > Doug Freyburger > > DOUG@JPL-VLSI.ARPA, escher!doug@cit-vax, etc. Here's some VAX FORTRAN code to read the terminal input and output speeds. The speeds are available as bytes 3 and 4 of the IO status byte returned by SYS$QUIOW when doing IO$_SENSEMODE. What's actually returned is an integer index into a speed array. DEC has defined the speed constants in the $IODEF module of FORSYSDEF.TLB, but unfortunately hasn't provided a means of translating the index back into a baud rate. I just had to do so via a hard-coded array. I doubt these are likely to change, though, since the speeds are determined by the available hardware. Note that the receive speed is rarely set; it usually just contains a 0, meaning RECEIVE=TRANSMIT. The baud rate software depends on a slightly simplified SYS$QUIO interface module called TTIO. I've included the whole TTIO module since it contains some other useful routines to read/write raw characters, set up a ^C handler, etc... (read the comments!) In case you're wondering, this code was originally written as a (slightly) smarter replacement for the INITT subroutine of PLOT10. The PLOT10 INITT provided by Tektronix (written in generic FORTRAN-'04:-) isn't smart enough to figure out the baud rate. Most student programs around here just had 1200 baud hard-coded, and would often screw up at 9600 baud. If anyone's interested, send me mail and I'll mail back my replacement INITT... ---------------------->8-->8--cut here-->8-->8-------------------------- * * Villanova University * College of Engineering * Villanova, PA 19085 * * Engineering Software Library * * * TTSPEED (adapted from ESL$INITT, a subroutine to supersede * PLOT10 INITT subroutine on VAXen) * * written 5-14-85 by Colin Kelley * modified 1-18-85 * program TTSPEED implicit none include '($iodef)' ! include 'esl$dir:[lib]tools.for' integer esl$ttio character bs ! need something to pass to TTIO !constants from *** MODULE $TTDEF *** * PARAMETER TT$C_BAUD_50 = '00000001'X * PARAMETER TT$C_BAUD_75 = '00000002'X * PARAMETER TT$C_BAUD_110 = '00000003'X * PARAMETER TT$C_BAUD_134 = '00000004'X * PARAMETER TT$C_BAUD_150 = '00000005'X * PARAMETER TT$C_BAUD_300 = '00000006'X * PARAMETER TT$C_BAUD_600 = '00000007'X * PARAMETER TT$C_BAUD_1200 = '00000008'X * PARAMETER TT$C_BAUD_1800 = '00000009'X * PARAMETER TT$C_BAUD_2000 = '0000000A'X * PARAMETER TT$C_BAUD_2400 = '0000000B'X * PARAMETER TT$C_BAUD_3600 = '0000000C'X * PARAMETER TT$C_BAUD_4800 = '0000000D'X * PARAMETER TT$C_BAUD_7200 = '0000000E'X * PARAMETER TT$C_BAUD_9600 = '0000000F'X * PARAMETER TT$C_BAUD_19200 = '00000010'X integer baud(16)/50,75,110,134,150,300,600,1200,1800,2000,2400, 1 3600,4800,7200,9600,19200/ integer ios byte iosbyte(4) ! so I can get to byte 3 equivalence (ios,iosbyte(1)) ! could now be done with STRUCTURE and ios=esl$ttio(bs,io$_sensemode,) ! MAP, right??? * * IOS is returned as: * * 31 24 23 16 15 0 * +-----------+-----------+-----------+-----------+ * | receive | transmit | status | * | speed | speed | | | * +-----------+-----------+-----------+-----------+ * ^ ^ ^ ^ * iosbyte(4) iosbyte(3) iosbyte(2) iosbyte(1) * if (iosbyte(4).eq.0) then iosbyte(4) = iosbyte(3) ! receive.eq.0 really means rec.eq.trans endif *** do something more useful here! type *,'transmit = ',baud(iosbyte(3)),'; rec = ',baud(iosbyte(4)) end ----------------------8<--8<--cut here--8<--8<-------------------------- * * Villanova University * College of Engineering * Villanova, PA 19085 * * Engineering Software Library * * ESL$TTIO - Terminal read/write procedures * R. Perry 5/13/85 * * Entry points: * * ESL$TTIO (c, code ,[time]) * read or write, optionally timed * * ESL$TTIO_GETCHAN (chan) * retrieve TT: channel number * * ESL$TTIO_CTRLCAST (crtn) * establish asynchronous CTRL/C AST handler * * ESL$TTIN (c) * read passall, noecho * * ESL$TTIN_TIMED (c, [time]) * read passall, noecho, timed * * ESL$TTOUT (c) * write * * ESL$TTOUT_CANCTRLO (c) * write, cancel ctrl/o inhibit * * where c is a character string variable (for reads) * or character string variable or constant (for writes). * The number of characters to read or write is * determined by the passed length of c. * * time is an integer variable or constant specifying a timeout * value in seconds (default=0). * * code is an integer variable or constant * specifying a DEC standard I/O function code * including any necessary modifier bits. * * chan is an integer variable to receive the TT: channel * number used in the ESL$TTIO routines. * If a channel has not already been assigned, one * will be created via sys$assign. * * crtn is an external asynchronous completion routine * that will be invoked upon user entry of CTRL/C * after establishment via ESL$TTIO_CTRLCAST * * Return function value for ESL$TTIO_GETCHAN is always esl$_success. * Return function value for the other entry points is the first element of * the I/O status argument from sys$qiow. For timed I/O this value will test * .TRUE. if the operation was successful. The low-order word of the result * represents the I/O status and the high-order word represents the number of * characters actually transferred to or from the terminal. * * If sys$qiow return value is not normal, or, on the first entry, * if sys$assign fails to assign a channel, then the routine will stop * and display an error dump. * * adapted from [Kresch]get.for integer function esl$ttio(c,code,time) implicit none include '($iodef)' ! include 'esl$dir:[lib]tools.for' integer esl$ttin_timed,esl$ttin,esl$ttout,esl$ttout_canctrlo, 1 esl$ttio_getchan,esl$ttio_ctrlcast character c*(*) integer ch, chan, code, code$$, time, time$$, status integer iosb(2), sys$qiow logical first/.true./ external crtn code$$=code goto 44 entry esl$ttin_timed(c,time) ! timed read noecho, passall code$$=io$_ttyreadall.or.io$m_noecho.or.io$m_timed 44 time$$=0 if( %loc(time).ne.0) time$$=time goto 88 entry esl$ttin(c) ! read noecho, passall code$$=io$_ttyreadall.or.io$m_noecho goto 66 entry esl$ttout_canctrlo(c) ! write, cancel ctrl/o code$$=io$_writevblk.or.io$m_canctrlo goto 66 entry esl$ttout(c) ! write code$$=io$_writevblk 66 time$$=0 88 if( first) call esl$ttio_sysassign(first,ch) status=sys$qiow(,%val(ch),%val(code$$),iosb,,,%ref(c), 1 %val(len(c)),%val(time$$),,,) if( .not. status ) call lib$stop(%val(status)) esl$ttio=iosb(1) return entry esl$ttio_getchan(chan) if( first) call esl$ttio_sysassign(first,ch) chan=ch esl$ttio=1 !esl$_success return entry esl$ttio_ctrlcast(crtn) if( first) call esl$ttio_sysassign(first,ch) code$$=io$_setmode.or.io$m_ctrlcast status=sys$qiow(,%val(ch),%val(code$$),iosb,,,crtn,,%val(3),,,) if(.not.status) call lib$stop(%val(status)) esl$ttio=iosb(1) return end subroutine esl$ttio_sysassign(first,ch) implicit none include '($iodef)' integer ch, status, sys$assign logical first first=.false. status=sys$assign('tt',ch,,) if( .not. status ) call lib$stop(%val(status)) return end