Converting Serial Port Data to Tcp/Ip in a Linux Environment

Create a virtual serial port connection over TCP

Try socat. Possible scenario:

socat  pty,link=/dev/virtualcom0,raw  tcp:192.168.254.254:8080&

socat creates TCP connection to 192.168.254.254:8080, so that everything, that will be written to /dev/virtualcom0 will be forwarded to 192.168.254.254:8080 and vice versa.

Another approach would be to use RFC2217 via ser2net on Linux sever side and RFC2217 driver on Windows side (for example http://www.hw-group.com/products/hw_vsp/index_en.html single port version). You can also try to get http://pyserial.sourceforge.net/ to work with ser2net.

Virtual Serial Port on linux through TCP

In theory you could use Python with PySerial package. It can handle COM ports, RFC2217 (ser2net) and TCP raw connections (socat).

For example you would start socat on all clients with real hardware and connect to them via Python script.

This statement opens raw socket:

tcp_con = serial.serial_for_url('socket://<my_ip>:<my_port>')

Can I use a serial port as TCP/IP interface on Red Hat Linux?

You should also be able to use PPP (point-to-point protocol) to another endpoint over a serial connection.

Linux command to send data to a remote tcp-client

Install netcat

yum install nc

Make it to listen to a particular port number

nc –l portnumber &

Lets validate it using netstat from a different console:

netstat -anlp |grep yourportnumber

PS: Change the installation command based on your linux flavor.

xml messaging over serial port

The serial port is just the transport you have available. You can theoretically run just about any protocol over serial port that you could run over other communication means. Theoretically you could even run TCP/IP over bongo drums.

If the embedded device supports it, you can run TCP/IP over the serial port, and pass your XML structure over TCP/IP based protocols.

Converting serial port data to TCP/IP in a linux environment

Even if the embedded device cannot run a protocol like TCP/IP, you can still transmit XML messages over the serial port and interpret them in your C program.



Related Topics



Leave a reply



Submit