Snippet - CERB family managed CANBUS driver

I just posted CERB family managed CANBUS driver on Codeshare. Feel free to discuss and make suggestions here.

4 Likes

Needed, thanks for sharing.

I too purcased the FEZ Cerberus Mainboard for a small footprint/low-cost automobile project with CanBus. Reading the Key Features section stating that the Cerb has CanBus and desided to go for it… but did not do my homework researching enough about how well CanBus was supported.

Did anyone try to rewrite this to a native driver or using RLPLite?

Thanks for the code, do you have any information on the current throughput rates?

Throughput depends a lot on the way your code is organized. Because this is not a “real” driver the only input buffering you get is from the buffers on the STM chip (=4).
Therefore it is important to call as much as possible the GetMessage on your Canbus channel.

Your main loop should look something like:

for (;;)
{
        // handle ALL input messages before doing other work
        while ((rxMessage = canChannel.GetMessage()) != null)
        {
               // write your input message handler code here
        }
       // do other work: the time you spend here will determine throughput
}

Above assumes single threaded application. Alternative you can read messages from a dedicated thread but then you will have to add a “reasonable” sleep time because there is no event that tells you there is a message available and you don’t want to block other threads!

I am using above approach but I take care that the “other work” does not take a long time for a single run. Works fine for my app …

Code should be obsolete. Move to NETMF 4.3 for native CAN support!