|
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 | |
| LinuxUART (const std::string &vid, const std::string &pid, const std::string &serial, 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/serial | |
| 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, const std::string &target_serial, std::string &tty_path) |
| static ErrorCode | ReadFun (ReadPort &, bool) |
| static ErrorCode | WriteFun (WritePort &port, bool) |
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(/serial) 自动发现并创建 UART 通道。 Supports UART creation by device path or USB VID/PID(/serial) auto discovery.
Definition at line 34 of file linux_uart.hpp.
|
inline |
通过设备路径构造 UART / Construct UART by device path
Definition at line 40 of file linux_uart.hpp.
|
inline |
通过 USB VID/PID 构造 UART / Construct UART by USB VID/PID
Definition at line 95 of file linux_uart.hpp.
|
inline |
通过 USB VID/PID/序列号构造 UART / Construct UART by USB VID/PID/serial
Definition at line 107 of file linux_uart.hpp.
|
inlinestatic |
Definition at line 199 of file linux_uart.hpp.
|
inline |
Definition at line 175 of file linux_uart.hpp.
Definition at line 389 of file linux_uart.hpp.
|
inlineprivate |
Definition at line 399 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 278 of file linux_uart.hpp.
|
inline |
Definition at line 270 of file linux_uart.hpp.
|
inlineprivate |
Definition at line 434 of file linux_uart.hpp.
Definition at line 391 of file linux_uart.hpp.
|
private |
Definition at line 487 of file linux_uart.hpp.
|
private |
Definition at line 488 of file linux_uart.hpp.
|
private |
Definition at line 483 of file linux_uart.hpp.
|
private |
Definition at line 477 of file linux_uart.hpp.
|
private |
Definition at line 476 of file linux_uart.hpp.
|
private |
Definition at line 478 of file linux_uart.hpp.
|
private |
Definition at line 475 of file linux_uart.hpp.
|
private |
Definition at line 485 of file linux_uart.hpp.
|
private |
Definition at line 481 of file linux_uart.hpp.
|
private |
Definition at line 479 of file linux_uart.hpp.
|
private |
Definition at line 482 of file linux_uart.hpp.
|
private |
Definition at line 480 of file linux_uart.hpp.
|
private |
Definition at line 484 of file linux_uart.hpp.