CAN rderror and tderror example needed.

28 Jun 2010 . Edited: 28 Jun 2010

What exactly does rderror and tderror tell you?  I assume that rderror reports TRUE if there was a buffer overflow and messages were missed?  I could not find any sample code for rderror and tderror on the forum or website.  Can someone post some examples?

 

Here is how I'm using rderror.  Is this correct?

Edited code after original post:

 

        CAN1ReadError = FALSE;
        if(can1.rderror() == TRUE)
        {
            pc.printf("CAN1 Read Error.  Buffer overflow.\r\n");
        }

        MessageFoundCAN1 = FALSE;
        if ( can1.read(CAN1_MsgRx) )  // See if any CAN messages are in CAN1 Buffer- MSCAN 
        {
            MessageFoundCAN1 = TRUE;
            led1 = !led1; // Toggle LED1
            MessagesFound =  MessagesFound + 1;
        }
28 Jun 2010

These routines return the CAN rx and tx error counters - they return integers. These error counters are incremented by the CAN block when it detects an error, and decremented on error-free communications. The LPC1768 user manual, Chapter 16, section 8.1 goes into a little more detail.