Linux串口1.5停止位

Linux serial port 1.5 stop bits

linux串口可以使用1.5个停止位吗? POSIX 似乎不支持这一点。我查看了 pyserial 的源代码,其中 1.5 个停止位在 POSIX 接口中被解释为 2 个停止位。而在串口1.5停止位的支持代码中的单声道源代码中根本没有处理。 linux中是否有另一个非POSIX possibility/driver支持1.5停止位?也许使用 FTDI 或 silabs 驱动程序?

什么是串行控制器和所需的字长?通常,对于 5 位字 (CS5),设置 CSTOPB 标志意味着发送 1.5 个停止位,而不是一个或两个。

例如,对于 8250 UART,Linux 执行此操作(在 drivers/tty/serial/8250/8250_port.c 中):

static unsigned char serial8250_compute_lcr(struct uart_8250_port *up,
                                            tcflag_t c_cflag)
{
        unsigned char cval;

        switch (c_cflag & CSIZE) {
        case CS5:
                cval = UART_LCR_WLEN5;
                break;
        case CS6:
                cval = UART_LCR_WLEN6;
                break;
        case CS7:
                cval = UART_LCR_WLEN7;
                break;
        default:
        case CS8:
                cval = UART_LCR_WLEN8;
                break;
        }

        if (c_cflag & CSTOPB)
                cval |= UART_LCR_STOP;
[…]
        return cval;
}

UART_LCR_STOP 定义为 0x04.

According to this documentation of the 8250 UART,设置 LCR 寄存器中的第 2 位意味着

stop bits = 1.5 for 5 bit words or 2 for 6, 7 or 8 bit words

如果您有不同的 UART,则必须查看内核源代码并查看 POSIX 标志如何传递给硬件,以及对线路的影响。