8207b5e88357d3d5a39f0ce529540426d9d230b9
The test called handle.join() without first calling handle.close(), causing the spawned session task to park forever waiting for cmd_rx.recv() to return None. Since join() borrows &self, cmd_tx stays alive, and the task never exits. Add close() call before join() to send a Close command and unblock the task. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
xserial
xserial 是一个基于 Rust workspace 的串口 / TCP / UDP 数据观测工具,支持可配置分帧、协议解码、会话管理,以及以文本、十六进制和绘图为核心的桌面 GUI。
工作区结构
仓库当前包含 4 个 crate:
xserial-core负责传输层、分帧器、协议解码器和 pipeline 基础能力。xserial-client负责会话生命周期、配置、事件分发、历史缓冲和 Lua 相关接口。xserial-gui当前主要使用入口,基于egui/eframe。xserial-tui终端 UI crate,目前还只是占位实现。
当前功能
- 在一个 GUI 中管理多个 session。
- 支持
Serial、TCP、UDP三种传输方式。 - 支持以下 framer:
Line、Fixed、Length、Cobs、MixedTextPlot。 - 支持以下 decoder:
Text、Hex、Plot、MixedTextPlot。 - 每个 session 可在
Text、Hex、Plot三种视图之间切换。 - 支持单连接 mixed text + plot 数据流。
- 支持
Interleaved、Block、XY三种 plot 格式。 - 可在 sidebar 中直接编辑 session 配置。
- plot 视图支持嵌入主界面,也支持在 GUI 内部弹出为浮动窗口。
构建
cargo check --workspace
运行
启动 GUI:
cargo run -p xserial-gui
当前 xserial-tui 还不是完整实现:
cargo run -p xserial-tui
测试
运行整个 workspace 的测试:
cargo test --workspace
常用本地检查命令:
cargo fmt --all
cargo clippy --workspace --all-targets -- -D warnings
GUI 快速开始
- 启动
xserial-gui。 - 在 sidebar 中创建一个 session。
- 选择传输方式:
Serial、TCP或UDP。 - 添加一个或多个 pipeline,并选择匹配的 framer / decoder。
- 连接 session。
- 在
Text、Hex、Plot视图之间切换。
补充说明:
- session 配置入口在 sidebar 的齿轮按钮。
- 连接控制是单个切换按钮,不再区分独立的
Connect/Disconnect。 - plot 视图支持内嵌和浮动窗口两种显示方式。
Plot 测试服务器
仓库自带一个本地波形测试工具:
python tools/test_plot.py --help
示例:通过 TCP 发送 mixed text + plot 数据流:
python tools/test_plot.py --wire-format mixed --host 127.0.0.1 --port 8091
GUI 中对应配置为:
- Transport:
TCP 127.0.0.1:8091 - Framer:
MixedTextPlot - Decoder:
MixedTextPlot
示例:发送 XY plot 数据:
python tools/test_plot.py --wire-format mixed --format xy --channels 2
示例:发送固定长度 raw plot 帧:
python tools/test_plot.py --wire-format raw --channels 2 --framelen 256
GUI 中对应配置为:
- Framer:
Fixed - Decoder:
Plot - Sample type:
F32 - Endian:
Little Channels/Format与脚本参数保持一致
Profiling
GUI 内置了一套轻量级性能日志,默认关闭。
开启方式:
RUST_LOG=xserial_gui::perf=info XSERIAL_GUI_PROFILE=1 cargo run -p xserial-gui
修改统计输出间隔:
RUST_LOG=xserial_gui::perf=info XSERIAL_GUI_PROFILE=1 XSERIAL_GUI_PROFILE_INTERVAL_MS=500 cargo run -p xserial-gui
日志会输出:
- frame 耗时
- 事件 drain 耗时
- text / hex / plot 渲染耗时
- plot 点数量统计
仓库目录
crates/
xserial-core/
xserial-client/
xserial-gui/
xserial-tui/
tools/
test_plot.py
开发约定
- 传输层、协议和 pipeline 逻辑优先放在
xserial-core。 - 会话管理和状态编排优先放在
xserial-client。 - UI 相关状态放在
xserial-gui或xserial-tui。 - 集成测试位于
crates/*/tests。
当前状态
目前项目中最完整的是 GUI 路径。xserial-tui 已经在 workspace 中,但还没有达到和 GUI 同等的可用程度。
Description
Languages
Rust
91.4%
C
5.8%
Python
2.6%
Lua
0.2%