linux下串口转TCP/IP的终端服务器实现

串口与网络IP、端口号完成映射的脚本。希望对大家有帮助

[root@localhost bash_doc]# cat ./ttyusb.sh 
#!/bin/bash

TCP_PORT=5021
SERIAL_PORT=/dev/ttyUSB0
BAUDRATE=9600

while (true)
    do 
    stty -F $SERIAL_PORT $BAUDRATE
    stty -F $SERIAL_PORT line 0
    stty -F $SERIAL_PORT eof ^A
    stty -F $SERIAL_PORT min 1
    stty -F $SERIAL_PORT time 0
    stty -F $SERIAL_PORT -brkint
    stty -F $SERIAL_PORT -icrnl
    stty -F $SERIAL_PORT ixoff
    stty -F $SERIAL_PORT -imaxbel
    stty -F $SERIAL_PORT -opost
    stty -F $SERIAL_PORT -onlcr
    stty -F $SERIAL_PORT -isig
    stty -F $SERIAL_PORT -icanon
    stty -F $SERIAL_PORT -iexten
    stty -F $SERIAL_PORT -echo
    stty -F $SERIAL_PORT -echoe
    stty -F $SERIAL_PORT -echok
    stty -F $SERIAL_PORT -echoctl
    stty -F $SERIAL_PORT -echoke

    nc -l 192.168.1.33 $TCP_PORT < $SERIAL_PORT > $SERIAL_PORT
done
 




本文转自 tiger506 51CTO博客,原文链接:http://blog.51cto.com/tiger506/564710,如需转载请自行联系原作者

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值