我正在通过cansend
向vcan0发送数据,同时我正在侦听通过candump vcan0
发送至vcan0的消息。
由于某种原因,通过脚本将数据发送到vcan0
时,我不会收到任何消息,但是通过终端发送数据时,脚本会以某种方式接收数据。
cansend vcan0 004#0152FEE400000000 # sending data to vcan0
while true;
do
msg_candump=$(candump vcan0) # read vcan0
if [[ ${#msg_candump} > 1 ]]; then #received msg
echo $msg_candump
fi
done
答案 0 :(得分:0)
这完成了工作:
while true;
do
cansend vcan0 '004#0152FEE400000000'
sleep 1
msg_candump="$(candump vcan0 -n 1)" # read vcan0
if [[ ${#msg_candump} > 1 ]]; then #received msg
echo $msg_candump
msg_candump=${msg_candump// /} # leerzeichen entfernen
msg_candump=${msg_candump:19:8} # substring holen
msg_candump=${msg_candump,,} #lowercase
if [[ $msg_candump != `git log -1 --format="%h"`0 ]]; then
echo "git pull"
#git pull
break
fi
fi
sleep 0.025
done