RTU/mimo/plan/libcomm与libtask分析.md

41 lines
1.5 KiB
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.

# Plan: libcomm + libtask 公共库分析
## 目标
分析 `src/public/libcomm/``src/public/libtask/` 两个公共库,形成文档并指出优缺点。
---
## 步骤
### T1: 保存 plan
- 存入 `mimo/plan/libcomm与libtask分析.md`
### T2: 撰写 libcomm 模块分析
- 输出: `mimo/工程/libcomm模块分析.md`
- 覆盖:
- 统一通信抽象层架构stru_comm + 工厂模式 + 类型分发)
- TCP 客户端/服务端实现(非阻塞 connect + select 事件循环)
- UART 实现termios 配置 + send 被注释的分析)
- UDP 实现
- fd 类型检测工具get_fd_type / get_fd_info
- 调试数据包 hex dump含颜色
- **优点**: 统一接口、自动重连、调试开关、fd 诊断
- **缺点**: TCP 客户端空轮询 CPU、UART send 缺失、无内存释放、void* 类型不安全
### T3: 撰写 libtask 模块分析
- 输出: `mimo/工程/libtask模块分析.md`
- 覆盖:
- 三个子系统Event / MessageQueue / Timer
- Event: pthread_cond 事件标志AND/OR/CLEAR/超时)
- MessageQueue: 环形缓冲区 + 长度头编码
- Timer: POSIX timer_create(SIGEV_THREAD) 单次/周期
- 引用计数销毁机制
- **优点**: 纯 C + POSIX、零外部依赖、完备的超时支持、双条件 AND/OR
- **缺点**: timer 回调线程不安全、msg_queue 满写直接丢弃、事件无优先级
---
## 验证
1. 确认 `mimo/工程/libcomm模块分析.md``mimo/工程/libtask模块分析.md` 已创建
2. 检查文档包含优缺点章节