c++ - 覆盆子 pi3 : C++ serial communication not working properly (Raspberry pi was working! )

标签 c++ qt serialization

我有一个 Raspberry PI B+ 和一个能够与 Arduino 通信的 C++ 应用程序。我能够读取、写入、串行连接 perfeclty 稳定。

现在,我买了一个 Raspberry PI3 来集成更多的性能和 wifi。 花了很多时间后,我让 QT 应用程序再次运行,但串行通信无法正常工作。 我连接了 Arduino IDE 的串行监视器并使用 RPI 1 检查它是否工作正常,我看到所有消息都按照我的协议(protocol)发送,所以我确信我可以分析我正在用 Raspberry P3 写的东西。 不幸的是,我只收到奇怪的字符: enter image description here 我尝试了不同的波特率,例如 115200 和 9600(预期波特率!)但结果不同但同样错误。

我想报告一下我在 Raspberry P3 中所做的事情: enter image description here 我禁用了控制台的串行端口(正如我在网上所了解的那样) 此设置会自动修改选项: enter image description here

enable_uart=0

这很奇怪,因为在网络上我发现谁建议启用,谁清楚地写着应该禁用它,因为指的是“console over serial”。 然后,我添加了一些线(你可以看到红色形状)以移动 miniuart 中的蓝牙处理,将 cpu 频率固定为 250 并将默认波特率固定为 9600。 enter image description here 然后,我使用以下命令禁用蓝牙: enter image description here 我真的不确定,但是..在一些帖子中提出了一些建议。 最后,这是我的 QT c++ 应用程序中的设置: enter image description here 我将端口名称更改为“ttyS0”(与“serial1”相同)。

所以..我想要实现的是设置我的 pi3 串行通信,就像使用 piB+ 一样,连接在相同的引脚 GPIO14 和 GPIO15 上。 蓝牙无所谓,我不会用。

我错过了什么或做错了什么?

Raspberry PI3 的 PINOUT 似乎与 Raspberry PI B+ 的 PINOUT 相同: enter image description here

而Raspberry B+的PINOUT是: enter image description here

但是我发现了一件有趣的事: enter image description here 似乎配置有问题,因为 GPIO14 和 GPIO15 都是输入!!

最佳答案

我终于修好了! 正如我所写的,我在网上发现了很多建议,但往往不一致。所以我将在这里报告我如何设置我的 Raspberry p3 以便正常工作。

1) 升级了我的系统

sudo apt-get update
sudo apt-get dist-upgrade

2) 启用 UART 控制台

sudo raspi-config

高级选项 --> 串行: enter image description here

注意:它会自动在文件 config.txt 中设置 1 enable_uart

3) 编辑config.txt

sudo nano /boot/config.txt

我基本上添加了一行以禁用蓝牙端口(在我的情况下未使用) enter image description here

我还取消了 cpu 频率为 250 的限制,在论坛中发现多次提示,如您所见,它被注释 (#)。 您还可以看到使用 raspi-config 界面完成的“enable_uart=1”设置。

4) 编辑文件cmdline.txt

sudo /boot/cmdline.txt

enter image description here

我删除了那段有类似东西的绳子:

.... console=serial0,115200 ....

5) 应用指的是serial0

enter image description here

6) 完成!

我希望这个循序渐进的指南对其他人有用,或者总的来说会有所帮助。

关于c++ - 覆盆子 pi3 : C++ serial communication not working properly (Raspberry pi was working! ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38813679/

相关文章:

c++ - vector 迭代器

c++ - 带有发布和调试版本的简单 makefile - 最佳实践

c# - 在 MFC 与 C# 中对字符串进行排序

linux - OpenGL 应用程序导致 Xorg 泄漏

c# - 类序列化到 XML

启用扩展序列化调试信息的 Java 标志

Java 序列化 - java.io.InvalidClassException 本地类不兼容

c++ - 我构造子类对象的方式有什么问题?

c++ - Qt 插件中的 QObject 工厂(非创建者)

c++ - Qt 数据类型选择