Terry Dawson wrote:
Del wrote:

Does anyone have a solution to this problem?

This might do what you want:

http://freshmeat.net/projects/conserver

Although it could be overkill for what you want to do.

It does the job, though.

I found a simple solution for the specific case that I was after, and that is to use gpsd. gpsd contains a client called gpspipe which can query gpsd for the raw data received on the serial port. Then it was a matter of creating a forked gpspipe process for each incoming socket connection, which socat can do:

socat -lm TCP4-LISTEN:25591,fork,reuseaddr EXEC:"/usr/bin/gpspipe -r",pty

... so every process connecting to TCP port 25591 gets its own copy of the raw NMEA data from the GPS.

conserver seems to be the solution for the general case of one serial port, multiple readers (or writers), however.

It seems a pretty simple exercise to write a small daemon program that
opens a serial port, and listens for incoming TCP connections,
multiplexing the data about as you want it though.

It's not trivial but it's possible. The problem is in giving all clients a shared buffer that they can read from and allowing each client to read from the buffer using its own read pointer but also having a single write buffer pointer. Multiple FIFOs could handle it but I'd be inclined to code something using memcached or shared memory segments. Then there's the mess of cleaning up the various forked children, scavenging their read pointers for reuse, etc.

I got part way through a perl implementation (before I discovered gpspipe and conserver) and it was a few hundred lines.

I presume you don't need two way comms, just simplex?

Yeah, in this case nobody is allowed to write to the GPS, only read from it.

--
Del
Babel Com Australia
http://www.babel.com.au/
ph: 02 9966 9476
fax: 02 9906 2864
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to