文章目录 设备连接 应用下载 配置过程 note 设备连接 USB 串口交叉连线即可。 应用下载 Win10 应用商店,串口调试助手下载: 界面如下,当串口连接
文章目录
- 设备连接
- 应用下载
- 配置过程
- note
设备连接
USB 串口交叉连线即可。
应用下载
Win10 应用商店,串口调试助手下载:
界面如下,当串口连接后,切记打开串口:
配置过程


选择关闭串口登录功能,打开硬件串口调试功能,后者设置与否无所谓,本次实验采用软件串口进行,重点是关闭串口登录功能,因为涉及到串口的占用问题。
重点是下图:
默认将cmdline.txt 修改保存到 /boot/, 但是树莓派4B的启动文件在 /boot/firmware 下,故:将 /boot/firmware 下的 cmdline.txt 先保存到 /boot/ 下,再经过 raspi-config 配置完毕后,将/boot/ 中修改后的 cmdline.txt 文件,拷贝到 /boot/firmware 下即可。
最终效果如下,等到系统启动一半之后,串口调试工具中显示的输出就会终止,因为我们关闭了串口调试功能。
3. 配置完毕,构造程序如下:
使用方式:
sudo python3 serial_send.py 123


循环等待数据。

note
树莓派有两个串口可以使用,一个是硬件串口(/dev/ttyAMA0),另一个是mini串口(/dev/ttyS0)。硬件串口有单独的波特率时钟源,性能好,稳定性强;mini串口功能简单,稳定性较差,波特率由CPU内核时钟提供,受内核时钟影响。
树莓派(3/4代)板载蓝牙模块,默认的硬件串口是分配给蓝牙模块使用的,而性能较差的mini串口是分配给GPIO串口 TXD0、RXD0。
ubuntu@ubuntu:~/Documents$ cat /boot/firmware/cmdline.txt # 配置过后的内容# 原本内容
net.ifnames=0 dwc_otg.lpm_enable=0 console=tty1 root=LABEL=writable rootfstype=ext4 elevator=deadline rootwait fixrtc
ubuntu@ubuntu:~/Documents$ cat /boot/firmware/cmdline_backup.txt # 原本内容
net.ifnames=0 dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=LABEL=writable rootfstype=ext4 elevator=deadline rootwait fixrtc