Building a CAN API for Arduino DUE

Sorry Mark, I should have answered those questions before.

  1. CAN.get_rx_buff() grabs the first canbus frame in the receive buffer. The receive buffer is filled as frames come in to the RX mailboxes. There is currently no way to easily figure out which mailbox the frame came from. The mailboxes are automatically cleared as soon as their frame is placed into the receive buffer. If a frame is being dropped then one of these things happened: all mailboxes that could accept the given frame were still full and the frame could not be received or the software did something dumb and lost the frame. The first possibility shouldn't actually drop the frame because canbus resends until somebody acks the frame. So, the only way it would be "dropped" at the Due is if the Due could not accept it but something else on the bus did set acknowledge on the frame. The second possibility could be a race condition in the interrupt code. It might be harder to find.
  2. Not currently. The frames are automatically stuck into the receive buffer for you to check later on. There isn't a way to register a callback right now.

I have a kvaser leaf light so I might be able to do some testing to see if I can get the Due to drop frames. I know it does sometimes because I've tried to capture a firmware update between an ECU programmer and a motor controller and the Due could not keep up with the traffic. The Kvaser leaf does.