|
libxr
1.0
Want to be the best embedded framework
|
Linux UART 串口驱动实现 / Linux UART driver implementation. More...
#include <linux_uart.hpp>
Public Member Functions | |
| LinuxUART (const char *dev_path, unsigned int baudrate=115200, Parity parity=Parity::NO_PARITY, uint8_t data_bits=8, uint8_t stop_bits=1, uint32_t tx_queue_size=5, size_t buffer_size=512, size_t thread_stack_size=65536) | |
| 通过设备路径构造 UART / Construct UART by device path | |
| LinuxUART (const std::string &vid, const std::string &pid, unsigned int baudrate=115200, Parity parity=Parity::NO_PARITY, uint8_t data_bits=8, uint8_t stop_bits=1, uint32_t tx_queue_size=5, size_t buffer_size=512, size_t thread_stack_size=65536) | |
| 通过 USB VID/PID 构造 UART / Construct UART by USB VID/PID | |
| std::string | GetByPathForTTY (const std::string &tty_name) |
| void | SetLowLatency (int fd) |
| ErrorCode | SetConfig (UART::Configuration config) override |
| 设置 UART 配置 / Sets the UART configuration | |
Public Member Functions inherited from LibXR::UART | |
| template<typename ReadPortType = ReadPort, typename WritePortType = WritePort> | |
| UART (ReadPortType *read_port, WritePortType *write_port) | |
| UART 构造函数 / UART constructor. | |
| template<typename OperationType , typename = std::enable_if_t<std::is_base_of_v< WriteOperation, std::decay_t<OperationType>>>> | |
| ErrorCode | Write (ConstRawData data, OperationType &&op, bool in_isr=false) |
| template<typename OperationType , typename = std::enable_if_t<std::is_base_of_v< ReadOperation, std::decay_t<OperationType>>>> | |
| ErrorCode | Read (RawData data, OperationType &&op, bool in_isr=false) |
Static Public Member Functions | |
| static bool | FindUSBTTYByVidPid (const std::string &target_vid, const std::string &target_pid, std::string &tty_path) |
| static ErrorCode | ReadFun (ReadPort &) |
| static ErrorCode | WriteFun (WritePort &port) |
Private Member Functions | |
| void | RxLoop () |
| void | TxLoop () |
Private Attributes | |
| int | fd_ = -1 |
| bool | connected_ = true |
| Configuration | config_ |
| std::string | device_path_ |
| Thread | rx_thread_ |
| Thread | tx_thread_ |
| uint8_t * | rx_buff_ = nullptr |
| uint8_t * | tx_buff_ = nullptr |
| size_t | buff_size_ = 0 |
| Semaphore | write_sem_ |
| Mutex | read_mutex_ |
| ReadPort | _read_port |
| WritePort | _write_port |
Additional Inherited Members | |
Public Types inherited from LibXR::UART | |
| enum class | Parity : uint8_t { NO_PARITY = 0 , EVEN = 1 , ODD = 2 } |
| 奇偶校验模式 / Parity mode More... | |
Data Fields inherited from LibXR::UART | |
| ReadPort * | read_port_ |
| 读取端口 / Read port | |
| WritePort * | write_port_ |
| 写入端口 / Write port | |
Linux UART 串口驱动实现 / Linux UART driver implementation.
支持按设备路径或 USB VID/PID 自动发现并创建 UART 通道。 Supports UART creation by device path or USB VID/PID auto discovery.
Definition at line 32 of file linux_uart.hpp.
|
inline |
通过设备路径构造 UART / Construct UART by device path
Definition at line 38 of file linux_uart.hpp.
|
inline |
通过 USB VID/PID 构造 UART / Construct UART by USB VID/PID
Definition at line 92 of file linux_uart.hpp.
|
inlinestatic |
Definition at line 170 of file linux_uart.hpp.
|
inline |
Definition at line 151 of file linux_uart.hpp.
|
inlinestatic |
Definition at line 345 of file linux_uart.hpp.
|
inlineprivate |
Definition at line 355 of file linux_uart.hpp.
|
inlineoverridevirtual |
设置 UART 配置 / Sets the UART configuration
ErrorCode::OK,否则返回相应错误码 / Returns the operation status, ErrorCode::OK if successful, otherwise an error code该方法为纯虚函数,子类必须实现具体的 UART 配置逻辑。 This is a pure virtual function. Subclasses must implement the specific UART configuration logic.
Implements LibXR::UART.
Definition at line 234 of file linux_uart.hpp.
|
inline |
Definition at line 226 of file linux_uart.hpp.
|
inlineprivate |
Definition at line 390 of file linux_uart.hpp.
|
inlinestatic |
Definition at line 347 of file linux_uart.hpp.
|
private |
Definition at line 443 of file linux_uart.hpp.
|
private |
Definition at line 444 of file linux_uart.hpp.
|
private |
Definition at line 439 of file linux_uart.hpp.
|
private |
Definition at line 433 of file linux_uart.hpp.
|
private |
Definition at line 432 of file linux_uart.hpp.
|
private |
Definition at line 434 of file linux_uart.hpp.
|
private |
Definition at line 431 of file linux_uart.hpp.
|
private |
Definition at line 441 of file linux_uart.hpp.
|
private |
Definition at line 437 of file linux_uart.hpp.
|
private |
Definition at line 435 of file linux_uart.hpp.
|
private |
Definition at line 438 of file linux_uart.hpp.
|
private |
Definition at line 436 of file linux_uart.hpp.
|
private |
Definition at line 440 of file linux_uart.hpp.