|

楼主 |
发表于 2013-12-25 11:03:12
|
显示全部楼层
本帖最后由 tomjobim 于 2013-12-25 11:29 编辑
oydl82 发表于 2013-12-25 06:54 
请教楼主,openwrt如何通过RX / TX接收单片机数据?是什么软件还是shell?
都是通过shell脚本。
控制命令在interface.sh里:
stty 9600 -echo < /dev/ttyS0 #设置ttl口波特率为9600
until inputline=$(echo $inputline | grep -e "^tun:") #检测输入,直到检测到tun:开始的命令
do
inputline=$(head -n 1 < /dev/ttyS0)
done
station=${inputline:4:2} #取出设定电台号
volume=${inputline:10:3} #取出设定音量
然后就用mpc play $station设定电台,用mpc volume $volume设定音量。
实际状态在display.sh里返回:
name=$(echo "currentsong" | nc localhost 6600 | grep -e "^Name: ") #获取电台信息
if [ -z "$name" ] # 如果没有,则用Name: CONNECTING代替
then
name="Name: CONNECTING" # no, let the AVR know not to display a name
fi
echo $name > /dev/ttyS0 #发送到ttl口
title=$(echo "currentsong" | nc localhost 6600 | grep -e "^Title: ") #获取当前播放的曲目信息
if [ -z "$title" ] # 如果没有,则用Title: NULL代替
then
title="Title: NULL" # no, let the AVR know not to display a title
fi
echo $title > /dev/ttyS0 #发送到ttl口
mpc | grep -e "playing" > /dev/ttyS0 #获取当前播放信息(电台号/总电台号/曲目时间),发送到ttl口
曲目时间未在单片机里处理,因为lcd屏太小了,显示时间的意义不大。 |
|