Hi Edward,
Thanks for responding. I thought of doing that, reading the odd byte if I detect we’re off by 1 byte, or if we read 0x55aa. But then I was worried that I would be missing the first sync word, and then I wouldn’t know if I was at the beginning of a frame, or just the next object in a frame I’m already processing. Does that make sense?
Also, how do you determine how many bytes you should read at a time? Last year we were only looking for one object, so we were reading 32 bytes. There was only one object there, 16 bytes, so the rest were 0s. We’ve been trying to update it to be able to read 2 objects this time. We’ve tried reading 32, 64, and 128 bytes in different runs. For some reason, when we read 128 bytes, it was coming back all zeros.
When we read 64 bytes, we thought it was working for awhile, but then we ran into this offset problem. After more testing tonight, I think that was because we were reading into the next frame, located in the latter part of those 64 bytes, after reading our first frame in the first part of the 64 bytes.
We eventually got it to work, meaning not getting those offset bytes in later reads, by reading 30 bytes. I guess because this is the size of a frame with 2 objects?
I’m glad we got that to work, but it does seem inflexible, in that it seems like you need to know how many objects you are expecting to see, in order to know how many bytes to read to keep the byte stream aligned in subsequent reads. We were trying to design a system that would work when you don’t know how many objects you’re going to see.
It seems like to do that, you’d have to read 64 bytes, for example, process 1 frame, and if you see a partial 2nd frame, you have to store that, read another 64 bytes, piece those pieces of the frame together, etc. I guess I was thinking of a single read per frame.
Sorry if that got to rambling. Kinda brain dumping, we did a lot of testing earlier tonight. I’m mentoring a first robotics team for the first time. I wasn’t there when they got the pixy processing working last year, but we’re working from that code, trying to improve it to read 2 (or more) objects.