Port I/O Monitoring

Port I/O Monitoring

Post by David Poerazaff - CNED/W » Thu, 17 Aug 1995 04:00:00



I have to write a program in C on a unix platform that will monitor a
specified tty2 port at all times. It will read a data stream from the port in
the format

STX,NAME,QTY CRLF

The communication parameters are:

        Speed   9600
        Parity  Even
        Data    7
        Stop    2

The monitor will read whenever data stream comes and it will write to an
ascii file, the data stream without STX.

Can anyone give help me with this module.

Thanks

--
===================================
David Poerazaff
Ryerson Polytecchnic University
Toronto, Ontario
Canada


===================================

 
 
 

1. advice on ioctl and serial ports; creating port monitor

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
______________________________________________________________________________

2. Intel AGP systems, good for Linux?

3. port monitor tag tcp failed,no access to parallel port

4. Help on 3-button mouse

5. monitoring and logging CTS on a serial port

6. PPP & SLACKWARE 96

7. Problem adding tty port using 128 Port Async Adapter with 16 port Async Node

8. patch clusters

9. Using a laptop's external monitor port under Linux

10. serial port monitoring

11. serial port monitor

12. Unix Port Alarm Monitoring

13. tli rpc, tcp keepalive, and port monitor problem