|
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 &control_interface_name, 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/control interface name 构造 UART Construct UART by USB VID/PID/control interface name | |
| LinuxUART (const std::string &vid, const std::string &pid, const std::string &control_interface_name, 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/control interface name/serial 构造 UART Construct UART by USB VID/PID/control interface name/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, std::string &tty_path) |
| static bool | FindUSBTTYByVidPid (const std::string &target_vid, const std::string &target_pid, const std::string &target_control_interface_name, std::string &tty_path) |
| static bool | FindUSBTTYByVidPid (const std::string &target_vid, const std::string &target_pid, const std::string &target_control_interface_name, 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(/control interface name[/serial]) 自动发现并创建 UART 通道。 Supports UART creation by device path or USB VID/PID(/control interface name[/serial]) auto discovery.
Definition at line 36 of file linux_uart.hpp.
|
inline |
通过设备路径构造 UART / Construct UART by device path
Definition at line 42 of file linux_uart.hpp.
|
inline |
通过 USB VID/PID 构造 UART / Construct UART by USB VID/PID
Definition at line 97 of file linux_uart.hpp.
|
inline |
通过 USB VID/PID/control interface name 构造 UART Construct UART by USB VID/PID/control interface name
Definition at line 116 of file linux_uart.hpp.
|
inline |
通过 USB VID/PID/control interface name/serial 构造 UART Construct UART by USB VID/PID/control interface name/serial
Definition at line 136 of file linux_uart.hpp.
|
inlinestatic |
Definition at line 239 of file linux_uart.hpp.
|
inlinestatic |
Definition at line 230 of file linux_uart.hpp.
|
inlinestatic |
Definition at line 223 of file linux_uart.hpp.
|
inline |
Definition at line 199 of file linux_uart.hpp.
Definition at line 447 of file linux_uart.hpp.
|
inlineprivate |
Definition at line 457 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 336 of file linux_uart.hpp.
|
inline |
Definition at line 328 of file linux_uart.hpp.
|
inlineprivate |
Definition at line 492 of file linux_uart.hpp.
Definition at line 449 of file linux_uart.hpp.
|
private |
Definition at line 545 of file linux_uart.hpp.
|
private |
Definition at line 546 of file linux_uart.hpp.
|
private |
Definition at line 541 of file linux_uart.hpp.
|
private |
Definition at line 535 of file linux_uart.hpp.
|
private |
Definition at line 534 of file linux_uart.hpp.
|
private |
Definition at line 536 of file linux_uart.hpp.
|
private |
Definition at line 533 of file linux_uart.hpp.
|
private |
Definition at line 543 of file linux_uart.hpp.
|
private |
Definition at line 539 of file linux_uart.hpp.
|
private |
Definition at line 537 of file linux_uart.hpp.
|
private |
Definition at line 540 of file linux_uart.hpp.
|
private |
Definition at line 538 of file linux_uart.hpp.
|
private |
Definition at line 542 of file linux_uart.hpp.