Building a CAN API for Arduino DUE

Ok, I made a 4th example sketch in my copy of the canbus library. It turns out that extended frames do work fine already with the library. The sketch is a ping/pong type where the two canbus devices are set up to fire and receive frames pointing at each other so one sends, the other receives,then that one sends and the first receives, back and forth. Currently I have 100uS delay between each sending to slow things down a bit. I have tested this to be pretty stable. Right now I am looking at a serial monitor showing 5 million ping/pongs in a row. If I take the 100us delay out it will work VERY quickly but usually lock up after around 1 million ping/pongs. I don't know why quite yet, I assume the speed is causing it to sometimes miss setting things right and even one failed send will stop the sequence from happening.

Word to the wise, I test with a canbus to usb dongle also connected so I can see the traffic. I don't have a dongle that can handle 100,000 frames per second and you probably don't either. But, it appears the Due can do it. So, you kind of have to trust that the sent and received counters are accurate because it's hard to find another piece of hardware to verify.

I've attached the newest version of the library with the above 4th example.

Edit: I tested up to 100 million successful ping/pongs and quit. If it's stable to that much it seems stable enough. It would be good if someone wanted to try testing how little delay you can add and still have the traffic stay stable.

CAN.zip (26.5 KB)