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
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]