Riva:
Does some device on the bus send the same message on a regular basis ?
You get status request messages sent out periodically to check that that modules are still active, but nothing more frequent than 3 second intervals. You could potentially miss an awful lot of traffic in that period. I guess it's still good practice to try and include some sort of error recovery though.
My problem at the moment is that when it gets out of sync, it quite often causes the arduino to reset, or simply becomes unresponsive, so it's hard to debug. I don't know for sure, but think it's the IBUSbyte array getting full and over writing into program memory. I've increased the array size to 256 bytes to allocate more space, but it still locks up during busy times on the bus. I guess I could make it even bigger, but assumed the biggest it would ever get is when it reads a length byte of 0xFF and tries to read in 255 bytes. Actually, 256 bytes isn't quite big enough. It will already have read in the source and length bytes, so the array could potentially get 257 bytes. I'll increase the array size to 300 just to be sure.
This is one of the reasons I would prefer to not use the length byte to dictate how many bytes to read in before flagging the message as complete. If for any reason the length byte is wrong, the whole system falls over because you start reading in bytes from other messages etc.
Thanks,
Ian.