Files
Obsidian/串口.md
2025-08-23 15:15:57 +08:00

24 lines
686 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### **Linux/MacOS 测试步骤**
1. **创建虚拟串口**
```bash
socat -d -d pty,raw,echo=0 pty,raw,echo=0
```
记录生成的设备路径(如 `/dev/pts/1` 和 `/dev/pts/2`)。
2. **使用 `minicom` 测试**
• 终端1监听 `/dev/pts/1`
```bash
minicom -D /dev/pts/1 -b 9600
```
• 终端2发送数据到 `/dev/pts/2`
```bash
echo -n -e "\xEB\x90\x07\x00\x00\x0B\x61\x74\x2B\x74\x65\x73\x74\x3D\x31\x0D\x0A" > /dev/pts/1
```
• 在终端1查看接收结果。
---
``` bash
stty -F /dev/ttyS3 115200 raw -echo # 设置串口参数
cat /dev/ttyS3 | hexdump -v -e '/1 "%02X "' # 实时十六进制显示
```