Problem with Cerberus Board and CanDP Module

Hello everybody!

I am developing a very simple system that communicates via CAN and sends some commands and receives response (3 possible commands-3 prossible responses), because of the simplicity of the system i decided to use cerberus board+canDP module assuming it would be fast to do… but how wrong was i :frowning:

i am struggling to make a simple transmission, for some reason it simply doesnt communicate, I am trying to conect with one Pcan-USB analizer (which i have already tested by plugging directly to another one and of course the communication worked without issues), and also i tried communicating a pair cerberus-canDP with another identical pair, and using the same code that simply sends 1 message… thats it… and all my setups there is an error when i try to send, and never receive anything (i have tried several different version of the code, from self thought to examples and codes i found in other posts in here).

the error i receive is:
error 3 (ErrorPassive)which i capture with an error handler… nothing fancy. (btw i verified and when i disconnect the other side of the network and leave only one device, the error changes to error 2).

i have no idea whats wrong, i have searched for 2 days and have tried every single idea ive had, and no luck; can anybody here please take a look at my code and maybe give me an advice?

my cerberus boards work because ia have already tested that, andthe canDW devices are brand new (got 24 of them one week ago)

im using vs 2013/framework 4.3 and the device firmware is 4.3.6.0, FEZ config says there is no more recent release.

Thanks a lot!

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GHI.IO;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace AprendiendoCAN
{
    public partial class Program
    {
/// <summary>
/// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// </summary>
        ControllerAreaNetwork.Message mensaje;
  //      GT.Timer tempo = new GT.Timer(1100);
        void ProgramStarted()
        {
            var can = new ControllerAreaNetwork(ControllerAreaNetwork.Channel.One, ControllerAreaNetwork.Speed.Kbps125);

            can.ErrorReceived += can_ErrorReceived;
            can.MessageAvailable += can_MessageAvailable;

            can.Enabled = true;

            can.SendMessage(new ControllerAreaNetwork.Message() { Data = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, ArbitrationId = 0x12345678, Length = 8, IsRemoteTransmissionRequest = false, IsExtendedId = true });

//            Thread.Sleep(-1);
        }

        private static void can_MessageAvailable(ControllerAreaNetwork sender, ControllerAreaNetwork.MessageAvailableEventArgs e)
        {
            var received = sender.ReadMessage();

            var data = string.Empty;
            for (int i = 0; i < received.Length; i++)
                data += "0x" + received.Data[i].ToString("x2") + " ";

            Debug.Print("   CAN Message   ");
            Debug.Print("-----------------");
            Debug.Print("    ID: " + received.ArbitrationId.ToString());
            Debug.Print("  Time: " + received.TimeStamp.ToString());
            Debug.Print("   RTR: " + received.IsRemoteTransmissionRequest.ToString());
            Debug.Print("   EID: " + received.IsExtendedId.ToString());
            Debug.Print("Length: " + received.Length.ToString());
            Debug.Print("  Data: " + data);
            Debug.Print(""); 
        }
        private static void can_ErrorReceived(ControllerAreaNetwork sender, ControllerAreaNetwork.ErrorReceivedEventArgs e)
        {
            Debug.Print("Error on CAN: " + e.Error.ToString());

        }
    }
}

What i consider important of the Debug output is:

[quote]
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\mscorlib.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Native.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Graphics.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.TinyCore.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.IO.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.IO.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.Usb.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Net.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Gadgeteer\Core\Assemblies.NET Micro Framework 4.3\le\Gadgeteer.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.3 SDK\Libraries\le\GHI.Hardware.dll’
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.3 SDK\Libraries\le\GHI.Usb.dll’
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.3 SDK\Libraries\le\GHI.Pins.dll’
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZCerberus\NETMF 4.3\le\GHIElectronics.Gadgeteer.FEZCerberus.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\USBClientDP\NETMF 4.3\le\GTM.GHIElectronics.USBClientDP.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\CANDW\NETMF 4.3\le\GTM.GHIElectronics.CANDW.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.12.dll’ (Managed): Loaded ‘C:\Users\cuervod\Documents\Visual Studio 2013\Projects\AprendiendoCAN\AprendiendoCAN\bin\Debug\le\AprendiendoCAN.exe’, Symbols loaded.
The thread ‘’ (0x2) has exited with code 0 (0x0).
Using mainboard GHI Electronics FEZ Cerberus version 1.3
Error on CAN: 3
The program ‘[69] Micro Framework application: Managed’ has exited with code 0 (0x0).[/quote]

@ Ingcuervo - I am not sure it will help, but your CAN object might go out of scope when you exit the ProgramStarted method.

Also, tell us about how you wired up the CAN network.

@ Ingcuervo -

