advice on ioctl and serial ports; creating port monitor

advice on ioctl and serial ports; creating port monitor

Post by Bret A. Schuhmach » Mon, 06 Nov 1995 04:00:00



Hi all,

I've got an internal modem and I'd like to program an interface to see
what's going on with it.  My first thought was to use ioctl() to have a
peek at it...

here's the code:

    if (ioctl( modem, TIOCMGET, &arg ) != 0) {
         printf("Error getting modem stats, exiting.\n");
         exit(1);
     }

      bits_[0] = !!(arg & TIOCM_LE);  // FG   Frame Ground
      bits_[1] = !!(arg & TIOCM_DTR);  // TxD  Transmit Data
      bits_[2] = !!(arg & TIOCM_RTS);  // RTS  Request to Send
      bits_[3] = !!(arg & TIOCM_ST);   // RxD  Receive  Data
      bits_[4] = !!(arg & TIOCM_SR);   // RxD  Receive  Data
      bits_[5] = !!(arg & TIOCM_CTS);  // CTS  Clear to Send
      bits_[6] = !!(arg & TIOCM_CAR);  // DCD  Data Carrier Detect
      bits_[7] = !!(arg & TIOCM_RNG);  // RI   Ring Indicator
      bits_[8] = !!(arg & TIOCM_DSR);  // DSR  Data Set Ready
      bits_[9] = !!(arg & TIOCM_CD);  // RI   Ring Indicator
      bits_[10] = !!(arg & TIOCM_RI);  // DTR  Data Terminal Ready

I snagged the above piece of code from a program called xosview
(apologies to the author, although I think he had some of the bits
wrong).  I'd use xosview, but the code doesn't seem to work for serial
port monitoring although it works well for everything else it does.

Compiling the above code and running it always gets me the same result
code whether the modem is connected, sending, receiving, etc.  I
always get a return value of 358 decimal (101100110 binary).

Is using ioctl the way to go?  Could the same thing be accomplished
via named pipes or is there some data stored in the /proc filesystem
that would be of use?  I'd like to get all the data above in addition
to enough data to calculate throughput.

Thanks for any ideas!

Bret

--
______________________________________________________________________________

Technical Director, WebNet Technologies          WWW:   http://www.wn.com
Voice/Fax: (214) 821-0848                        Pager: (214) 816-0283
______________________________________________________________________________

 
 
 

advice on ioctl and serial ports; creating port monitor

Post by Mark Eva » Tue, 07 Nov 1995 04:00:00



:
: Hi all,
:
: I've got an internal modem and I'd like to program an interface to see
: what's going on with it.  My first thought was to use ioctl() to have a
: peek at it...

There is a program called "statserial" which does this sort of thing.