优化获取波特率的方式

This commit is contained in:
2024-07-15 01:34:57 +08:00
parent 12fe1b13c7
commit ebf06e4b0c
2 changed files with 9 additions and 4 deletions

View File

@@ -16,11 +16,11 @@
# --- ---- --- -----------
# 0.0.01 2024-07-14 Feng Bohan initial version
#===========================================================================
if [ "$#" -ne 1 ]; then
echo "错误:此脚本需要且仅需要个参数, 作为COM口号"
if [ "$#" -ne 2 ]; then
echo "错误:此脚本需要且仅需要2个参数, 作为COM口号和波特率。"
exit 1 # 使用非零状态码退出表示异常
fi
stty -F $1 speed 9600 cs8 -parenb -cstopb raw -echo -echoe -echok -echoctl -echoke
stty -F $1 speed $2 cs8 -parenb -cstopb raw -echo -echoe -echok -echoctl -echoke
echo -e "RESET!" > $1