|
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. | |
| virtual size_t | EmptySize () |
| 获取队列的剩余可用空间。 Gets the remaining available space in the queue. | |
| virtual 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, uint32_t size) |
| 更新读取操作的状态。 Updates the status of the read operation. | |
| void | MarkAsRunning (ReadInfoBlock &info) |
| 标记读取操作为运行中。 Marks the read operation as running. | |
| ErrorCode | operator() (RawData data, ReadOperation &op) |
| 读取操作符重载,用于执行读取操作。 Overloaded function call operator to perform a read operation. | |
| virtual void | ProcessPendingReads (bool in_isr) |
| Processes pending reads. | |
| virtual void | Reset () |
| Resets the ReadPort. | |
Data Fields | |
| ReadFun | read_fun_ = nullptr |
| LockFreeQueue< uint8_t > * | queue_data_ = nullptr |
| size_t | read_size_ = 0 |
| ReadInfoBlock | info_ |
| std::atomic< BusyState > | busy_ {BusyState::IDLE} |
ReadPort class for handling read operations.
处理读取操作的ReadPort类。
Definition at line 268 of file libxr_rw.hpp.
|
strong |
Definition at line 271 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 10 of file libxr_rw.cpp.
|
virtual |
获取队列的剩余可用空间。 Gets the remaining available space in the queue.
该函数返回 queue_block_ 中当前可用的空闲空间大小。 This function returns the size of the available empty space in queue_block_.
Reimplemented in LibXR::ESP32UARTReadPort, and LibXR::TinyUSBUARTReadPort.
Definition at line 17 of file libxr_rw.cpp.
| void ReadPort::Finish | ( | bool | in_isr, |
| ErrorCode | ans, | ||
| ReadInfoBlock & | info, | ||
| uint32_t | size ) |
更新读取操作的状态。 Updates the status of the read operation.
该函数用于在读取操作过程中更新 read_size_ 并调用 UpdateStatus 方法更新 info.op_ 的状态。 This function updates read_size_ and calls UpdateStatus on info.op_ during a 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. |
| size | 读取的数据大小。 The size of the read data. |
Definition at line 37 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.
| ErrorCode ReadPort::operator() | ( | RawData | data, |
| ReadOperation & | op ) |
读取操作符重载,用于执行读取操作。 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. |
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 31 of file libxr_rw.cpp.
|
virtual |
Processes pending reads.
处理挂起的读取请求。
| in_isr | 指示是否在中断上下文中执行。 Indicates whether the operation is executed in an interrupt context. |
Reimplemented in LibXR::ESP32UARTReadPort, and LibXR::TinyUSBUARTReadPort.
Definition at line 126 of file libxr_rw.cpp.
| bool ReadPort::Readable | ( | ) |
Checks if read operations are supported.
检查是否支持读取操作。
Definition at line 29 of file libxr_rw.cpp.
|
virtual |
Resets the ReadPort.
重置ReadPort。
Reimplemented in LibXR::ESP32UARTReadPort, and LibXR::TinyUSBUARTReadPort.
Definition at line 172 of file libxr_rw.cpp.
|
virtual |
获取当前队列的已使用大小。 Gets the currently used size of the queue.
该函数返回 queue_block_ 当前已占用的空间大小。 This function returns the size of the space currently used in queue_block_.
Reimplemented in LibXR::ESP32UARTReadPort, and LibXR::TinyUSBUARTReadPort.
Definition at line 23 of file libxr_rw.cpp.
| std::atomic<BusyState> LibXR::ReadPort::busy_ {BusyState::IDLE} |
Definition at line 282 of file libxr_rw.hpp.
| ReadInfoBlock LibXR::ReadPort::info_ |
Definition at line 281 of file libxr_rw.hpp.
| LockFreeQueue<uint8_t>* LibXR::ReadPort::queue_data_ = nullptr |
Definition at line 279 of file libxr_rw.hpp.
| ReadFun LibXR::ReadPort::read_fun_ = nullptr |
Definition at line 278 of file libxr_rw.hpp.
| size_t LibXR::ReadPort::read_size_ = 0 |
Definition at line 280 of file libxr_rw.hpp.