There is a serial port that can receive text messages from the external device. Now I want to pass these messages to a special software. But that software can only receive TCP/IP packet. For example, I can use telnet to connect it and send the text messages. Will I emulate a NIC device? Is there free software or commercial software that can do such things?
2 Answers
I'll assume linux.
First you need to identify your serial connection, usually these are of the form /dev/ttyS0
. Using dmesg | grep tty
should help find it.
Next you want to set the speed of the serial connection - 9600, 8n1 is common:
stty -F /dev/ttyS0 9600 cs8 -parenb -cstopb
Now you can read the tty with cat /dev/ttyS0
, however we want to direct anything coming in via the tty to a tcp connection. To do this we will use netcat
:
sudo apt-get install netcat # this is debian style package management, yours may differ
Now assuming your software is listening on IP address 192.168.10.1 on port 3322, we will direct the output from cat
to nc
, which is netcat, which will connect and pass the incoming traffic to the service:
cat /dev/ttyS0 | nc 192.168.10.1 3322
Check out ser2net
ser2net provides a way for a user to connect from a network connection to a serial port.