AnsweredAssumed Answered

MQX CAN bus API usage

Question asked by Kai Falkenberg on Apr 4, 2014
Latest reply on Apr 10, 2014 by Kan_Li



I am writing my first small application using MQX 4.0 and it's CAN bus drivers on a K60 tower board. I've had a look at the kflexcan example code that comes with the MQX bundle. After playing around with it, I'm now wondering if I understand the concept behind it correctly. What I mean is this:

The kflexcan API offers a FLEXCAN_Rx_message() that takes a mailbox as parameter. Now, a mailbox is initialized by FLEXCAN_Initialize_mailbox() that takes a specific CAN ID as parameter. Later you just call _lwevent_wait_ticks() which will block the current task until a message with the requested CAN ID pops up in the mailbox. So far, this is very comfortable and easy to use.

But let's say I'm working with a large number of different CAN IDs. How does this approach work then? Do I have to add a mailbox for every CAN ID that can appear on the bus? That doesnt sound like the way to go..

What I would expect is a function that takes a CAN ID as parameter and then blocks the current task until it receives such a message or hits a timeout. Something like this: can_message_t can_read(can_id_t id, uint_32 timeout). For my purposes this wouldn't need to be thread safe. Do I have to implement such a function myself? How are you guys working with the provided API, regarding multiple CAN IDs?


Thanks for any input!