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 = 2 } |
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 |
Mutex | mutex_ |
ReadInfoBlock | info_ |
std::atomic< BusyState > | busy_ {BusyState::Idle} |
ReadPort class for handling read operations.
处理读取操作的ReadPort类。
Definition at line 269 of file libxr_rw.hpp.
|
strong |
Definition at line 272 of file libxr_rw.hpp.
|
inline |
Constructs a ReadPort with queue sizes.
以指定队列大小构造ReadPort。
queue_size | Number of queued operations. |
buffer_size | Size of each buffer. |
Definition at line 292 of file libxr_rw.hpp.
|
inlinevirtual |
获取队列的剩余可用空间。 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 309 of file libxr_rw.hpp.
|
inline |
更新读取操作的状态。 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 371 of file libxr_rw.hpp.
|
inline |
标记读取操作为运行中。 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 388 of file libxr_rw.hpp.
|
inline |
读取操作符重载,用于执行读取操作。 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 406 of file libxr_rw.hpp.
赋值运算符重载,用于设置读取函数。 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 348 of file libxr_rw.hpp.
|
inlinevirtual |
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 501 of file libxr_rw.hpp.
|
inline |
Checks if read operations are supported.
检查是否支持读取操作。
Definition at line 333 of file libxr_rw.hpp.
|
inlinevirtual |
Resets the ReadPort.
重置ReadPort。
Reimplemented in LibXR::ESP32UARTReadPort, and LibXR::TinyUSBUARTReadPort.
Definition at line 550 of file libxr_rw.hpp.
|
inlinevirtual |
获取当前队列的已使用大小。 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 325 of file libxr_rw.hpp.
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.
Mutex LibXR::ReadPort::mutex_ |
Definition at line 282 of file libxr_rw.hpp.
LockFreeQueue<uint8_t>* LibXR::ReadPort::queue_data_ = nullptr |
Definition at line 280 of file libxr_rw.hpp.
ReadFun LibXR::ReadPort::read_fun_ = nullptr |
Definition at line 279 of file libxr_rw.hpp.
size_t LibXR::ReadPort::read_size_ = 0 |
Definition at line 281 of file libxr_rw.hpp.