【发布时间】:2016-04-11 21:12:20
【问题描述】:
我使用 lirc 和 raspberrypi 构建了一个乐高遥控器。
一切正常,但现在我遇到了问题。火车不断需要红外信号。我写了这个脚本:
#!/bin/bash
while :
do
if [ -t 0 ]; then stty -echo -icanon -icrnl time 0 min 0; fi
keypress=''
clear;
echo "Dies ist das Lego
1 = vorwärts
2 = rückwärts
3 = stop
"
read -n 1 text
if [ "$text" = "1" ];
then
while [ "x$keypress" = "x" ]; do
irsend SEND_ONCE LEGO_Combo_Direct FORWARD_FLOAT
keypress="`cat -v`"
done
fi
if [ "$text" = "2" ];
then
while [ "x$keypress" = "x" ]; do
irsend SEND_ONCE LEGO_Combo_Direct BACKWARD_FLOAT
keypress="`cat -v`"
done
fi
if [ "$text" = "3" ];
then
while [ "x$keypress" = "x" ]; do
irsend SEND_ONCE LEGO_Combo_Direct BRAKE_BRAKE
keypress="`cat -v`"
done
fi
done
我的问题是脚本在read -n 1 text 上停止。
如果有人可以帮助我将keypress 用于$text,则脚本将不再停止。
提前致谢:)
【问题讨论】: