[ale] Getting bytes from a port

Mike Kachline kachline at brightstar.gt.ed.net
Wed Aug 2 15:55:35 EDT 2000


On Wed, 2 Aug 2000, Chris Fowler wrote:

> I need some help with some code.
> 
> 
> I would like to attach to a serail port and capture all data on it that
> comes and goes to the application.  How can I do this if the app is blocking
> for data.  I want to read what is on the port but not take it away?  Anyone
> know how I can do this?
<snip>
	Chris,

	Just to recap what you are asking, are you asking "How do I
non-obtrusively sniff data off of a serial port?"

	As a "short and simple" answer, I do not know of a way to
effectively "tee" data from a COM port to some other device, file, or
whatnot. A quick look through the linux kernel sources shows that
"gs_chars_in_buffer()" (see linux/generic_serial.h) may have some
potential, but, I've never used it before. :( If you find a way to do
this (or anyone else posts such), such information would be highly
appreciated by myself too!


	An alternative solution which I can think of off the top of my
head would be to write a "sniffer" program which reads from /dev/ttyS[N],
and then write to a pseudo TTY. Configure your application to then
read/write to the pseudo TTY as if it were a COM port. This solution
effectively puts your "sniffer" application in between the remote end
(coming in from the COM cable) and your local application. The
disadvantage being that it's a bit more difficult to handle the "out of
band signalling" (ie, ioctl's) which *may* be performed on COM ports, and,
of course that you've got to convince your application to talk to a PTY,
and not a ttyS.

		???,
			- Mike
======================================
Michael Kachline 
mailto:kachline at brightstar.gt.ed.net
http://brightstar.gt.ed.net/kachline
======================================

--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list