Linux 设置stty参数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9092791/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:18:58  来源:igfitidea点击:

Set stty parameters

linuxbashserial-portttystty

提问by afro360

Im trying to use bash to read from ttyS0 and need to set the following but im struggling to figure it out

我试图使用 bash 从 ttyS0 读取并需要设置以下内容,但我正在努力弄清楚

databits = 7
stopbits = 2
parity = 0
flow control = 0

heres my code:

继承人我的代码:

#!/bin/bash

# Port setting
stty -F /dev/ttyS0 raw speed 1200

# Loop
while [ 1 ]; 
do
    echo 'LOADING...'
    READ=`dd if=/dev/ttyS0 count=1`
    echo $READ


echo '[PRESS Ctrl + C TO EXIT]'
done

The script is working but I need to set the parameters. Any suggestions? And thanks:)

该脚本正在运行,但我需要设置参数。有什么建议?并感谢:)

采纳答案by Ortwin Angermeier

try

尝试

stty -F /dev/ttyS0 cs7 cstopb -ixon raw speed 1200