Wagner: Say you have a 10-byte fixed length packet. Your receiving routine would typically wait until 10 bytes are in its buffer, then apply the CRC routine. If the CRC does not match, you might empty the buffer, saying that there is garbage coming in, not packets. Well, the routine may not ever synchronize if you do this. As an example, say the transmitter is always sending out valid 10-byte packets. What if the receiver wakes up in the middle of a packet? It receives 5 bytes from the end of the first packet, then 5 bytes from the start of the next packet, applies the CRC, discards the data and then repeats the whole process, staying out of sync, even though there are good packets coming in. The trick is to only discard one byte instead of the whole buffer or a whole packet's worth of bytes. Then the receiver essentially has a sliding 10-byte window, whose CRC will only match up if there is a valid packet in the 10 bytes. Of course, once you do get valid packet, you take the whole packet out at once. Maybe this is obvious to everyone, but it had me stumped for a bit--once I got out of sync it would reject all packets. At 06:57 AM 8/24/99 , you wrote: >Brent Crosby wrote: >[snip] >> If you are going to throw data away when the CRC does not match, >> remember that it is important to only throw away one byte, and then >> re-apply the CRC criteria. This will guarantee that your algorithm >> re-synchronizes without the need for timeouts or any other complex >> code. > >Brent, I did not slept well last night, and probably this is the reason >why I can't understand your text above. Can you explain it better, >please? I understand you are talking about the received data block in >error, but what you mean with "throw away one byte"? strip it out from >the data block? >Wagner. Sincerely, Brent A. Crosby | Brent A. Crosby | Crystalfontz America, Incorporated | 15611 East Washington Road | Valleyford, WA 99036 | voice (509) 291-3514 facsimile (509) 291-3345 | http://www.crystalfontz.com brent@crystalfontz.com