Watching serial port activity.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sergei Organov

    #16
    Re: Watching serial port activity.

    Grant Edwards <grante@visi.co m> writes:
    [color=blue]
    > On 2006-05-31, Sergei Organov <osv@javad.co m> wrote:
    >[color=green]
    >> It seems that sniff on a real tty device could be implemented using the
    >> same technique strace uses to intercept and show syscalls, though I'm
    >> not aware of any sniffer application that does it.[/color]
    >
    > Using strace you can indeed trace read/write calls on user-specified
    > file descriptors.[/color]

    I've actually meant to take strace in source code and modify it for
    particular purpose. The fact that it almost can do it in unmodified form
    is quite impressive though.
    [color=blue]
    > Figuring out which file descriptors to trace is the tricky part.[/color]

    Provided I have port name, say, /dev/ttyM0, and have running application:

    osv@osv ~$ fuser /dev/ttyM0
    /dev/ttyM0: 5134
    osv@osv ~$ ls -l /proc/5134/fd | grep /dev/ttyM0
    lrwx------ 1 osv osv 64 2006-05-29 15:33 8 -> /dev/ttyM0
    osv@osv ~$

    so I need to track fd #8 of the process with pid 5134. Guess one can
    attach to a running process as gdb does it.

    Alternatively, if the process to be sniffed sporadically opens/closes
    the port at run-time, it is required to track open()/close() syscalls as
    well as read()/write() ones, I think. Overall, seems not that trivial
    but doable.

    --
    Sergei.

    Comment

    Working...