![将文本复制或重定向为 UART 的输入,需要强制降低带宽](https://linux22.com/image/112205/%E5%B0%86%E6%96%87%E6%9C%AC%E5%A4%8D%E5%88%B6%E6%88%96%E9%87%8D%E5%AE%9A%E5%90%91%E4%B8%BA%20UART%20%E7%9A%84%E8%BE%93%E5%85%A5%EF%BC%8C%E9%9C%80%E8%A6%81%E5%BC%BA%E5%88%B6%E9%99%8D%E4%BD%8E%E5%B8%A6%E5%AE%BD.png)
基本上我已经厌倦了输入大量文字。显然想将其输入文件中,将其推送到UART U-Boot,然后修改文件,再试一次。
但 Shift+Ctrl+C 都无法screen ttyUSB0 115200
正常工作,或者cat file.cmd > ttyUSB0
.
有人有复制到 UART 的奇特方法吗?我不可能是唯一一个尝试做这样的事情的人。
答案1
好吧,必须制作一个小脚本来做到这一点,呃,足够好了:
cat > slowpipe << 'EOF'
#!/usr/bin/env bash
set -eu
data=$(< /dev/stdin)
hz=$(bc -l <<< "1.0 / $1")
while [ -n "$data" ]; do
printf '%s' "${data:0:1}"
data=${data:1}
sleep $hz
done
# XXX It seems to be imposible to save leading newlines in variables,
# you cant have var=$'\n'$'\n' no mater what you do, only one new line can will
# be saved, IFS won't help, or anything. one way is to use `read`, without
# saving all stdin to variable.
echo
EOF
chmod 755 slowpipe
./slowpipe 42 < rpi.cmd >> /dev/ttyUSB0