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


Monks, =)

I've been playing around with POE and want to make a small daemon that interfaces a COM port and binds it to a tcp port. This way you can just telnet to a port from external of my machine and talk to the device connected(which in this case is a GPS receiver) to it and the app just passes the information in a nice non-blocking manner in both directions.

I have made a few scripts now that work with the clients and servers on the TCP side (with POE), but am not sure how to interface to the serial port. The POE CookBook eludes to POE having a serial port abstraction, however there isn't an example (yet...).

Can anyone point me in the direction of a POE/Serial port interface example or throw a snippet my way? I've had a bit of a look around the traps and there is lots of 'serial' stuff, but can it be done via a POE method.

The only parameters the script will have in the end are the bind port for the local TCP side of things and the port and baud etc for the serial stuff.


Any advice is appreciated.

Regards Paul

Replies are listed 'Best First'.
Re: POE & Serial Ports
by PodMaster (Abbot) on Oct 29, 2004 at 13:10 UTC
    Head on to CPAN and look for serial. Then go look at POE::Loop (and POE::Loop::*) and write your own POE::Loop (::SerialPort maybe).

    update: maybe you don't need to create your own Loop, maybe you need your own Wheel to talk to the SerialPort (that sound about right).

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: POE & Serial Ports
by rcaputo (Chaplain) on Oct 30, 2004 at 21:05 UTC

    After your e-mail haunted my inbox for a while, I decided to give serial ports a try in POE. It turns out that Device::SerialPort works with one easily worked-around hitch! I'll be documenting the problem with a testcase and sending a bug report to Device::SerialPort's author.

    Here's a program to interact with a line-based device over a serial port. Replacing the console bits with a TCP server is left as an exercise, but most of your answers are in POE's cookbook.