【发布时间】:2019-07-03 03:04:20
【问题描述】:
我正在尝试捕捉来自连接到 USB 的设备的响应。 使用此代码:
sudo stty -F /dev/ttyUSB0 speed 115200 cs8 -cstopb -parenb -echo
sudo stty raw; cat > /home/received.log < /dev/ttyUSB0
echo "Monitor started"
端口就绪后,向设备发送命令请求
echo -en '\x5A\x00\x00\x0D\x0A\x71' > /dev/ttyUSB0
然后读取日志并将响应粘贴到另一个文件中正确转换它 xxd -plain /home/received.log > /home/output.txt
所以我可以显示数据, cat -v
但我需要更稳定的东西,该代码向我显示此错误:
stty: 'standard input': Inappropriate ioctl for device
这很奇怪,因为它正在工作......
我想捕获响应并将其存储在变量中。
【问题讨论】:
-
哪个 stty 正在生成消息? stty raw 还是 stty -F ...?还有,你为什么要把你的终端设置成raw???
-
我不知道生成该消息的原因
-
我知道,你已经说过了。但是在您的帖子中,有两 (2) 个 stty 命令。哪一个导致消息显示?
-
哦,第二个
标签: linux bash raspberry-pi raspberry-pi3 stty