RLScott
Joined: 10 Jul 2007 Posts: 465
|
Re: Developing frames/packets using serial data (bytes) |
Posted: Thu May 22, 2008 5:10 am |
|
|
Whenever you have a connection that could be broken, it is good to have a protocol in place to re-establish synchronization in the event that it is lost. Therefore I suggest that you make your StartFlag unique - so that it can never appear in the DataLength, Data, or StopFlag. That means your DataLength would not be straight binary, which could attain any value, but rather it would be encoded in some way to avoid the StartFlag value. The same consideration should be followed for the Data field. One way to do this would be to send 4 bits in each character. Or, if you want to be more efficient, send 7 bits in each character and use bit 7 to indicate that the character is a StartFlag or StopFlag.
Robert Scott
Real-Time Specialties |
|