文档章节

Serial2Ethernet Bi-redirection

zungyiu
 zungyiu
发布于 07/21 23:05
字数 972
阅读 19
收藏 0

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

© 著作权归作者所有

共有 人打赏支持
zungyiu
粉丝 11
博文 156
码字总数 35677
作品 0
深圳
Bonita 开放解决方案 5.6.2 发布

这是 Bonita 5.6 分支的最新维护版本,下载地址:here. 该版本修复了如下一些 bug: - 0005807: [console-appli] Filenames with "&" don't work. - 0008137: [studio-connectors] Groovy ......

DongZhang
2012/02/23
1K
1
Ubuntu远程桌面客户端连接WINDOWS

rdesktop 是一个在 Unix/Linux 下访问 Windows 远程桌面的客户端程序。当前,rdesktop 所支持的 Windows 系列版本包括 NT、2000、XP 和 2003。通过使用 rdesktop 所实现的远程桌面协议(RDP...

张旭0512
2014/05/21
0
2
rdesktop 1.8.2 发布,远程桌面客户端

rdesktop 1.8.2 发布,此版本更新内容如下: add support for server redirection when connecting to a Windows 2012 RDS Farm andfixes issues related to server redirection for Window......

oschina
2014/05/22
3K
14
丢弃的输出(Discard the output)(过滤的输出)

Sometimes you will need to execute a command, but you don't want the output displayed to the screen. In such cases you can discard the output by redirecting it to the file /dev/......

肖鋭
2014/06/01
0
0
WordPress实现301重定向(跳转)的5种方法

站长们都知道301对SEO的意义,特别是首页有的站长喜欢将带www的地址直接跳转到不带www的域名地址,而又有的站长则喜欢网站地址都带上www。在网站建设过程中,可能由于前期规划不到位,或者后...

English0523
2015/09/10
0
0

没有更多内容

加载失败,请刷新页面

加载更多

阿里P8架构师深度概述分布式架构

简介 作为一名架构师,我们要专业,要能看懂代码,及时光着臂膀去机房,也能独挡一面!及时同事搞不定问题,或者撂挑子,你也能给老大一个坚定的眼神:不怕,有我在!还能在会议室上滔滔不绝...

java知识分子
9分钟前
0
0
zabbix利用自带的模板监控mysql数据库

zabbix利用自带的模板监控mysql数据库                                     作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任。 有些东...

linjin200
15分钟前
0
0
当刷新的Sandbox后,需要重新发布社区

当刷新的Sandbox后,需要重新发布社区 然后在登录页面设置中选择login/forgot password

在山的那边
16分钟前
0
0
Ubuntu 镜像文件下载

https://www.ubuntu.com/download/desktop

15834278076
20分钟前
0
0
解决php -v查看到版本于phpinfo()打印的版本不一致问题

一般造成这种原因可能是升级或多版本 用php -v 和phpinfo()查出来版本不一致,怎么解决呢 编辑/etc/profile文件在最后一行添加一个环境变量: export PATH="/usr/local/php/bin:$PATH" 最后保...

xiaogg
20分钟前
0
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部