Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

streaming of serial port data over ethernet

by amazon (Initiate)
on Nov 12, 2009 at 11:08 UTC ( [id://806685]=perlquestion: print w/replies, xml ) Need Help??

amazon has asked for the wisdom of the Perl Monks concerning the following question:

How do i accept a stream of data on my serial port and broadcast it over Ethernet
  • Comment on streaming of serial port data over ethernet

Replies are listed 'Best First'.
Re: streaming of serial port data over ethernet
by fmerges (Chaplain) on Nov 12, 2009 at 11:36 UTC

    Hi,

    Well, I think you should clarify a bit more what exactly you want to do, otherwise I can just say checkout Device::SerialPort, with this module you can read the serial port.

    If you want to broadcast... what type of broadcast, do you want clients to connect to something (server) to get the data, polling/pushing?, you could use Spread, Jabber, ActiveMQ, maybe you want to use multicast IO::Socket::Multicast, in general you should read IO::Socket::INET.

    Regards,

    fmerges at irc.freenode.net
      Hi, Thanks for the quick response, I think i was not able to put across the requirement properly. I have a device that gives output in NMEA 0183 format, which can be given to the serial port of a PC. Now, I want to transfer the NMEA information to another PC, connected to the first PC over Ethernet. So at the first PC data received over serial port is to be streamed out over Ethernet to the second PC, which should accept the information and display in cutecom.

        Hi,

        Ok, just read in wikipedia about this NMEA 0183, and it seems to be just one direction communication, from the device to listener(s), so I assume no commands are sent to the device to control it or change settings, right?

        This accept and display information in cutecom I would forget it, it even doesn't make sense anymore, as you're not connecting on the remote PC to a serial, instead you going to read on a socket to receive data.

        You can write a simple server using either TCP or UDP, and then the remote client connect to it to get pushed the telemetry data.

        For reading from the serial (via the module), you have to read data and split it in chunks or messages using the message delimiters of the protocol which are $ and &.

        If you want to make something more sophisticated you could think about writing the server using POE, so you would use the TCP server component and create a session that uses the code you write for reading from the serial. Or for example you could use something like spread, have a central server, and then have on each instrument you have a simple script that reads from serial and sends it to the Spread server, whoever wants to listen to that communication connects to the Spread server and reads from the channel(s).

        Using a TCP server you can use telnet to test it out, in case of Spread you can use spuser, in any case you can write a simple script that connects and read and dumps the data.

        What option fits best for you, is based on your requirements, also taking in mind, how many devices you want to read from, etc etc etc. Anyway apply KISS.

        Update: checkout also Net::Daemon it might simplify things for you.

        Regards,

        fmerges at irc.freenode.net

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://806685]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2025-11-12 05:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (68 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.