View Single Post
  #75   Spotlight this post!  
Unread 13-06-2002, 20:24
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
I'd avoid reading one byte at a time if possible. It is inefficient and means your program will loop more often. And if you miss a byte, the output could appear sluggish or delayed. If you want to do something similar to this, I'd recommend that that you just discard data until you find a 255,255 and then copy the next 24 bytes into your data structure.

Quote:
Originally posted by Ian W.
ah, ok that makes sense. so, i do a first read, finding the double 255/0xff, and then once i find that, start the main loop? i think i know how that should work, although not completely sure.
Everytime through the loop you should resort the data. Otherwise, if you miss even a single bit, the whole packet will be off and the data won't make any sense. My advice is to read the data into a temporary storage space and then sort it into a final one. That's the way I did it in my dashboard program, and it works fairly well. If you want to take a look, the source is at http://FIRSTprograms.tripod.com under the name gDash. Or, I can send you just the relevant portion of code if you would prefer.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php

Last edited by rbayer : 13-06-2002 at 20:30.