Reputation: 124
Is it possible to use 1.5 stop bits for the serial port in linux? It seems, that this is not supported by POSIX. I had a look into the source code of pyserial, where 1.5 stop bits are interpreted as 2 stop bits in the POSIX interface. And in the mono source code in the support code for the serial port 1.5 stop bits are simply not handled. Is there another non-POSIX possibility/driver in linux to support 1.5 stop bits? Maybe with the FTDI or silabs driver?
Upvotes: 2
Views: 3076
Reputation: 33719
What's the serial controller and the required word size? Usually, with 5 bit words (CS5
), a set CSTOPB
flag means that 1.5 stop bits are sent, not one or two.
For example, for the 8250 UART, Linux does this (in 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
is defined as 0x04
.
According to this documentation of the 8250 UART, a set bit 2 in the LCR register means
stop bits = 1.5 for 5 bit words or 2 for 6, 7 or 8 bit words
If you have a different UART, you'll have to look at the kernel sources and see how the POSIX flags are passed to the hardware, and what the effect on the wire will be.
Upvotes: 1