Serial2Ethernet Bi-redirection

Serial Tool is a utility for developing serial communications, custom protocols or device testing. You can set up bytes to send accordingly to your protocol and save configuration to a file – which can be used another time.
You can send multiple byte arrays, you can send sequence of different byte arrays and put delay between them. You can read data in HEX or ASCII. You can even write a note to yourself like: “CH1: toggle LED 1”. GitHub

tcp2com creates a bridge between a TCP socket and a serial port (COM). The program runs as a service under Windows NT. With tcp2com, you can telnet into any device you may have plugged into your COM port.

A very simple software that bidirectionally forwards COM (serial) communication through a TCP/IP connection.

 

ScriptCommunicator is a scriptable cross-platform data terminal which supports serial port (RS232, USB to serial), UDP, TCP client/server, SPI, I2C and CAN.

ScriptCommunicator (scriptable data terminal) script which routes:
- serial port (RS232, USB to serial) <-> TCP/IP (Client/Server)
- serial port (RS232, USB to serial) <-> UDP/IP
- TCP/IP (Client/Server) <-> UDP/IP

Serial port sniffer, network serial server/client and serial port emulator Serial port sniffer, network serial server/client and serial port emulator

You can achieve this with standard tools using socat and tee.

1) socat -d -d pty,raw,echo=0 pty,raw,echo=0. The output will give you two ports ...N PTY is /dev/pts/27... N PTY is /dev/pts/28.

2) sudo cat /dev/ttyS0 | tee /dev/pts/27 and in another terminal sudo cat /deb/pts/27 | tee /dev/ttyS0. Finally

3) Connect your program to /dev/tty/28.

The two tee commands will dump both directions to the console and forward to/from the actual serial port. Note that the port settings like baudrate must be configured ahead of time. – jtpereyda Jul 18 '15 at 0:36
You can save the tee stuff to a file, too: cat /dev/pts/27 | sudo tee /dev/ttyS0 serial-caps and xxd will help if it's a binary protocol: cat /dev/pts/27 | sudo tee /dev/ttyS0 serial-caps | xxd

There are a few options:

sersniff is a simple program to tunnel/sniff between 2 serial ports.

Serial line sniffer (slsnif) is a serial port logging utility. It listens to the specified serial port and logs all data going through this port in both directions.

Serial to Network Proxy (ser2net) provides a way for a user to connect from a network connection to a serial port. For more: here

SerialSpy acts as a serial pass-through device. It listens for incoming data on two serial ports and forwards it so the devices act as if they are directly connected. It also logs the data as it moves through the ports.

sercd is an RFC 2217-compliant serial port redirector. It lets you share a serial port through a network. It is based on sredird. The RFC2217 protocol is an extension to telnet and allows changing communication port parameters.

SerLooK is a KDE application for inspecting data going over serial lines. It can work as a binary terminal that sends and receives data through a defined port (Point to Point mode) and displays them on separate views. Each view can be configured to display data in hexadecimal, decimal, octal, binary, and raw ASCII. It is also possible to perform I/O through terminal emulation views and define a secondary port and monitor the traffic between two external hosts using a "Y" cable (Snooper mode).

nullmodem creates a virtual network of pseudo-terminals. It can be used as an adapter to connect two programs that normally need serial interface cards.

ttywatch monitors, logs, and multiplexes terminal I/O. It has full log rotation built in, and can use telnet as well as local TTY ports.

  • Linux sreen command

screen -L /dev/ttySx > logging file

Example for remote tty (tty over TCP) using socat

#### Method xx

You don't need to write a program to do this in Linux. Just pipe the serial port through netcat:

netcat www.example.com port </dev/ttyS0 >/dev/ttyS0

Just replace the address and port information. Also, you may be using a different serial port (i.e. change the /dev/ttyS0 part). You can use the stty or setserial commands to change the parameters of the serial port (baud rate, parity, stop bits, etc.).

 

 

####Method 1

All the tools you would need are already available to you on most modern distributions of Linux.

As several have pointed out you can pipe the serial data through netcat. However you would need to relaunch a new instance each time there is a connection. In order to have this persist between connections you can create a xinetd service using the following configuration:

service testservice
{
    port        = 5900
    socket_type = stream
    protocol    = tcp
    wait        = yes
    user        = root
    server      = /usr/bin/netcat
    server_args = "-l 5900 < /dev/ttyS0"
}

Be sure to change the /dev/ttyS0 to match the serial device you are attempting to interface with.

https://stackoverflow.com/questions/484740/converting-serial-port-data-to-tcp-ip-in-a-linux-environment

####Method 2

Open a port in your server with netcat and start listening:

nc -lvp port number

And on the machine you are reading the serial port, send it with netcat as root:

nc <IP address> portnumber < /dev/ttyACM0

If you want to store the data on the server you can redirect the data to a text file.

First create a file where you are saving the data:

touch data.txt

And then start saving data

nc -lvp port number > data.txt

转载于:https://my.oschina.net/zungyiu/blog/1860772

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值