我正在尝试在树莓派(B型号,raspian wheezy)和STM32F4板之间通过串行连接(GPIO UART引脚)发送/接收数据。
为了设置串口,我遵循了几篇教程中的所有步骤,例如: http://elinux.org/RPi_Serial_Connection#Preventing_Linux_using_the_serial_port
当无法连接到STM32F4板时,我阅读到如果你将树莓派的TX、RX引脚相互连接,则可以在pi上本地测试串口,它应该只是在minicom中重复输入的数据。
不幸的是,这也不起作用。
在“cmdline”和“inittab”文件中,ttyAMA0的设置是正确的。(如许多教程所述)
还尝试了自动配置脚本 https://github.com/lurch/rpi-serial-console
直接将RX连接到rpi的TX引脚不会在minicom中输出任何内容。 我还使用了一个重复给定输入的Python脚本。 似乎什么都没有用,我有点迷失方向。
Minicom启动命令应该是正确的(尝试使用不同的波特率):
root@raspberrypi:/home/jef# minicom -b 9600 -o -D /dev/ttyAMA0
OPTIONS: I18n
Compiled on Apr 28 2012, 19:24:31.
Port /dev/ttyAMA0
minicom的底部始终显示离线状态:
CTRL-A Z for help | 9600 8N1 | NOR | Minicom 2.6.1 | VT102 | Offline
在使用 Python 检查可用串口时,没有显示任何内容:
python -m serial.tools.list_ports
no ports found
用户属于dailout组,因此这不应该是问题(尝试使用root和非root用户):
root@raspberrypi:/home/jef# id
uid=0(root) gid=0(root) groups=0(root),20(dialout),1001(indiecity)
检查串口是否不再被getty使用:
root@raspberrypi:/home/jef# ps aux | grep getty
root 2809 0.0 0.1 3740 804 tty1 Ss+ 10:36 0:00 /sbin/getty --noclear 38400 tty1
root 2810 0.0 0.1 3740 804 tty2 Ss+ 10:36 0:00 /sbin/getty 38400 tty2
root 2811 0.0 0.1 3740 804 tty3 Ss+ 10:36 0:00 /sbin/getty 38400 tty3
root 2812 0.0 0.1 3740 804 tty4 Ss+ 10:36 0:00 /sbin/getty 38400 tty4
root 2813 0.0 0.1 3740 804 tty5 Ss+ 10:36 0:00 /sbin/getty 38400 tty5
root 2814 0.0 0.1 3740 804 tty6 Ss+ 10:36 0:00 /sbin/getty 38400 tty6
root 3129 0.0 0.1 2012 624 pts/0 S+ 11:57 0:00 grep getty
我检查了其他使用ttyAMA0的应用程序,也没有发现任何问题:
root@raspberrypi:/home/jef# ps aux | grep ttyAMA0
root 3125 0.0 0.1 2012 628 pts/0 S+ 11:56 0:00 grep ttyAMA0
用户有正确的权限访问串口:
root@raspberrypi:/home/jef# ls -l /dev/ttyAMA0
crw-rw---T 1 root dialout 204, 64 Dec 25 11:53 /dev/ttyAMA0
我有没有遗漏什么?我读了大约20篇关于如何设置串口的教程和博客,但我找不到导致问题的原因。请问你能给我一些建议吗?