Update to 4.3.7.10, please?

https://www.ghielectronics.com/support/netmf/sdk/37/ghi-electronics-netmf-sdk-2015-r1-pre-release-4

plus, you really need to let the ProgramStarted complete before trying to send messages. Start a timer or thread with a sleep at the start, and send from that. The Gadgeteer framework really needs to have completed its initialisation before you try to use modules.

Hello all, Thanks a lot for your answers

@ Dat - Should i really update to a so recent version? it scares me also the fact that is a PRE-RELEASE and it has BIG, RED, SCARY letters saying:

[quote]This SDK is unsupported pre-release software and represents potentially unfinished and untested functionality that may be altered or removed in a future release. It is not recommend for use in a production environment. Use at your own risk.[/quote] :smiley: :smiley: :smiley:

@ Brett - I already tried that, in fact thats how i started, i literally made a timer to 1000 ms, and then in the tick the message creation and transmission, the results were the same; the code i posted was the simplest i could come up with in order to make it easy to understand and read in the forum, thats why youi can find some commented directives in the code :slight_smile:

@ Mike - Thanks for your answer

yes, you are right, in this case the can object goes out of scope, but i did this as a simple way to show my code, normally i use the can object from Candw.can, which is defined for the entire class.

about the cabling, i simply used a standard serial 1-1 cable with both ends in female, as i mentioned, i tested it between 2 analizers and there was no issue at all,

@ Ingcuervo - I do not work with CAN networks. But, i believe a terminator is needed on a network.

1 Like

@ Mike - Hello,

Yes you are right, i actually came here to say that i found the problem… and it is somehow related to this.

when i purchased the modules, i trusted the page where it says:

but today checking the schematic… realized that the jumper WASNT INSTALLED IN ANY OF MY MODULES… hence… none of the resistors was activated!

i have to say that this really sucks, because i made the bridge and everything works… but if you cannot trust the information that is released by the manufacturer… then… what?

is there a way to report this issue? i bought the modules trhough Mouser.de

I was just going to say that the schematic is correct as it shows the link open.

Since there should only be one terminator on the network, no jumpers is the logical default. You have to activate the terminator at the end of the network.

1 Like

@ Sprigo - hey, yep it shows it open, thats why i realized, but in the page it says that the resistor is included, but you can deactivate it :S

anyway thanks to everybody, and im gonna post my code here in order to help any other unfortunate to start :slight_smile:

used canDW module and cerberus board (updated the firmware to the pre-release as suggested in the beginning); the finall setup is 2 cerberus boards with usbDP as powersource and CANDW (rememeber to verify the resistors!) module; a simple 1-1 (NOT CROSSED) serial cable (db9 connectors) with both ends in female, and framework 4.3

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using GHI.IO;
namespace NEwCanAttempt
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.  
        GT.Timer tempo; 
        void ProgramStarted()
        {
            tempo = new GT.Timer(1000);
            tempo.Tick += tempo_Tick;
   
            canDW.Initialize(ControllerAreaNetwork.Speed.Kbps125);
            canDW.ErrorReceived += canDW_ErrorReceived;
            canDW.MessagesReceived += canDW_MessagesReceived;
            canDW.Can.Enabled = true;
            canDW.MessagesSent += canDW_MessagesSent;
            canDW.Reset();
            Debug.Print("Program Started");
            tempo.Start();
        }

        void canDW_MessagesSent(CANDW sender, EventArgs e)
        {
            Debug.Print("successfully sent");
        }

        void tempo_Tick(GT.Timer timer)
        {
   
            canDW.SendMessage(new ControllerAreaNetwork.Message() { Data = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, ArbitrationId = 0x12345678, Length = 8, IsRemoteTransmissionRequest = false, IsExtendedId = true });

            Debug.Print("theoretically sent");
        }

        void canDW_MessagesReceived(CANDW sender, CANDW.MessagesReceivedEventArgs e)
        {
            Debug.Print("Message receivedCanDW: ");
        }

        void canDW_ErrorReceived(CANDW sender, CANDW.ErrorReceivedEventArgs e)
        {
            Debug.Print("Error CanDW: " + e.Error.ToString());
        }
    }
}

[quote]@ Dat - Should i really update to a so recent version? it scares me also the fact that is a PRE-RELEASE and it has BIG, RED, SCARY letters saying:

It’s up to you, but a version come later is usually always better then the previous one.
And, we don’t scare you, never!

:smiley:

1 Like

@ Mike - i dont mind they have no activated resistors, but I really mind that they say otherwise in the page :slight_smile:

@ Ingcuervo - Sorry for the confusion, the catalog entry has been updated to reflect the fact that we no longer populate it.

1 Like