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

Hello everyone, I'm relatively new at perl as I've only used it a couple of times to perform simple tasks, like capturing serial data and outputting to a file, replacing some strings, or add some timestamps. I'm in desperate need of an tcp/ip to rs-232 redirect program. That is to say, i have an application that connects to a tcp/ip host and sends/receives data. I need this data to be output to a COM port on the same machine WITHOUT any modification. That is to say, whatever arrives to the tcp socket i need it to be sent immediately (without waiting for a specific character) to the com port and vice versa. I have found several links to tcp servers and serial port loggers but nothing complete that will perform the task i'm interested in. Could someone please help me? I'm using FreeBSD 6.2 Any help will be greatly appreciated. Best regards, Thanos

Replies are listed 'Best First'.
Re: tcp/ip to rs232 redirect
by ig (Vicar) on Jan 29, 2009 at 04:35 UTC
Re: tcp/ip to rs232 redirect
by pileofrogs (Priest) on Jan 28, 2009 at 23:09 UTC

    Since you've asked a general question, I'll give you a general answer.

    I'd say, rather than asking for a complete solution, you could build your solution from the blocks you already have. So, make a script that does the tcp/ip bit, then once that's working, do the com port stuff. If you have tcp servers and serial loggers to pick over, that should be all you need.

    Once you get started and you have more questions, post 'em.

    --Pileofrogs

Re: tcp/ip to rs232 redirect
by rcaputo (Chaplain) on Jan 29, 2009 at 17:26 UTC

    The trivial case is easy with something like POE, but how do you plan to handle flow control? For example, what will you do if your 100 megabit/sec network device provides data faster than you can write to your 115.2 kilobit/sec serial device?

    Your description implies that flow control won't be a problem in the other direction, but we don't know whether the client has its own timing requirements or bandwidth limits. For all we know, your client may also be attached to a serial device.

    The trivial case won't preserve timing, which can often be an issue with serial data. If timing is important to you, this will complicate the TCP application protocol.

    The timing problem gets significantly worse if your serial device doesn't support flow control at all.