arduino-CAN icon indicating copy to clipboard operation
arduino-CAN copied to clipboard

No RTR receiption

Open aviatorhh opened this issue 6 years ago • 2 comments

Unfortunately RTR messages are not handled correctly. If you look at

void MCP2515Class::handleInterrupt()
{
  if (readRegister(REG_CANINTF) == 0) {
    return;
  }

  while (parsePacket()) {
    _onReceive(available());
  }
}

you can see that _onReceive will only get called if parsePacket returns non-zero.

If the function parsePacket detects the RTR bit set it sets the _rxDlc (data packet length) to zero which in terms of RTR is correct. Unfortunately it returns that zero value.

return _rxDlc;

The solution is simple. Modify the return statement in parsePacket to:

return _rxRtr ? true : _rxDlc;

aviatorhh avatar Sep 25 '19 12:09 aviatorhh

I'll give this a try in the next few days. I was expecting some RTR packets, but never saw them (using the callback onReceive).

BiggRanger avatar Jan 01 '20 03:01 BiggRanger

PR https://github.com/sandeepmistry/arduino-CAN/pull/103 might help with this.

sandeepmistry avatar Nov 19 '22 15:11 sandeepmistry