Hello, I'm trying to configure my system such that I have a TCP port listening which will send all data it receives to a serial port.
ie: tcp/2112 --> /dev/ttyS0
My goal would be to be able to:
Use netcat to create the listen and redirect to a serial port: $ nc -l 2112 > /dev/ttyS0
Then in another window, run minicom at /dev/ttyS0
Then in a 3rd window, $ telnet localhost 2112 "Type things, hello world"
But, I can never get the text to show up in the minicom window.
I read different variations on the netcat command, including:
$ nc -l 2112 <> /dev/ttyS0 or $ nc -l 2112 > /dev/ttyS0 < /dev/ttyS0
But none seem to do the trick.
Anyone have any ideas on what I'm missing here?
Any help would be great.
Thanks!
If life gives you lemons, keep them-- because hey.. free lemons.
"~heart~ Sticker" fixer: http://microflush.org/stuff/stickers/heartFix.html
On 12/20/2013 04:13 PM, Joseph Spenner wrote:
Use netcat to create the listen and redirect to a serial port: $ nc -l 2112 > /dev/ttyS0
Then in another window, run minicom at /dev/ttyS0
Is this on the same machine? I.e. you have only one machine and one serial port?
Do you have some sort of loopback cable connected to the serial port?
If it is on two different machines I would check handshaking settings on the serial ports.
Mogens
Mogens: Thanks for reply! Here's the actual scenario:
I have a system running an application which wants to get its data from a physical serial port. My goal is to provide this data from a network connection, and ~trick~ the application into thinking it's still getting it from the serial port. Technically it is still on the serial port, but the data is arriving via TCP. So, it's all on the same machine. The idea would be for the machine to run an application, pointed at the serial port. My netcat would receive the data being pushed to it on a TCP port, and redirect it to the serial port.
If life gives you lemons, keep them-- because hey.. free lemons.
"~heart~ Sticker" fixer: http://microflush.org/stuff/stickers/heartFix.html
On Friday, December 20, 2013 8:58 AM, Mogens Kjaer mk@lemo.dk wrote:
On 12/20/2013 04:13 PM, Joseph Spenner wrote:
Use netcat to create the listen and redirect to a serial port: $ nc -l 2112 > /dev/ttyS0
Then in another window, run minicom at /dev/ttyS0
Is this on the same machine? I.e. you have only one machine and one serial port?
Do you have some sort of loopback cable connected to the serial port?
If it is on two different machines I would check handshaking settings on the serial ports.
Mogens
On Fri, Dec 20, 2013 at 10:29 AM, Joseph Spenner joseph85750@yahoo.com wrote:
Mogens: Thanks for reply! Here's the actual scenario:
I have a system running an application which wants to get its data from a physical serial port. My goal is to provide this data from a network connection, and ~trick~ the application into thinking it's still getting it from the serial port. Technically it is still on the serial port, but the data is arriving via TCP. So, it's all on the same machine. The idea would be for the machine to run an application, pointed at the serial port. My netcat would receive the data being pushed to it on a TCP port, and redirect it to the serial port.
Do you need a real serial port involved at all? It sounds like what you really want is a linux device that looks like a tty in terms of accepting ioctl's from a program that thinks it is a serial port, but actually accepts a tcp connection. I suppose you could rig a loopback cable and actually have a separate program writing to the serial port with the loopback returning it to your listening application.
On Friday, December 20, 2013 10:17 AM, Les Mikesell lesmikesell@gmail.com wrote:
On Fri, Dec 20, 2013 at 10:29 AM, Joseph Spenner joseph85750@yahoo.com wrote:
Mogens: Thanks for reply! Here's the actual scenario:
I have a system running an application which wants to get its data from a physical serial port. My goal is to provide this data from a network connection, and ~trick~ the application into thinking it's still getting it from the serial port. Technically it is still on the serial port, but the data is arriving via TCP. So, it's all on the same machine. The idea would be for the machine to run an application, pointed at the serial port. My netcat would receive the data being pushed to it on a TCP port, and redirect it to the serial port.
Do you need a real serial port involved at all? It sounds like what you really want is a linux device that looks like a tty in terms of accepting ioctl's from a program that thinks it is a serial port, but actually accepts a tcp connection. I suppose you could rig a loopback cable and actually have a separate program writing to the serial port with the loopback returning it to your listening application.
--
Les: Actually, no-- I do not really need a physical "port". It could all be virtual.
(sorry about previous 'top post'. Yahoo email has "improved" their interface making it hard to know what's going on with the thread)
On Fri, Dec 20, 2013 at 11:23 AM, Joseph Spenner joseph85750@yahoo.com wrote:
Do you need a real serial port involved at all? It sounds like what
you really want is a linux device that looks like a tty in terms of accepting ioctl's from a program that thinks it is a serial port, but actually accepts a tcp connection. I suppose you could rig a loopback cable and actually have a separate program writing to the serial port with the loopback returning it to your listening application.
Les: Actually, no-- I do not really need a physical "port". It could all be virtual.
What does the actual application do? If it is just collecting/logging data - or even something slightly more complicated you might be able to replace it with kermit (ckermit package in EPEL) which can work the same way on serial or tcp connections.
But, I think socat will do what you need if you can make it connect a PTY (perhaps with optional symlink name) with a TCP4-LISTEN, and have your application open the pty.
It is good.
On Fri, Dec 20, 2013 at 11:16 PM, Les Mikesell lesmikesell@gmail.comwrote:
On Fri, Dec 20, 2013 at 10:29 AM, Joseph Spenner joseph85750@yahoo.com wrote:
Mogens: Thanks for reply! Here's the actual scenario:
I have a system running an application which wants to get its data from
a physical serial port. My goal is to provide this data from a network connection, and ~trick~ the application into thinking it's still getting it from the serial port. Technically it is still on the serial port, but the data is arriving via TCP.
So, it's all on the same machine. The idea would be for the machine to
run an application, pointed at the serial port. My netcat would receive the data being pushed to it on a TCP port, and redirect it to the serial port.
Do you need a real serial port involved at all? It sounds like what you really want is a linux device that looks like a tty in terms of accepting ioctl's from a program that thinks it is a serial port, but actually accepts a tcp connection. I suppose you could rig a loopback cable and actually have a separate program writing to the serial port with the loopback returning it to your listening application.
-- Les Mikesell lesmikesell@gmail.com _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On 20.12.2013 15:13, Joseph Spenner wrote:
Hello, I'm trying to configure my system such that I have a TCP port listening which will send all data it receives to a serial port.
Check out socat, http://www.dest-unreach.org/socat/
On Fri, Dec 20, 2013 at 1:20 PM, Nux! nux@li.nux.ro wrote:
On 20.12.2013 15:13, Joseph Spenner wrote:
Hello, I'm trying to configure my system such that I have a TCP port listening which will send all data it receives to a serial port.
Check out socat, http://www.dest-unreach.org/socat/
It's packaged in EPEL.
On 12/20/2013 08:13, Joseph Spenner wrote:
But, I can never get the text to show up in the minicom window.
You know the aphorism about hammers and nails? minicom is an awesome hammer, and here you are, presenting a problem that calls for a ratcheting box wrench.
minicom is great for interactive use. When you want to do something programmatically, there's always a better way.
Nux's suggestion, socat, looks like a much better choice here.
I found a blog post that tells you how to create virtual serial ports connected to TCP listeners, here:
http://justcheckingonall.wordpress.com/2009/06/09/howto-vsp-socat/