Saturday, May 10, 2008

Countdown to Victoly!


Laurel and I decided on a modified buffer scheme.

Scheme:
Search for a specific sequence of bytes:

0. Start Delimiter (always 0x7E)

1. Length – MSB (should be 0)

2. Length – LSB (should be 8)

3. API identifier (0x81 for received transmission)

Once we received all these packets, we'll assume that the next 8 bytes are valid and will parse them accordingly. We will need storage space for
Source MSB
Source LSB
ME218 Byte0 Header
ME218 Byte1 Navigation
ME218 Byte2 Special


How things can go horribly wrong:
1. We receive a partial packet while checking for our first 4 states- This one's not so bad. We'll just start looking again for the start delimiter.
2. We receive a partial packet while we think we're
receiving good data- This one's a bit worse. The current packet is trash, and the next packet is trashed as well because our parsing is off. The good news is that we'll detect the fact that the second packet is bad because the four byte sequence will be off. We'll ignore the rest of the packet until a good sequence comes in. The strength of this scheme is that we can wait any length of time until this happens; a valid packet
could be 1 ms or 1 s away and we would still be able to detect it.

State progression:




Reason *not* to do the timer:
1. Needs a lot of buffers to store all the data
2. Hard to debug/test: no way to indicate why a packet was rejected
3. Timers are squirrelly


No comments: