串口设置
开机启动信息可以看到串口的名称,例如以下串口启动信息:
Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
ar933x-uart: ttyATH0 at MMIO 0x18020000 (irq = 11) is a AR933X UART
console [ttyATH0] enabled, bootconsole disabled
可以看到串口的名称为ttyATH0,此时可以ls /dev/查看确认。
stty 串口波特率设置
opkg update //更新软件列表
opkg install coreutils-stty //安装stty
stty -F /dev/ttyATH0 raw speed 9600 //设置ttyATH0串口的波特率为9600
echo "hello" > /dev/ttyACM0 //向串口输出字符"hello"
cat /dev/ttyATH0 //读取串口
屏蔽串口的系统显示(消除乱码和串口BusyBox 影响)
编辑文件:vi /etc/inittab
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
ttyS0::askfirst:/bin/ash --login
#ttyATH0::askfirst:/bin/ash --login #注释此行
将串口波特率设置添加到开机启动
编辑文件:vi /etc/init.d/usart
文件属性:chmod 777 /etc/init.d/usart