linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: linux-c-programming@vger.kernel.org
Subject: Re: tcpdump equivalent for the serial port
Date: Fri, 12 Sep 2003 16:39:27 +0200	[thread overview]
Message-ID: <20030912143927.GS14376@lug-owl.de> (raw)
In-Reply-To: <3F61D6E4.2050604@abcpages.com>

[-- Attachment #1: Type: text/plain, Size: 1779 bytes --]

On Fri, 2003-09-12 16:23:32 +0200, Nicolae Mihalache <mache@abcpages.com>
wrote in message <3F61D6E4.2050604@abcpages.com>:
> Jan-Benedict Glaw wrote:
> >That way, you don't monitor the serial port itself, but the 
> >application
> >using it. For me, that has always been enough:-)
> >
> This seems a good ideea. Probably I will not use exactly strace but 
> develop something using the same library it uses.

There isn't really a library involved. strace is basically a hugh
wrapper around the ptrace() system call.

> I will still keep the cable break-out solution as an option but 
> definitely I wanted to be able to monitor the data without interfering 
> with the electic signaling on the cable.

Then you most probably want to go the preload lib way. That is, you
build a small lib containing open(), close(), read() and write() which
you call the original program with:

$ LD_PRELOAD=/path/to/your/lib.so ./serial_app

The lib needs to call the libc routines, of course. You can do this by
dlopen()ing libc (RTLD_NEXT) and get the original function (pointer)
from it (by calling dlsym()).

This way, you get access to all parameters (you're able to get the
open()ed file name, compare it to /dev/ttyS.*) and save the resultin fd
from the libc open() call.

On upcoming read()s and write()s, you simply always compare the supplied
fd with the initial fd() from the open() call to a serial device. It's
really that easy:)

MfG, JBG

-- 
   Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481
   "Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg
    fuer einen Freien Staat voll Freier Bürger" | im Internet! |   im Irak!
      ret = do_actions((curr | FREE_SPEECH) & ~(IRAQ_WAR_2 | DRM | TCPA));

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2003-09-12 14:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-12 13:37 tcpdump equivalent for the serial port Nicolae Mihalache
2003-09-12 13:50 ` Mariano Moreyra
2003-09-12 14:01   ` Nicolae Mihalache
2003-09-12 14:08     ` Mariano Moreyra
2003-09-12 14:05 ` Jan-Benedict Glaw
2003-09-12 14:23   ` Nicolae Mihalache
2003-09-12 14:39     ` Jan-Benedict Glaw [this message]
2003-09-12 15:33       ` Nicolae Mihalache
2003-09-12 14:34 ` Jamie Le Tual

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030912143927.GS14376@lug-owl.de \
    --to=jbglaw@lug-owl.de \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).