MCAN message buffering

Discussion to talk about software related topics only.
Post Reply
Anguel
Posts: 30
Joined: Fri Aug 23, 2019 12:39 am

MCAN message buffering

Post by Anguel »

Hi,

I am using the MODM7AE70 and try to understand how MCAN message buffering actually works with the Netburner API.
Regarding message reception, this part of the Simple CAN example code makes the RTOS block and wait for a new CAN message:

Code: Select all

CanRxMessage can_msg(&CanFifo);
It passes a reference to a CanFifo which seems to be an RTOS object and is defined as:

Code: Select all

OS_FIFO CanFifo;
But I don't find the size of this FIFO defined anywhere. So how does this work? Or is it somehow referring to the hardware FIFO of the CAN controller? Sorry, I am confused as I don't understand if incoming messages are already buffered and how deep the buffer is.
BTW, what is exactly the difference between a FIFO and a Queue in NBRTOS? It is not clear to me where to use which.

Regarding sending CAN messages this looks like this:

Code: Select all

mcan_instance.send_message(ExtToNbId(0x1234), (uint8_t *) "ETESTR", 6);
As far as I understand this is not buffering anything but uses busy polling until there is room for the message to send. Is this correct?

Thanks in advance,

Anguel
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: MCAN message buffering

Post by pbreed »

CAN messages are all placed in the PrivateCanData structures.
By default this is 512.

From mcan.cpp:

#define CAN_DATA_STORE_SIZE (512)
static PrivateCanData CanDataArray[CAN_DATA_STORE_SIZE];


The OS_FIFO is a linked list internally so we stack these locally statically allocated buffers on the fifo.
The first element of the PrivateCanData is
os_fifo_el *pNext;
Used to create the linked list under the fifo...

So if you let 512 RX messages accumulate without ever reading/freeing them, then CAN will stop recieving.
Post Reply