views:

77

answers:

2

RS-232 communication sometimes uses 9-bit bytes. This can be used to communicate with multiple microcontrollers on a bus where 8 bits are data and the extra bit indicates an address byte (rather than data). Inactive controllers only generate an interrupt for address bytes.

Can a Linux program send and receive 9-bit bytes over a serial device? How?

+3  A: 

The termios system does not directly support 9 bit operation but it can be emulated on some systems by playing tricks with the CMSPAR flag. It is undocumented and my not appear in all implementations.

Here is a link to a detailed write-up on how 9-bit emulation is done:

http://www.lothosoft.ch/thomas/libmip/markspaceparity.php

Amardeep
+1  A: 

Can a Linux program send and receive 9-bit bytes over a serial device?

The standard UART hardware (8251 etc.) doesn't support 9-bit-data modes.

ChrisW
Most UARTs only have 8 bit data (and status) registers so it's not obvious how you would even send/receive 9 bit data - maybe it would require two 8 bits reads/writes per 9 bit byte ?
Paul R
@Paul R - Amardeep may be suggesting you do it by manually toggling the stop-bit and/or parity-bit settings before transmitting each byte; but that wouldn't do for receiving 9-bit data.
ChrisW
An 8250/16450/16550 UART must be tricked into transmitting the 9th data bit by using mark and space parity. You can't manually toggle start and stop bits. Receive can be done using parity error detection.
Amardeep