|
libxr
1.0
Want to be the best embedded framework
|
ReadPort class for handling read operations. More...
#include <libxr_rw.hpp>
Public Types | |
| enum class | BusyState : uint32_t { IDLE = 0 , PENDING = 1 , EVENT = UINT32_MAX } |
Public Member Functions | |
| ReadPort (size_t buffer_size=128) | |
| Constructs a ReadPort with queue sizes. | |
| size_t | EmptySize () |
| 获取队列的剩余可用空间。 Gets the remaining available space in the queue. | |
| size_t | Size () |
| 获取当前队列的已使用大小。 Gets the currently used size of the queue. | |
| bool | Readable () |
| Checks if read operations are supported. | |
| ReadPort & | operator= (ReadFun fun) |
| 赋值运算符重载,用于设置读取函数。 Overloaded assignment operator to set the read function. | |
| void | Finish (bool in_isr, ErrorCode ans, ReadInfoBlock &info) |
| 更新读取操作的状态。 Updates the status of the read operation. | |
| void | MarkAsRunning (ReadInfoBlock &info) |
| 标记读取操作为运行中。 Marks the read operation as running. | |
| ErrorCode | operator() (RawData data, ReadOperation &op, bool in_isr=false) |
| 读取操作符重载,用于执行读取操作。 Overloaded function call operator to perform a read operation. | |
| virtual void | OnRxDequeue (bool) |
| RX 数据从软件队列成功出队后的通知。 Notification after bytes are popped from RX data queue. | |
| void | ProcessPendingReads (bool in_isr) |
| Processes pending reads. | |
| void | Reset () |
| Resets the ReadPort. | |
Data Fields | |
| ReadFun | read_fun_ = nullptr |
| LockFreeQueue< uint8_t > * | queue_data_ = nullptr |
| ReadInfoBlock | info_ |
| std::atomic< BusyState > | busy_ {BusyState::IDLE} |
ReadPort class for handling read operations.
处理读取操作的ReadPort类。
Definition at line 271 of file libxr_rw.hpp.
|
strong |
Definition at line 274 of file libxr_rw.hpp.
| ReadPort::ReadPort | ( | size_t | buffer_size = 128 | ) |
Constructs a ReadPort with queue sizes.
以指定队列大小构造ReadPort。
| queue_size | Number of queued operations. |
| buffer_size | Size of each buffer. |
Definition at line 11 of file libxr_rw.cpp.
| size_t ReadPort::EmptySize | ( | ) |
获取队列的剩余可用空间。 Gets the remaining available space in the queue.
该函数返回 queue_block_ 中当前可用的空闲空间大小。 This function returns the size of the available empty space in queue_block_.
Definition at line 18 of file libxr_rw.cpp.
| void ReadPort::Finish | ( | bool | in_isr, |
| ErrorCode | ans, | ||
| ReadInfoBlock & | info ) |
更新读取操作的状态。 Updates the status of the read operation.
| in_isr | 指示是否在中断上下文中执行。 Indicates whether the operation is executed in an interrupt context. |
| ans | 错误码,用于指示操作的结果。 Error code indicating the result of the operation. |
| info | 需要更新状态的 ReadInfoBlock 引用。 Reference to the ReadInfoBlock whose status needs to be updated. |
Definition at line 38 of file libxr_rw.cpp.
| void ReadPort::MarkAsRunning | ( | ReadInfoBlock & | info | ) |
标记读取操作为运行中。 Marks the read operation as running.
该函数用于将 info.op_ 标记为运行状态,以指示当前正在进行读取操作。 This function marks info.op_ as running to indicate an ongoing read operation.
| info | 需要更新状态的 ReadInfoBlock 引用。 Reference to the ReadInfoBlock whose status needs to be updated. |
Definition at line 44 of file libxr_rw.cpp.
|
inlinevirtual |
RX 数据从软件队列成功出队后的通知。 Notification after bytes are popped from RX data queue.
| in_isr | 指示是否在中断上下文中执行。 Indicates whether the operation is executed in an interrupt context. |
Reimplemented in LibXR::USB::CDCUartReadPort.
Definition at line 392 of file libxr_rw.hpp.
| ErrorCode ReadPort::operator() | ( | RawData | data, |
| ReadOperation & | op, | ||
| bool | in_isr = false ) |
读取操作符重载,用于执行读取操作。 Overloaded function call operator to perform a read operation.
该函数检查端口是否可读,并根据 data.size_ 和 op 的类型执行不同的操作。 This function checks if the port is readable and performs different actions based on data.size_ and the type of op.
| data | 包含要读取的数据。 Contains the data to be read. |
| op | 读取操作对象,包含操作类型和同步机制。 Read operation object containing the operation type and synchronization mechanism. |
| in_isr | 指示是否在中断上下文中执行。 Indicates whether the operation is executed in an interrupt context. |
ErrorCode,指示操作结果。 Returns an ErrorCode indicating the result of the operation. Definition at line 46 of file libxr_rw.cpp.
赋值运算符重载,用于设置读取函数。 Overloaded assignment operator to set the read function.
该函数允许使用 ReadFun 类型的函数对象赋值给 ReadPort,从而设置 read_fun_。 This function allows assigning a ReadFun function object to ReadPort, setting read_fun_.
| fun | 要分配的读取函数。 The read function to be assigned. |
Definition at line 32 of file libxr_rw.cpp.
| void ReadPort::ProcessPendingReads | ( | bool | in_isr | ) |
Processes pending reads.
处理挂起的读取请求。
| in_isr | 指示是否在中断上下文中执行。 Indicates whether the operation is executed in an interrupt context. |
Definition at line 127 of file libxr_rw.cpp.
| bool ReadPort::Readable | ( | ) |
Checks if read operations are supported.
检查是否支持读取操作。
Definition at line 30 of file libxr_rw.cpp.
| void ReadPort::Reset | ( | ) |
Resets the ReadPort.
重置ReadPort。
Definition at line 156 of file libxr_rw.cpp.
| size_t ReadPort::Size | ( | ) |
获取当前队列的已使用大小。 Gets the currently used size of the queue.
该函数返回 queue_block_ 当前已占用的空间大小。 This function returns the size of the space currently used in queue_block_.
Definition at line 24 of file libxr_rw.cpp.
| std::atomic<BusyState> LibXR::ReadPort::busy_ {BusyState::IDLE} |
Definition at line 284 of file libxr_rw.hpp.
| ReadInfoBlock LibXR::ReadPort::info_ |
Definition at line 283 of file libxr_rw.hpp.
| LockFreeQueue<uint8_t>* LibXR::ReadPort::queue_data_ = nullptr |
Definition at line 282 of file libxr_rw.hpp.
| ReadFun LibXR::ReadPort::read_fun_ = nullptr |
Definition at line 281 of file libxr_rw.hpp.