PDA

View Full Version : serial port - read chars twice



matze
12-07-2007, 05:56 AM
Hi

I'm new to linux programming and have a few questions regarding serial ports.

My goal is to monitor a ttyS.
I work on an embedded system which has a ppp connection via modem. During an established ppp connection I need to check the traffic between ppp process and modem. (The modem is allowed to send state information and ppp frames at same time)

Is it possible to read from file descriptor without removing the characters from input stream? I don't want to change anything in ppp implematation. I already checked a lot of techniques to handle serial ports but the key issue is always the same. When I read from the stream I steal the input and destroy the ppp frames.

many thanks in advance
Matze

matsp
12-07-2007, 07:32 AM
You can't, trivially, do that.

You may be able to create a pseudo-device that allows you to duplicate the traffic somehow, or modify your serial port driver so that it stores the data in some way [if this is needed for debug purposes, I would recommend introducing a new set of IOCTL calls:
IOCTL A takes a buffer and/or buffersize, and sets a flag to store data in the buffer [perhaps allocated by the driver].
IOCTL B reads data from the buffer [including a count of how much data you got out of the buffer].
IOCTL C stops the storing (clears said flag) and if necessary deallocates the buffer.

--
Mats