我想用 Munin 来显示我的数据波。我从 ttyACM0 获取数据,它是一个 Arduino UNO。我使用shell脚本。但是我遇到了一个问题,我无法使用“cat /dev/ttyACM0”来获取数据。这是问题所在,程序在'cat /dev/ttyACM0'处停止,
+ . /usr/share/munin/plugins/plugin.sh
+ '[' '' = autoconf ']'
+ '[' '' = config ']'
++ cat /dev/ttyACM0
有时还有另一个问题,就是找不到 'LINE = $(cat /dev/ttyACM0 | awk -F: '{print $2}')' 命令。有人有想法吗?非常感谢。
这是我的代码的一部分,
if [ "$1" = "config" ]; then
echo 'graph_title Temperature of board'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel temperature(°C)'
echo 'graph_category temperature'
echo 'graph_scale no'
echo 'graph_period second'
echo 'graph_info This graph shows the temperature of board'
LINE = $(cat /dev/ttyACM0 | awk -F: '{print $2}')
for i in 0 1 2 3 4; do
case $i in
1)
TYPE="Under PCB"
;;
2)
TYPE="HDD"
;;
3)
TYPE="PHY"
;;
4)
TYPE="CPU"
;;
5)
TYPE="Ambience"
;;
esac
name=$(clean_name $TYPE)
if ["$TYPE" != "NA"]; then
echo "temp_$name.label $TYPE";
fi
done
exit 0
fi
LINE = $(cat /dev/ttyACM0 | awk -F: '{print $2}')
for i in 0 1 2 3 4; do
case $i in
1)
TYPE="Under PCB"
VALUE=$(echo "$LINE" | awk '{print $1}')
;;
2)
TYPE="HDD"
VALUE=$(echo "$LINE" | awk '{print $2}')
;;
3)
TYPE="PHY"
VALUE=$(echo "$LINE" | awk '{print $3}')
;;
4)
TYPE="CPU"
VALUE=$(echo "$LINE" | awk '{print $4}')
;;
5)
TYPE="Ambience"
VALUE=$(echo "$LINE" | awk '{print $5}')
;;
esac
name=$(clean_name $TYPE)
if ["$TYPE" != "NA"]; then
echo "temp_$name.value $VALUE";
fi
done