Hi, I am using G400D CAN1 to decode some CAN bus data. The program works fine but occasionally, I got an exception when enable the CAN device.
The exception looks like:
Exception System.Exception - 0xffffffff (1)
Message:
GHI.IO.ControllerAreaNetwork::NativeEnable [IP: 0000]
GHI.IO.ControllerAreaNetwork::set_Enabled [IP: 0021]
RadarDataProcessor.RadarDataDecoder::Run [IP: 0035]
RadarDataProcessor.RadarDataProcessorApp::Main [IP: 0018]
A first chance exception of type ‘System.Exception’ occurred in GHI.Hardware.dll
In my RadarDataDecoder program, the code is:
canDevice = new ControllerAreaNetwork (ControllerAreaNetwork.Channel.One, ControllerAreaNetwork.Speed.Kbps500);
if (canDevice == null)
{
Debug.Print ("CAN 1 device cannot be initialized!");
return;
}
// hook up handlers
try
{
canDevice.Enabled = true;
}
catch (System.Exception e)
{
Debug.Print ("CAN enable error : " + e.Message);
return;
}
canDevice.MessageAvailable += OnCanDataReceived;
canDevice.ErrorReceived += OnCanErrorReceived;
I got the exception at canDevice.Enabled = true at about 50% chance every time I run the program. My G400D tinyloader and firmware are both 4.3.6 versions.
And then the CAN device works, I can receive all the data I want, but I will also receive the CAN error ErrorPassive from time to time. Any suggestion that I can get rid of this can error?
Thanks a lot.