...
最终实现效果:实现RS232串口通信,数据收发正常

2.RS485串口测试
1.系统启动检查
| 代码块 |
|---|
|
# 1. 检查UART设备节点
ls -l /dev/ttyS* # 或 /dev/ttyAML*
# 应看到ttyS2(对应UART2)
# 2. 查看dmesg中UART初始化信息
dmesg | grep -i "uart\|serial\|485"
# 正常输出示例:
# [ 2.560000] febc0000.serial: ttyS2 at MMIO 0xfebc0000 (irq = 45, base_baud = 1500000) is a 16550A
# [ 2.560100] febc0000.serial: RS485 enabled
# 3. 检查GPIO控制引脚
cat /sys/class/tty/ttyS2/rs485
# 正常输出应显示RS485配置 |
| 代码块 |
|---|
|
# 安装串口测试工具
sudo apt-get update
sudo apt-get install -y minicom picocom screen
# 安装Python测试库(可选)
pip install pyserial |
| 代码块 |
|---|
|
# 设备A(RK3588)作为主机
# 步骤1:配置串口参数
stty -F /dev/ttyS2 115200 cs8 -cstopb -parenb
stty -F /dev/ttyS2 raw
stty -F /dev/ttyS2 -echo
# 步骤2:发送测试数据
echo "RS485_TEST_FROM_RK3588" > /dev/ttyS2
# 步骤3:接收数据测试(需要另一设备发送)
cat /dev/ttyS2
# 或使用十六进制显示
hexdump -C /dev/ttyS2 |
1. 设备连接状态识别
通过以下命令确认设备是否接入系统并获取设备节点信息:
...