I must admit I am surprised to see it so vehemently disagreed as to what is "standard" for an UART transceiver. I guess I have been pampered with the support I've had with the microcontrollers I've used!
NXP i.MX RT1062 (as used on Teensy 4.x) supports 7 to 10 bit data (the transmitter and receiver have 9 to 13 bit shift registers), and internally supports both idle and break "characters" (break length being 9 to 15 bit times, depending on the relevant settings), and even hardware flow control (RTS/CTS).
Even Atmel (now Microchip) ATmega32U4, an 8-bit AVR with native USB support, supports 5 to 9 bit data, all with no or even or odd parity, and with one or two stop bits (the datasheet explicitly mentions all 30 combinations are supported). The other 32-bit NXP chips I often use (specifically on Teensy LC and 3.x) have similar support.
[For framing messages] one can use a simple a SLIP frame format: https://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol
There are more efficient, but more complex implementations for creating this kind of soft framings.
As mentioned,
COBS or Consistent Overhead Byte Stuffing is one.
One could say that using the BREAK condition –– which is basically the same size as a normal serial data frame but one that is separate from all valid data frames –– would be even simpler, and just as efficient as COBS for framing. Unfortunately, not all UART/USART implementations support sending or receiving BREAK conditions/characters in a sensible manner.
I personally prefer a variant of SLIP with 1/
N maximum overhead (depending on implementation complexity) and minimal buffering (four bytes for 33% maximum overhead). The major difference to SLIP and COBS is that my variant allows multiple frame byte values that will not occur in the data. (There are also multiple byte values that always begin an escape sequence.)
I developed the variant for an use case where I wanted to multiplex multiple logical byte streams onto a single byte stream with minimal latency (thus minimal buffering and very short uninterruptible sequences) and minimal work for both multiplexing and demultiplexing.
Using an extra bit to differentiate
structure and
data bytes is an interesting approach. It means data can be sent as-is, without any need for escaping. However, the extra bit does mean something like 8% to 10% constant overhead (because each UART data frame will typically have at least a START bit and one or two STOP bits in addition to the data bits), plus the frame structuring bytes on top. Of course, if one has just two byte streams to multiplex, then the extra bit (or bits!) could be used to indicate the stream the data bits are part of.
The two-stream-multiplexing by an extra bit reminds me of the SPI bus variant many OLED and small TFT display module driver chips (ILI9341, ST7735S, ST7789, etc.) use for (serial) communications with a microcontroller: they have a separate Data/Command signal indicating whether the current/next byte is a new command, or data related to the previous command.