Main Site Documentation

EMX CAN RXOver issues


#1

Hi,

I have several CAN devices which sends 100hz messages each, I need to connect 8 of these modules into an EMX board, when I connect 4-5 of them I am able to receive their messages without any error but when I connect all 8 of them I keep getting RXOver error

How can I avoid this error? I tried to increase the size of the RX messages list without any help, please advise.

Liran


#2

You need to enable filters for the messages you need.

Welcome to the community.


#3

Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the

 tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)

#4

Sorry about the previous reply, hit that button by mistake

  1. I have only my devices connected, and I want to receive all their messages
  2. I did setup filter using
SetExplicitFilters(new uint[] { 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108 }); 

My complete CAN object code is below:

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.Hardware;

namespace CANTest
{
    public delegate void CANBusDataReceivedREvent(object sender, ref CAN.Message[] msg);

    public class CCANBus
    {
        private uint m_counter = 0;
        private CAN.Message[] m_MsgList;
        private CAN.Message[] m_TXMsg;
        private CAN m_CAN;
        public CANBusDataReceivedREvent DataReceivedEvent = null;

        public CCANBus(CAN.Channel Channel, int BRP,int T1,int T2,int MsgCapacity = 100)
        {
            m_MsgList = new CAN.Message[MsgCapacity];
            for (int Index = 0; Index < m_MsgList.Length; Index++)
                m_MsgList[Index] = new CAN.Message();

            m_TXMsg = new CAN.Message[1];
            m_TXMsg[0] = new CAN.Message();

            m_CAN = new CAN(Channel, (uint)(((T2 - 1) << 20) | ((T1 - 1) << 16) | ((BRP - 1) << 0)));
            m_CAN.SetExplicitFilters(new uint[] { 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108 }); 
            
            m_CAN.ErrorReceivedEvent += new CANErrorReceivedEventHandler(HandleErrorReceivedEvent);
            m_CAN.DataReceivedEvent += new CANDataReceivedEventHandler(HandleDataReceivedEvent);
        }

        ~CCANBus()
        {
            if (m_CAN != null)
            {
                m_CAN.Dispose();
                m_CAN = null;
            }
        }

        public void SendData(uint ID,byte D0,byte D1,byte D2,byte D3,byte D4,byte D5,byte D6,byte D7)
        {
            m_TXMsg[0].ArbID = ID;
            m_TXMsg[0].Data[0] = D0;
            m_TXMsg[0].Data[1] = D1;
            m_TXMsg[0].Data[2] = D2;
            m_TXMsg[0].Data[3] = D3;
            m_TXMsg[0].Data[4] = D4;
            m_TXMsg[0].Data[5] = D5;
            m_TXMsg[0].Data[6] = D6;
            m_TXMsg[0].Data[7] = D7;
            m_TXMsg[0].IsEID = false;
            m_TXMsg[0].IsRTR = false;
            m_TXMsg[0].DLC = 8;
            m_TXMsg[0].TimeStamp = DateTime.Now;
            bool SentOk = (m_CAN.PostMessages(m_TXMsg, 0, 1) == 1);
        }

        private void HandleDataReceivedEvent(CAN sender, CANDataReceivedEventArgs args)
        {
            int NumberOfMsgs = sender.GetMessages(m_MsgList, 0, sender.ReceivedMessagesCount);
            m_counter += (uint)NumberOfMsgs;
            if (DataReceivedEvent != null)
                DataReceivedEvent(this, ref m_MsgList);
        }

        private void HandleErrorReceivedEvent(CAN sender, CANErrorReceivedEventArgs args)
        {
            //Debug.Print(">>> Error <<<");

            switch (args.Error)
            {
                case CAN.Error.Overrun:
                    //Debug.Print("Overrun error. Message lost");
                    break;

                case CAN.Error.RXOver:
                    //Debug.Print("RXOver error. Internal buffer is full. Message lost");
                    break;

                case CAN.Error.BusOff:
                    //Debug.Print("BusOff error. Reset CAN controller.");
                    sender.Reset();
                    break;
            }
        }
    }
}

#5

@ Gus - can you please take a look at the code, it includes the setup of filters like you suggested but still no help, I still get the error events