【linux】OPENWRT串口通信stty安装使用 概述 本文讲述如何在【linux】OPENWRT环境下安装使用stty串口通信工具对串口参数设置,并使用cat echo 命令进行串口通信。 stty安装--在线安装 在线安装 前题先连接网络 更新opkg Openwrt是基于opkg包管理,安装前先更新opkg,注意要连接网络 root@SunLink:~# opkg update Downloading http://downloads.openwrt.org/chaos_calmer/15.05.1/ramips/mt7628/pack ages/base/Packages.gz. Updated list of available packages in /var/opkg-lists/chaos_calmer_base. Downloading http://downloads.openwrt.org/chaos_calmer/15.05.1/ramips/mt7628/pack ages/base/Packages.sig. Signature check passed ...... Downloading http://downloads.openwrt.org/chaos_calmer/15.05.1/ramips/mt7628/pack ages/telephony/Packages.sig. Signature check passed. stty安装 执行命令:
root@SunLink:~# opkg install coreutils-stty Installing coreutils-stty (8.23-1) to root... Downloading http://downloads.openwrt.org/chaos_calmer/15.05.1/ramips/mt7628/pack ages/packages/coreutils-stty_8.23-1_ramips_24kec.ipk. Installing coreutils (8.23-1) to root... Downloading http://downloads.openwrt.org/chaos_calmer/15.05.1/ramips/mt7628/pack ages/packages/coreutils_8.23-1_ramips_24kec.ipk. Configuring coreutils. Configuring coreutils-stty. stt查看帮助 不会新命令都执行一下加--help参数就没错 root@SunLink:~# stty --help Usage: stty [-F DEVICE | --file=DEVICE] [SETTING]... or: stty [-F DEVICE | --file=DEVICE] [-a|--all] or: stty [-F DEVICE | --file=DEVICE] [-g|--save] Print or change terminal characteristics. Mandatory arguments to long options are mandatory for short options too. -a, --all print all current settings in human-readable form -g, --save print all current settings in a stty-readable form -F, --file=DEVICE open and use the specified DEVICE instead of stdin --help display this help and exit --version output version information and exit Optional - before SETTING indicates negation. An * marks non-POSIX settings. The underlying system defines which settings are available. Special characters:
eof CHAR CHAR will send an end of file (terminate the input) eol CHAR CHAR will end the line
erase CHAR CHAR will erase the last character typed intr CHAR CHAR will send an interrupt signal kill CHAR CHAR will erase the current line
quit CHAR CHAR will send a quit signal
start CHAR CHAR will restart the output after stopping it stop CHAR CHAR will stop the output susp CHAR CHAR will send a terminal stop signal
Special settings: N set the input and output speeds to N bauds
ispeed N set the input speed to N
min N with -icanon, set N characters minimum for a completed read ospeed N set the output speed to N
speed print the terminal speed time N with -icanon, set read timeout of N tenths of a second Control settings: [-]clocal disable modem control signals [-]cread allow input to be received
csN set character size to N bits, N in [5..8] [-]cstopb use two stop bits per character (one with '-') [-]hup send a hangup signal when the last process closes the tty [-]hupcl same as [-]hup [-]parenb generate parity bit in output and expect parity bit in input [-]parodd set odd parity (or even parity with '-')
Input settings: [-]brkint breaks cause an interrupt signal [-]icrnl translate carriage return to newline [-]ignbrk ignore break characters [-]igncr ignore carriage return [-]ignpar ignore characters with parity errors
[-]inlcr translate newline to carriage return [-]inpck enable input parity checking [-]istrip clear high (8th) bit of input characters
[-]ixoff enable sending of start/stop characters [-]ixon enable XON/XOFF flow control [-]parmrk mark parity errors (with a 255-0-character sequence) [-]tandem same as [-]ixoff Output settings:
[-]opost postprocess output
Local settings: [-]crterase echo erase characters as backspace-space-backspace
[-]echo echo input characters
[-]echoe same as [-]crterase [-]echok echo a newline after a kill character
[-]echonl echo newline even if not echoing other characters
[-]icanon enable erase, kill, werase, and rprnt special characters [-]iexten enable non-POSIX special characters [-]isig enable interrupt, quit, and suspend special characters [-]noflsh disable flushing after interrupt and quit special characters
Combination settings:
cbreak same as -icanon -cbreak same as icanon cooked same as brkint ignpar istrip icrnl ixon opost isig icanon, eof and eol characters to their default values -cooked same as raw crt same as echoe echoctl echoke dec same as echoe echoctl echoke -ixany intr ^c erase 0177 kill ^u
ek erase and kill characters to their default values evenp same as parenb -parodd cs7 -evenp same as -parenb cs8
litout same as -parenb -istrip -opost cs8 -litout same as parenb istrip opost cs7 nl same as -icrnl -onlcr -nl same as icrnl -inlcr -igncr onlcr -ocrnl -onlret oddp same as parenb parodd cs7 -oddp same as -parenb cs8 [-]parity same as [-]evenp pass8 same as -parenb -istrip cs8 -pass8 same as parenb istrip cs7 raw same as -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -opost -isig -icanon -xcase min 1 time 0 -raw same as cooked sane same as cread -ignbrk brkint -inlcr -igncr icrnl -iutf8 -ixoff -iuclc -ixany imaxbel opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke, all special characters to their default values Handle the tty line connected to standard input. Without arguments, prints baud rate, line discipline, and deviations from stty sane. In settings, CHAR is taken literally, or coded as in ^c, 0x37, 0177 or 127; special values ^- or undef used to disable special characters. GNU coreutils online help: http://www.gnu.org/software/coreutils/ Report stty translation bugs to http://translationproject.org/team/ For complete documentation, run: info coreutils 'stty invocation' stty应用举例 设置串口波特率 老规矩串口使用前先配置波特率 root@SunLink:~# stty -F /dev/ttyS2 raw speed 115200 115200 查看串口配置 root@SunLink:~# stty -F /dev/ttyS2 speed 115200 baud; line = 0; intr = ; quit = ; erase = ; kill = ; eof = ; susp = ; rprnt = ; werase = ; lnext = ; flush = ; min = 1; time = 0; -brkint -icrnl -imaxbel -opost -isig -icanon -iexten -echo Shell命令读串口(接收数据)命令 cat /dev/ttyS1 & #后台运行 Shell命令写串口(发送数据)命令 echo -e "ttyS2 Sending....." > /dev/ttyS1 |
|Archiver|手机版|深圳市光明谷科技有限公司|光明谷商城|Sunshine Silicon Corpporation ( 粤ICP备14060730号 ) |Sitemap
GMT+8, 2024-9-30 23:14 , Processed in 0.124125 second(s), 36 queries .
Powered by Discuz! X3.2 Licensed
© 2001-2013 Comsenz Inc.