AnsweredAssumed Answered

canReceive using a fix mailbox number (do not use CAN_ANY_MAILBOX)

Question asked by Aurelien.Leclercq on Jul 10, 2014
Latest reply on Jul 22, 2014 by Erwan Y
Hello,

I want to use canReceive and specify the mailbox to read (do not use CAN_ANY_MAILBOX). Example: if I want to check the first mailbox, I use:

canReceive(can1.canp, 1, &rxmsg, TIME_IMMEDIATE) == MSG_OK

canReceive first checks if the buffer received data using the can_lld_is_rx_nonempty function. If you give the mailbox number 1 to this function, it checks the mailbox 0 (BUF[0]).

The problem is that next to this check, the function can_lld_receive will access the second mailbox (BUF[1]).

To fix this, I suggest to define CAN_ANY_MAILBOX to 0xFF and change the switch values in can_lld_is_rx_nonempty from 1-8 to 0-7.

My target is SPC56EL60 but it applies to all families and I use SPC5 Studio.

Is it a bug or I missed something? I can't update SPC5 Studio at the moment, this bug is maybe already fixed.

EDIT: using CAN_ANY_MAILBOX make these 2 functions searching through all mailboxes. In my example they both found that the first mailbox contains data, so it works... All the examples I found are using  CAN_ANY_MAILBOX, did anybody tried to specify a mailbox number?

Outcomes