---
title: "Openwrt 之 ser2net 工具"
author: "codyJava"
date: "2015-03-11T19:51:12Z"
tags: []
categories: ["开源软件"]
slug: "openwrt-ser2net"
draft: false
lastmod: "2015-03-11T19:54:03Z"
id: 2191605
url: "https://codyjava.iteye.com/blog/2191605"
---

Openwrt 常用工具之 ser2net

sourc code: http://sourceforge.net/projects/ser2net/

wiki page: http://ser2net.sourceforge.net/

The wiki page introduces what is the ser2net. - 

Serial to Network Proxy (ser2net)

ser2net provides a way for a user to connect from a network connection to a serial port.

介绍了查看串口和串口测试

http://rmingwang.com/720n-openwrt-stty-uart.html

ls /dev/ 下查看串口的名字，ttyS0，ttyATH0等。

串口测试：

echo "hello" &gt; /dev/ttyATH0 //向串口发送数据

 

这篇文章介绍了/dev/tty /dev/ttyS0 /dev/tty0区别，有助于对设备的理解

 

http://blog.sina.com.cn/s/blog\_78fe343a01017cbn.html

 

当串口可以接收到数据“hello”后，下一步就是配置ser2net,

/etc/ser2net.conf - 配置文件

修改里面的参数如下：

2001:raw:600:/dev/**ttyATH0**:9600 NONE 1STOPBIT 8DATABITS XONXOFF LOCAL -RTSCTS

tcp 端口：2001

timeout: 600

serial port: ttyATH0

波特率：9600

其余的都是停止位，传输格式之类的。保持默认就好。

修改文件：vi /etc/inittab

#ttyATH0::askfirst:/bin/ash --login  #注释此行

 

当修改好后，运行 ser2net就可以运行了。

可以通过netstat 查看端口信息

 

接上USB转TTL在PC上，引出703N的TTL，接在USB转TTL上，打开串口调试助手，在开一个TCP的client，现在就可以通过TCP client 向 703N发消息了，串口调试助手上就可以显示出来，一定要保持波特率一致