A comprehensive serial port debugging toolkit that handles everything from port scanning to live monitoring, hex viewing, and logging. It automatically detects available ports when you don't specify one, supports both text and binary protocols, and includes a multiplexing server so you can run minicom and monitoring scripts simultaneously without port conflicts. The config priority chain (CLI args, workspace config, state file, defaults) is sensible, and it persists your working parameters back to the project config after successful runs. Built for embedded work with AT commands, UART debugging, and MCU output inspection. The mux architecture using socat and TCP broadcast is clever but watch out for write collisions if multiple clients try sending at once.
npx -y skills add zhinkgit/embeddedskills --skill serial --agent claude-codeInstalls into .claude/skills of the current project.
统一封装端口发现、实时监控、数据发送、日志记录和 Hex 查看能力。
skill/config.json)serial skill 的环境级配置目前为空对象 {},因为串口参数属于工程级配置,统一在工作区的 .embeddedskills/config.json 中管理。
.embeddedskills/config.json)工作区下的 .embeddedskills/config.json 存放工程级串口配置:
{
"serial": {
"port": "",
"baudrate": 115200,
"bytesize": 8,
"parity": "none",
"stopbits": 1,
"encoding": "utf-8",
"timeout_sec": 1.0,
"log_dir": ".embeddedskills/logs/serial"
}
}
| 字段 | 说明 | 默认值 |
|---|---|---|
port | 串口号,如 COM3 | "" |
baudrate | 波特率 | 115200 |
bytesize | 数据位 | 8 |
parity | 校验位:none/even/odd/mark/space | none |
stopbits | 停止位:1/1.5/2 | 1 |
encoding | 文本编码 | utf-8 |
timeout_sec | 读写超时(秒) | 1.0 |
log_dir | 日志输出目录 | .embeddedskills/logs/serial |
--port, --baudrate 等) - 最高优先级.embeddedskills/config.json 中的 serial 部分).embeddedskills/state.json 中的历史记录)当未指定 port 时,脚本会自动扫描系统串口:
--port 指定)| 子命令 | 用途 | 风险 |
|---|---|---|
scan | 扫描可用串口 | 低 |
monitor | 实时查看文本输出 | 低 |
send | 发送文本或 Hex 数据 | 中 |
hex | 实时查看二进制流 | 低 |
log | 保存串口日志到文件 | 低 |
pyserial 是否可用,未安装时提示 pip install pyserialscanmonitor / send / hex / log 使用解析后的连接参数port,自动扫描系统串口:
所有脚本位于 skill 目录的 scripts/ 下,通过 python 直接调用。
脚本会按优先级从 CLI 参数、工程级配置、状态文件中读取参数。
# 扫描串口
python scripts/serial_scan.py [--filter <关键词>] [--json]
# 实时监控
python scripts/serial_monitor.py [--port <串口>] [--baudrate <波特率>] [--timestamp] [--filter <regex>] [--timeout <秒>] [--json]
# 发送数据
python scripts/serial_send.py [--port <串口>] [--baudrate <波特率>] <data> [--hex] [--crlf] [--repeat <次>] [--wait-response] [--json]
# Hex 查看
python scripts/serial_hex.py [--port <串口>] [--baudrate <波特率>] [--width <列>] [--timeout <秒>] [--json]
# 日志记录
python scripts/serial_log.py [--port <串口>] [--baudrate <波特率>] [--output <文件>] [--duration <秒>] [--format text|csv|json] [--json]
单次命令返回标准 JSON:
{
"status": "ok",
"action": "scan",
"summary": "发现 2 个串口",
"details": { ... }
}
持续命令(monitor --json、hex --json)输出 JSON Lines,结束摘要写入 stderr。
错误输出:
{
"status": "error",
"action": "monitor",
"error": { "code": "port_busy", "message": "串口被其他程序占用" }
}
当需要同时使用 minicom(或其他串口工具)和 skill 脚本访问同一个串口设备时,可以通过 mux 后台服务实现多路复用。
apt install socat / pacman -S socat ┌──────────────────┐
│ Real Hardware │
│ /dev/ttyUSB0 │
└────────┬─────────┘
│
┌────────▼─────────┐
│ Python mux server │
│ TCP-LISTEN:20001 │ 单串口读者 + 广播
└────────┬─────────┘
│
┌───────────────┼───────────────┐
│ │ │
┌────────▼──────┐ ┌─────▼──────┐ ┌──────▼────────┐
│ socat PTY │ │ skill │ │ skill │
│ /tmp/serial_ │ │ monitor │ │ send/log/hex │
│ mux_vserial │ │ socket:// │ │ socket:// │
└───────┬───────┘ └────────────┘ └───────────────┘
│
┌───────▼───────┐
│ minicom │
│ (用户侧) │
└───────────────┘
/tmp/serial_mux_vserial,供 minicom 使用socket:// 连接 TCP 端口# 启动多路复用
python scripts/serial_mux.py start --port /dev/ttyUSB0 [--baudrate 115200]
# 查询状态
python scripts/serial_mux.py status
# 停止多路复用
python scripts/serial_mux.py stop
启动后,skill 脚本(monitor/hex/log/send)自动通过多路复用连接,无需额外参数。若命令显式指定了不同串口或串口参数,则不会复用当前 mux。
python scripts/serial_mux.py start --port /dev/ttyUSB0minicom -D /tmp/serial_mux_vserial(用户侧交互)python scripts/serial_monitor.py(模型侧监控,自动走 mux)python scripts/serial_mux.py stop 停止复用(终止 socat 进程并清理 /tmp/serial_mux_vserial 符号链接)多客户端同时写入会导致串口数据错乱。 监控/hex/log 脚本在通过 mux 连接时输出警告到 stderr。send 脚本输出更强的冲突警告。如需直连真实串口(跳过 mux),使用 --direct 参数。
mux 进程 PID 保存到 .embeddedskills/state.json 的 serial_mux 段。脚本退出后下次调用 status 会检测进程是否仍存活,自动清理僵尸 PID。start 成功后会把已确认的串口配置写回 .embeddedskills/config.json,方便后续无参命令复用。stop 命令会终止 mux 与 socat PTY 进程,并删除残留的 /tmp/serial_mux_vserial 符号链接。
port 时自动扫描,唯一候选自动写入配置,多候选需用户选择.embeddedskills/config.json--json 输出的持续流使用 JSON Lines,摘要写 stderr 不污染数据流references/common_devices.json:常见 USB 转串口芯片 VID/PID 映射juliusbrussee/caveman
mattpocock/skills
shadcn/improve
obra/superpowers
forrestchang/andrej-karpathy-skills
vercel-labs/skills