|
Re: Distinguish Serial Data?
[quote=6600gt]How can you distinguish a group of bytes(data) form another?
Other than using a unique byte in front a group of bytes.
QUOTE]
If all you have is a stream of bytes coming through the serial port, there's no way other than try to come up with a unique "signature". IFI uses a two byte scheme of hex FFFF for the dashboard packets to synchronize them AND is careful to prevent most of their single byte data from taking on the value FF. This is why, if I remember right and I think there's one packet you have to be careful with, that the PWM values are interwoven in the packet since they're limited to values from 0 to FE (0 to 254).
If your data can take on all values, then using a one byte signature doesn't work because, in general, any byte in the stream has some probability of having that value. In a uniform distribution, this would be 1/256. A two byte signature reduces this to 1/65536 that any two byte sequence matches, etc.
IFI gets away with a little since their data is single byte and a large part of it is range limited. If you expanded their data to 16 bits AND allow signed numbers, FFFF becomes much more likely since it's really -1.
Going to ASCII increases your overhead but can aleviate the problem if your data is all numeric or the nonnumeric entities have limited values. Then you can just "name" your packets.
|