Post History
How does the receiver understand the end bits? It doesn't. The purpose of stop bits (what you seem to be calling "end bits") is to leave a guaranteed gap before the next start bit. The leading e...
Answer
#1: Initial revision
<blockquote>How does the receiver understand the end bits?</blockquote> It doesn't. The purpose of <i>stop bits</i> (what you seem to be calling "end bits") is to leave a guaranteed gap before the next start bit. The leading edges of start bits are always idle to non-idle transitions. The line must therefore always be at idle before any new character. The stop bit(s) of the previous character guarantee that. For modern digital communication, a single stop bit is sufficient. Early equipment that received asynchronous serial protocol used mechanical means for decoding, such as the common ASR-35 teletype back in the 1970s. Those mechanisms sometimes needed more than one bit time to reset to being ready for the start of the next character. It was common then to send two stop bits. Some operations that took more time, like a carriage after a long text line, might require 3 stop bits. There were algorithms to optimized the number of stop bits, taking into account the characteristics of the receiving equipment, like an ASR-35. <blockquote>In my case the last 2 0s could have been the end bits but instead the receiver understand the last two 0s from 0100100(0) are actually part of the data</blockquote> Right, because receivers don't "decode" stop bits. Transmitters and receivers have to agree ahead of time how many bits follow the start bit, and how long each of those bits take. Receivers then just grab the value of the line near the center of where each bit is supposed to be. Nothing in the data encodes where the data ends. Everything is relative to the leading edge of the start bit. This is why you have to specify protocol details when using RS-232. You may have seen specs like "9600 baud, 8 data bits, no parity bit, 1 stop bit". This is often abbreviated as "9600 8-N-1". Your example uses 7-E-1, meaning 7 data bits, even parity, and 1 stop bit. Note that the stop bits spec is a minimum. There can be any arbitrary additional gap between characters. The receiver can't distinguish between 8-N-1 with an additional 1-bit delay between two characters, and two characters sent with 8-N-2.