openwrt 安装 ser2net

来源:互联网 发布:校园异术超能小说知乎 编辑:程序博客网 时间:2024/05/27 19:27

一、编译安装文件
1.获取源码
ser2net源码http://sourceforge.net/projects/ser2net/files/latest/download
下载的文件: ser2net-3.5-rc2.tar.gz

2.解压安装包

tar -zxvf ser2net-3.5-rc2.tar.gz cd ser2net-3.5-rc2

3.运行源码中的configure脚本,生成对应的Makefile文件

./configure
不带参数运行,生成的Makefile运行后完成的是本地编译,编译得到的程序也是在本地执行;

./configure CC=/home/ysq/myopenwrt/staging_dir/toolchain-arm_arm926ej-s_gcc-4.8-linaro_eglibc-2.19_eabi/bin/arm-openwrt-linux-gcc–host=arm-linux
脚本带上交叉编译工具链,生成的Makefile完成的是交叉编译,编译得到的程序可以在特定的平台执行;–host指定的是交叉编译工具链的前缀;

4、执行make
编译生成可执行文件(ser2net)
make clean 等Makefile命令生成可执行文件;

二、安装到openwrt
1.拷贝文件
可执行文件(ser2net) 上传到 ARM板的/bin/ 目录下。
配置文件(ser2net.conf)上传到 ARM板的/etc/ 目录下。

三、配置文件:

vim /etc/ser2net.conf

如果有修改这个配置文件,需要重启ser2net服务。sudo service ser2net restart 重启服务。

介绍部分:

#This is the configuration file for ser2net.  It has the following format:     //这是ser2net的配置文件,格式如下#  <TCP port>:<state>:<timeout>:<device>:<options>2003:raw:0:/dev/ttySAC1:115200 8DATABITS EVEN 1STOPBIT -RTSCTS -XONXOFF LOCALport:  tcp/ip的端口号,用于接收该设备上来的连接,可以加IP信息如 127.0.0.1,2000  或者localhost,2000;  如果这里指定了IP则只能绑定在这个固定的IP上了;state :raw/  rawlp/  telnet/  off     四种可选状态; off: 禁止该端口的连接,         off   关闭端口        raw   原始数据        rawlp            telnet 使用telnet协议时用timeout:超时,以秒为单位,s ;  当没有活动的连接时。可以设置这个时间关闭端口;常写0,关闭该功能,即不会超时;<device>  指定映射本机的哪个串口 This   must be in the form of /dev/<device>  <options>options  设置波特率,奇偶校验,停止位,数据位,是否开流控,硬件流控,等#            Sets  operational  parameters  for the serial port.#            Options 300, 1200, 2400, 4800, 9600, 19200, 38400,#            57600, 115200 set the various baud rates.  EVEN,#            ODD, NONE set the parity.  1STOPBIT, 2STOPBITS set#            the number of stop bits.  7DATABITS, 8DATABITS set#            the number of data bits.  [-]XONXOFF turns on (-#            off) XON/XOFF support.  [-]RTSCTS turns on (- off)#            hardware flow control, [-]LOCAL turns off (- on)#            monitoring of the modem lines, and#            [-]HANGUP_WHEN_DONE turns on (- off) lowering the#            modem control lines when the connextion is done. #            NOBREAK disables automatic setting of the break#            setting of the serial port.#            The "remctl" option allow remote control (ala RFC#            2217) of serial-port configuration.  A banner name#            may also be specified, that banner will be printed#            for the line.  If no banner is given, then no#            banner is printed.115200 NONE 1STOPBIT 8DATABITS XONXOFF LOCAL:115200: 表示波特率为115200,NONE: 无奇偶校验,1STOPBIT: 1位停止位,8DATABITS: 8位数据位, XONXOFF:流量控制,LOCAL: 不检测modem信号线。

下面是一个配置例子,通过telnet协议,网口转usb,再通过usb转串口接线,转串口

5001:telnet:0:/dev/ttyUSB5:4800 8DATABITS NONE 1STOPBIT LOCAL banner

注意:LOCAL 必须添加,否则使用telnet登陆会闪退。提示链接被关闭的信息
 use : telnet localhost 20053 , or telnet 192.168.1.100 20053

5、运行错误处理

如果运行时出现“Error creating port lock file”错误,请确保根文件系统下有/var/lock目录。

四:配置好配置文件之后,设置开机启动

openwrt也是linux系统,linux系统开机后的会启动一系列的脚本,最后的最后会启动 /etc/rc.local 脚本;这个脚本是留给用户自定义的,所以我们可以在这个脚本的 exit(0)之前添启动ser2net的命令;/bin/ser2net -c /etc/ser2net.conf &   //&:后台启动ser2net -c指定使用的配置文件
原创粉丝点击