|
libxr
Embedded C++ framework for bare-metal, RTOS and Linux
|
使用单个 I/O 线程的 Linux 串口 / Linux UART with one I/O thread. 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) | |
| 通过设备路径构造串口 / Construct a 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 构造串口 / Construct a 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 控制接口名称构造串口 / Construct a UART by USB control interface. | |
| 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 接口和序列号构造串口 / Construct a UART by USB interface and serial. | |
| std::string | GetByPathForTTY (const std::string &tty_name) |
| 查找设备的稳定路径 / Find a stable path for a TTY. | |
| void | SetLowLatency (int fd) |
| 尝试启用设备低延迟选项 / Try to enable the device low-latency option. | |
| ErrorCode | SetConfig (UART::Configuration config, bool=false) override |
| 提交串口配置请求 / Submit a UART configuration request. | |
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) |
| 查找匹配的 USB 串口设备 / Find a matching USB TTY device. | |
| static bool | FindUSBTTYByVidPid (const std::string &target_vid, const std::string &target_pid, const std::string &target_control_interface_name, std::string &tty_path) |
| 查找匹配的 USB 串口设备 / Find a matching USB TTY device. | |
| 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) |
| 查找匹配的 USB 串口设备 / Find a matching USB TTY device. | |
Friends | |
| class | Detail::LinuxUARTReadPort |
Additional Inherited Members | |
Public Types inherited from LibXR::UART | |
| enum class | Parity : uint8_t { NO_PARITY = 0 , EVEN = 1 , ODD = 2 } |
| 奇偶校验模式 / Parity mode More... | |
Public Attributes inherited from LibXR::UART | |
| ReadPort * | read_port_ |
| 读取端口 / Read port | |
| WritePort * | write_port_ |
| 写入端口 / Write port | |
使用单个 I/O 线程的 Linux 串口 / Linux UART with one I/O thread.
支持设备路径和 USB VID/PID、控制接口名称、序列号匹配。线程统一负责打开、关闭、 接收、发送、配置和重连,读写端口的通知只唤醒该线程。 Supports device paths or USB VID/PID, control-interface name, and serial matching. One thread handles open, close, RX, TX, configuration, and reconnect. Port callbacks only wake that thread.
Definition at line 73 of file linux_uart.hpp.
|
inline |
通过设备路径构造串口 / Construct a UART by device path.
| dev_path | 设备路径 / Device path. |
| baudrate | 初始波特率,必须大于零 / Positive initial baud rate. |
| parity | 奇偶校验方式 / Parity mode. |
| data_bits | 数据位数,范围 5 至 8 / Data bits, from 5 to 8. |
| stop_bits | 停止位数,1 或 2 / Stop bits, 1 or 2. |
| tx_queue_size | 请求队列容量,必须大于零 / Positive TX request capacity. |
| buffer_size | 每个方向的字节队列容量,必须大于零 / Positive per-direction capacity. |
| thread_stack_size | I/O 线程栈大小,单位为字节 / I/O thread stack size in bytes. |
Definition at line 101 of file linux_uart.hpp.
|
inline |
通过 USB VID/PID 构造串口 / Construct a UART by USB VID/PID.
| vid | USB 厂商 ID 字符串 / USB vendor ID string. |
| pid | USB 产品 ID 字符串 / USB product ID string. |
| baudrate | 初始波特率,必须大于零 / Positive initial baud rate. |
| parity | 奇偶校验方式 / Parity mode. |
| data_bits | 数据位数,范围 5 至 8 / Data bits, from 5 to 8. |
| stop_bits | 停止位数,1 或 2 / Stop bits, 1 or 2. |
| tx_queue_size | 请求队列容量,必须大于零 / Positive TX request capacity. |
| buffer_size | 每个方向的字节队列容量,必须大于零 / Positive per-direction capacity. |
| thread_stack_size | I/O 线程栈大小,单位为字节 / I/O thread stack size in bytes. |
Definition at line 139 of file linux_uart.hpp.
|
inline |
按 USB 控制接口名称构造串口 / Construct a UART by USB control interface.
| vid | USB 厂商 ID 字符串 / USB vendor ID string. |
| pid | USB 产品 ID 字符串 / USB product ID string. |
| control_interface_name | 控制接口名称,空值不限制 / Control interface, empty for any. |
| baudrate | 初始波特率,必须大于零 / Positive initial baud rate. |
| parity | 奇偶校验方式 / Parity mode. |
| data_bits | 数据位数,范围 5 至 8 / Data bits, from 5 to 8. |
| stop_bits | 停止位数,1 或 2 / Stop bits, 1 or 2. |
| tx_queue_size | 请求队列容量,必须大于零 / Positive TX request capacity. |
| buffer_size | 每个方向的字节队列容量,必须大于零 / Positive per-direction capacity. |
| thread_stack_size | I/O 线程栈大小,单位为字节 / I/O thread stack size in bytes. |
Definition at line 163 of file linux_uart.hpp.
|
inline |
按 USB 接口和序列号构造串口 / Construct a UART by USB interface and serial.
| vid | USB 厂商 ID 字符串 / USB vendor ID string. |
| pid | USB 产品 ID 字符串 / USB product ID string. |
| control_interface_name | 控制接口名称,空值不限制 / Control interface, empty for any. |
| serial | 设备序列号,空值不限制 / Device serial number, empty for any. |
| baudrate | 初始波特率,必须大于零 / Positive initial baud rate. |
| parity | 奇偶校验方式 / Parity mode. |
| data_bits | 数据位数,范围 5 至 8 / Data bits, from 5 to 8. |
| stop_bits | 停止位数,1 或 2 / Stop bits, 1 or 2. |
| tx_queue_size | 请求队列容量,必须大于零 / Positive TX request capacity. |
| buffer_size | 每个方向的字节队列容量,必须大于零 / Positive per-direction capacity. |
| thread_stack_size | I/O 线程栈大小,单位为字节 / I/O thread stack size in bytes. |
Definition at line 192 of file linux_uart.hpp.
|
inlinestatic |
查找匹配的 USB 串口设备 / Find a matching USB TTY device.
Definition at line 287 of file linux_uart.hpp.
|
inlinestatic |
查找匹配的 USB 串口设备 / Find a matching USB TTY device.
Definition at line 274 of file linux_uart.hpp.
|
inlinestatic |
查找匹配的 USB 串口设备 / Find a matching USB TTY device.
Definition at line 264 of file linux_uart.hpp.
|
inline |
查找设备的稳定路径 / Find a stable path for a TTY.
| tty_name | 原始设备路径 / Original device path. |
Definition at line 236 of file linux_uart.hpp.
|
inlineoverridevirtual |
提交串口配置请求 / Submit a UART configuration request.
| config | 目标配置 / Requested configuration. |
Implements LibXR::UART.
Definition at line 406 of file linux_uart.hpp.
|
inline |
尝试启用设备低延迟选项 / Try to enable the device low-latency option.
| fd | 已打开的设备描述符 / Open device descriptor. |
Definition at line 384 of file linux_uart.hpp.
|
friend |
Definition at line 75 of file linux_uart.hpp.