天天看點

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,如需轉載請自行聯系原作者

繼續閱讀