|
libxr
Embedded C++ framework for bare-metal, RTOS and Linux
|
将字节流解析成 packet 并发布到已注册 topic 的状态机 / State machine that parses byte streams into packets and publishes them into registered topics More...
#include <server.hpp>
Public Types | |
| enum class | Status : uint8_t { WAIT_START , WAIT_TOPIC , WAIT_DATA_CRC } |
| parser 当前所在阶段 / Current stage of the parser More... | |
Public Member Functions | |
| Server (size_t buffer_length) | |
| 构造 parser 并分配内部暂存队列 / Construct the parser and allocate its internal staging queue | |
| void | Register (TopicHandle topic) |
| 注册一个可接收 packet 的 topic / Register one topic that may receive parsed packets | |
| size_t | ParseData (ConstRawData data) |
| 在普通上下文里喂入一批新字节 / Feed one new byte batch in normal context | |
| size_t | ParseDataFromCallback (ConstRawData data, bool in_isr) |
| 在回调/ISR 路径里喂入一批新字节 / Feed one new byte batch in callback/ISR path | |
将字节流解析成 packet 并发布到已注册 topic 的状态机 / State machine that parses byte streams into packets and publishes them into registered topics
把字节流解析成 packet 并投递到 topic 的 parser / Parser that turns byte streams into packets and delivers them into topics
Server 自己不维护 raw topic/cache 语义;它只依赖注册 topic 的: payload_size、payload_alignment 和名字 CRC 键。 The current Server does not restore old raw topic/cache semantics by itself; it relies only on each registered topic's payload_size, payload_alignment, and name CRC key. Definition at line 27 of file server.hpp.
|
strong |
parser 当前所在阶段 / Current stage of the parser
Definition at line 34 of file server.hpp.
| Topic::Server::Server | ( | size_t | buffer_length | ) |
构造 parser 并分配内部暂存队列 / Construct the parser and allocate its internal staging queue
| buffer_length | 内部字节队列和暂存缓冲区大小 / Size of the internal byte queue and staging buffer |
Definition at line 12 of file server.cpp.
| size_t Topic::Server::ParseData | ( | ConstRawData | data | ) |
在普通上下文里喂入一批新字节 / Feed one new byte batch in normal context
| data | 新收到的原始字节 / Newly received raw bytes |
Definition at line 35 of file server.cpp.
| size_t Topic::Server::ParseDataFromCallback | ( | ConstRawData | data, |
| bool | in_isr ) |
在回调/ISR 路径里喂入一批新字节 / Feed one new byte batch in callback/ISR path
| data | 新收到的原始字节 / Newly received raw bytes |
| in_isr | 当前是否位于 ISR / Whether the current path is in ISR context |
Definition at line 40 of file server.cpp.
| void Topic::Server::Register | ( | TopicHandle | topic | ) |
注册一个可接收 packet 的 topic / Register one topic that may receive parsed packets
| topic | 目标 topic 句柄 / Target topic handle |
payload_size + PACK_BASE_SIZE 能放进本 server 的 暂存缓冲区。 Registration asserts that the topic's payload_size + PACK_BASE_SIZE fits in this server's staging buffer. CACHE_LINE_SIZE 对齐分配;注册时还会 断言该 topic 的 payload_alignment <= CACHE_LINE_SIZE。 The server's internal staging buffer is allocated once at CACHE_LINE_SIZE alignment during construction; registration also asserts that the topic's payload_alignment <= CACHE_LINE_SIZE. Definition at line 22 of file server.cpp.