CANbus compilation error


I have two fez panda 2 boads and i want to set up a CAN network between them. I have been using sample code from the Beginners Guide to NETMF as a baseline for my code.

I am using the GHI NETMD 4.1 SDK and MS C# 2010 express.

I am having compilation errors - please advise, see my complete code below

using System.IO;
using System.Threading;
using System.Text;
using System.IO.Ports;
using System.Resources;

namespace MFConsoleApplication1
    public class Program
        public static void Main()

            // Bitrate 250Kbps
            // CLK = 72 Mhz, with BRP = 12 -> 6Mhz CAN clock
            // 6Mhz/250Kbps = 24 TQ
            // T1 = 16 minus 1 for sync = 15
            // T2 = 8
            // 15 + 1 + 8 = 24 TQs which is what we need
            const int BRP = 12;
            const int T1 = 15;
            const int T2 = 8;

            // Initialize CAN channel, set bit rate
            CAN canChannel = new CAN(CAN.Channel.Channel_1, ((T2 - 1) << 20) | ((T1 - 1) << 16) | ((BRP - 1) << 0));

            // make new CAN message
            CAN.Message message = new CAN.Message();

            // make a message of 8 bytes
            for (int i = 0; i < 8; i++)

            message.Data[i] = (byte)i;

            message.DLC = 8; // 8 bytes
            message.ArbID = 0xAB; // ID
            message.IsEID = false; // not extended ID
            message.IsRTR = false;// not remote

            // send the message

            // wait for a message and get it.
            while (canChannel.GetRxQueueCount() == 0);

            // get the message using the same message object

            // Now "message" contains the data, ID,
            // flags of the received message.

The compilation errors are:

Error 1 No overload for method ‘PostMessages’ takes 1 arguments

Error 2 ‘GHIElectronics.NETMF.Hardware.CAN’ does not contain a definition for ‘GetRxQueueCount’ and no extension method ‘GetRxQueueCount’ accepting a first argument of type ‘GHIElectronics.NETMF.Hardware.CAN’ could be found (are you missing a using directive or an assembly reference?)

Error 3 No overload for method ‘GetMessages’ takes 1 arguments

your help will be greatly appreciated.


The compiler is right:

You syntax is wrong. Look up the correct syntax for the calls
xxxx.PostMessages(TxMsg, 0, 1);, i.e three parameters)
xxxx.GetMessages(msgList, 0, msgList.Length); etc.
There is an example on the code page that shows this.

Thanks, i seem to have solved that problem.

Although the issue with the GetRxQueueCount is still a problem.

I am a newbie at programming in C#, if i am not mistaken the GetRxQueueCount signals when a message is received correct?

is there any alternate method to do this?


The best place to start is the Beginner’s Guide. This is on the Wki page:

Look through that. There is a complete CAN example with all the essentials, including the use of interrupts to signal incoming packets. You can use the function “can.ReceivedMessagesCount” to get the number of messages without retrieving them. Again, read the guide and copy the example to a program. Then you can step through and look at the variables etc.
You can also look at the class to see what methods / functions are available.

FYI: the referenced CAN example is in

I think the code example is already based on that page (or perhaps the corresponding at; the code comments parts suggest it.