05-31-2007 10:52 AM - edited 05-31-2007 10:52 AM
Message Edited by Forsaken Angel on 05-31-2007 10:54 AM
05-31-2007 11:58 AM
05-31-2007 01:22 PM
06-01-2007 03:44 AM
06-01-2007 06:18 AM
06-01-2007 07:51 AM
How fast are the characters coming to your serial port? If they're nto terribly fast, my approach would be to read them one at a time, wait for an escape character, discard it, then concatenate all the received characters until the next escape character is received.
Be careful, then to check the first character in the resultant string is not escape (it might be if you started your receiver inthe middle of a "packet").
The output from this look would be a complete, variable-length packet.
06-01-2007 09:28 AM
As I've already indicated, since you do not know how many bytes you're going to get you have to accumulate the bytes you read into a shift register and then look for your start/end markers. Once you find your frame (you may have more than one), snip it out, and only pass whatever is left into the next iteration, since you could have bytes from a new frame. You do not need to carry around everything you've read. Only enough so that you can get a complete frame out. Your "concat" version essentially does this, except you're just carrying around everything you've read so far. Modify this so that you look at your concatenated string, find frames, remove them from the string, and pass out whatever characters are left into the next frame. If in a particular iteration you do not yet have a full frame, then don't do any frame processing or graph updates.
My real problem is how can I process each frame without storing all the information I received, but without knowing how many bytes will I receive each time.