serial port - read chars twice

This is a discussion on serial port - read chars twice within the Linux Programming forums, part of the Platform Specific Boards category; Hi I'm new to linux programming and have a few questions regarding serial ports. My goal is to monitor a ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    1

    Question serial port - read chars twice

    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

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    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
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Serial Port Questions
    By valaris in forum Tech Board
    Replies: 2
    Last Post: 05-22-2009, 08:26 AM
  2. Serial port read() blocking
    By DavidDobson in forum C Programming
    Replies: 8
    Last Post: 04-01-2009, 10:45 AM
  3. Serial port Communication
    By vin_pll in forum C++ Programming
    Replies: 23
    Last Post: 01-07-2009, 08:32 AM
  4. serial port read
    By mackrackit in forum C++ Programming
    Replies: 6
    Last Post: 03-22-2006, 12:40 AM
  5. How to read from a serial port
    By WDT in forum C++ Programming
    Replies: 6
    Last Post: 05-10-2004, 06:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21