问题描述
我需要从Linux系统的串行端口获取数据并将其转换为TCP/IP以发送到服务器.这很难吗?我有一些基本的编程经验,但是对Linux没有太多的经验.是否有一个开源应用程序可以做到这一点?
I need to get data from the serial port of a Linux system and convert it to TCP/IP to send to a server. Is this difficult to do? I have some basic programming experience, but not much experience with Linux. Is there an open source application that do this?
推荐答案
您无需编写程序即可在Linux中执行此操作.只需管道通过 netcat :
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
只需替换地址和端口信息.另外,您可能正在使用其他串行端口(即更改/dev/ttyS0
部分).您可以使用 stty 或 setserial 命令来更改串行端口的参数(波特率,奇偶校验,停止位等).
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.).
这篇关于在Linux环境中将串行端口数据转换为TCP/IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!