RTU_ALL_AI/docs/README.md

118 lines
7.4 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.

# RTU_ALL_AI API 参考文档
> 生成日期: 2026-07-07
> 项目: RTU_ALL_AI — C/C++ 嵌入式通讯装置示例工程
---
## 文档索引
### 基础公共库 (public/)
| 模块 | 文档 | 语言 | 说明 |
|------|------|------|------|
| myBase.h | [API-myBase.md](public/API-myBase.md) | C 头文件 | 公共宏、类型常量、字节序转换 |
| liblist | [API-liblist.md](public/liblist/API-liblist.md) | 纯 C 头文件 | 侵入式双向循环链表 |
| liblog | [API-liblog.md](public/liblog/API-liblog.md) | 纯 C | 异步日志系统 |
| libfunc | [API-libfunc.md](public/libfunc/API-libfunc.md) | 纯 C | 65 个基础工具函数 |
| libmd5 | [API-libmd5.md](public/libmd5/API-libmd5.md) | 纯 C | MD5 消息摘要 (RFC 1321) |
| libtask | [API-libtask.md](public/libtask/API-libtask.md) | 纯 C | 定时器 + 事件 + 消息队列 |
| libdatacenter | [API-libdatacenter.md](public/libdatacenter/API-libdatacenter.md) | C 接口+C++ 内部 | 信号数据中心5种信号+事件队列) |
| libcJSON | [API-libcJSON.md](public/libcJSON/API-libcJSON.md) | 纯 C (开源库) | JSON 解析/生成 |
| libmy_xxhash | [API-libmy_xxhash.md](public/libmy_xxhash/API-libmy_xxhash.md) | 纯 C (开源库) | xxHash 快速哈希 |
| libxml | [API-libxml.md](public/libxml/API-libxml.md) | C 接口+C++ 内部 | XML 解析C接口包裹 tinyxml2 |
| libcmd | [API-libcmd.md](public/libcmd/API-libcmd.md) | C 接口+C++ 内部 | 命令注册/补全 + 内置 linenoise |
| libcomm | [API-libcomm.md](public/libcomm/API-libcomm.md) | C 接口+C++ 内部 | TCP/UDP/UART 通讯抽象层 |
### 通讯与协议库 (protocol/)
| 模块 | 文档 | 语言 | 说明 |
|------|------|------|------|
| libmodbus | [API-libmodbus.md](protocol/libmodbus/API-libmodbus.md) | C (开源库) | Modbus 协议栈 v3.1.12 |
| lib60870 | [API-lib60870.md](protocol/lib60870/API-lib60870.md) | C (自研) | IEC 60870-5-101/103/104 协议栈 |
| libicp67 | [API-libicp67.md](protocol/libicp67/API-libicp67.md) | 纯 C | ICP67 自定义协议(帧解析+编解码+核心逻辑) |
| libmongoose | [API-libmongoose.md](protocol/libmongoose/API-libmongoose.md) | C (MIT 开源) | HTTP/WebSocket 嵌入式网络库 v7.22 |
### 系统模块 (system/)
| 模块 | 文档 | 语言 | 说明 |
|------|------|------|------|
| RTU | [API-RTU.md](system/RTU/API-RTU.md) | C + C++ | 主程序入口、X-Macro 框架、模块生命周期 |
| libiec | [API-libiec.md](system/libiec/API-libiec.md) | C 接口+C++ 内部 | IEC-104 服务端26回调+环形缓冲+数据中心桥接) |
| libcom_router | [API-libcom_router.md](system/libcom_router/API-libcom_router.md) | C++ | 通信路由中枢(转发规则+协议绑定 dispatch |
| libmodbus_m | [API-libmodbus_m.md](system/libmodbus_m/API-libmodbus_m.md) | C++ | Modbus 主站管理(通道/点表/轮询/写入) |
| libself_ptl | [API-libself_ptl.md](system/libself_ptl/API-libself_ptl.md) | C++ | 内部自定义协议应用层多FTU帧组装+文件操作) |
| libweb_server | [API-libweb_server.md](system/libweb_server/API-libweb_server.md) | C++ | Web 管理服务HTTP + WebSocket 实时推送) |
```
┌──────────┐
│ myBase.h │ (颜色/大小端/类型常量)
└────┬─────┘
┌──────────────┼──────────────┐
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌──────────┐
│ liblist │ │ libfunc │ │ libmd5 │
│ (链表) │ │ (65函数)│ │ (MD5) │
└────┬────┘ └────┬────┘ └──────────┘
│ │
▼ ▼
┌─────────────────────────┐
│ liblog │ (异步日志)
│ (消息池+批量+文件轮转) │
└─────────────────────────┘
┌──────────┐ ┌──────────────┐
│ libcJSON │ │ libmy_xxhash │ (开源库)
└──────────┘ └──────┬───────┘
┌─────────────────────┼─────────────────────┐
│ ▼ │
│ ┌──────────┐ ┌──────────┐ ┌─────────┐ │
│ │ libtask │ │ libxml │ │ libcmd │ │ (P2库提前实现
│ │ (事件/ │ │ (C接口+ │ │ (命令 │ │ 供datacenter
│ │ 定时器) │ │ tinyxml2)│ │ 框架) │ │ 依赖)
│ └──────────┘ └────┬─────┘ └────┬────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────────────────────────┐ │
│ │ libdatacenter │ │
│ │ (信号数据中心 5种信号类型) │ │
│ │ 依赖: libxml + libcmd │ │
│ │ + libmy_xxhash │ │
└──────────┴─────────────────────────────┘
┌──────────┐
│ myBase.h │
└────┬─────┘
┌──────────────────┐
│ libcomm │ (通讯抽象层)
│ TCP/UDP/UART │ 阶段 2 首个模块
│ epoll 异步事件 │
└────┬───┬────┬────┘
│ │ │
┌──────────┼───┘ └──────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌────────────┐
│libmodbus │ │lib60870 │ ... │libweb_server│ (协议栈)
│ (Modbus) │ │(IEC104) │ │ (Web 管理) │
└──────────┘ └──────────┘ └────────────┘
```
### 构建与编译
```bash
cd release
./build.sh # x86 本地编译
./build.sh arm # ARM 交叉编译
```
### 编码规范
详见项目内存 `/memories/code-style.md`
- 一行一语句,`{}` 独占行,`}` 后空行,`return` 前空行
- 运算符前后空格(`a + b`, `x << 8`),逗号分号后空格
- 结构体 `stru_` 前缀,枚举 `enum_` 前缀
- 注释使用 UTF-8 中文