gpt4 book ai didi

serial-port - Raspberry Pi UART 串​​口无法正常工作

转载 作者:行者123 更新时间:2023-12-04 02:43:51 29 4
gpt4 key购买 nike

我正在尝试通过 Raspberry Pi(B 型号,raspian wheezy)和 STM32F4 板之间的串行连接(GPIO UART 引脚)发送/接收数据。

为了设置串口,我遵循了几个教程中的所有步骤,例如:
http://elinux.org/RPi_Serial_Connection#Preventing_Linux_using_the_serial_port

当无法连接到 STM32F4 板时,我读到你可以在 pi 上本地测试串行端口,如果你只是将 pi 上的 TX、RX 引脚连接到彼此,它应该只是重复在 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 篇关于如何设置串行端口的不同教程和博客,但我不喜欢导致这种情况的原因。你能给我一些我可以寻找的建议吗?

最佳答案

我有一个 Arduino 通过电平转换器(3.3v 到 5v)连接到我的 Raspberry Pi 串行端口,并且 minicom 也有问题。我可以在 minicom 中接收来自 Arduino 的输出,但无论我尝试什么设置,我都无法发送任何内容。使用插入 USB (/dev/ttyUSB0) 的 Arduino 的 minicom 也遇到了完全相同的问题。

最后我求助于使用基本的python串行控制台,使用pip安装pyserial(pip install pyserial)并执行以下命令:

python -m serial.tools.miniterm -p /dev/ttyAMA0 -e

关于serial-port - Raspberry Pi UART 串​​口无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20772110/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com