Real Dash CAN protocol extension

Greetings. In the RDCAN protocol, it is possible to send 8 bytes of information in one frame from arduino to RD. But it is not possible to automatically determine from which frame these 8 bytes are received …
I am tormented by the question of how can I send to the RD, id can of the frame along with the payload? Is it possible to add such a function?

See our Arduino examples which build the entire frame including the 8 byte payload:

https://github.com/janimm/RealDash-extras

I mean that every frame should be assembled, defined and described in XML from the very beginning. ReaDash is not able to automatically determine the ID of any frame. Thus, only previously known frames can be sent. A full set of can-tire cars. How it is done in Can-Analyzer

Yes, you need to build an XML that defines all frames. How else would RealDash know how to interpret the frames.

Yes Yes! Of course. But I do not want to achieve this a bit.
I’m interested in the task of studying the CAN bus
I will ask directly:
Is it possible to write a sketch for arduino so that it monitors the entire CAN bus? to get something like CAN Analyzer does.
I don’t have money to buy an analyzer, I want to make it from arduino …

I don’t think this is possible with only Arduino. You need to integrate a CAN chip (MCP2515 or os) into circuitry.

This chip has been working with my machine for 2 years. This is not a problem.
I am interested in how to implement this at the software level.
I mean the sketch and the XML description file.
In addition, I was able to get data from CAN, on a PC using the Arduino / MCP2515 bundle.
Now I want to get them using RealDash on android

That it would be possible to monitor them directly on my dashboard

Its currently not possible. While you can use CAN analyzers as CAN monitors, the RealDash CAN protocol requires all frames to be pre-defined in XML.

Although, this is an interesting idea, and completely doable. I will add this to feature request list.

Hi Jani,

I have this working beside the packet has lot of overhead for the amount of data sent, I like to see some sort of data validations, may be at least a simple check sum, same as what is used when data is sent from real dash.

May one of bytes check sum. and frame byte size up to 256, but leave default as is today.

Thanks,
Mostafa

No one says that this is a bad protocol and it needs to be changed! It would just not be bad if, Jani teaches RealDash to additionally see the addresses (based on the packages coming from the auto)
That is, a packet appeared on the input buffer, say “0x5DA”. Next, we check to see if this packet had already existed, if there was no packet, then a new section appears, if there was one, then its contents (useful information of 8 bytes) are sent to an existing address recorded in RD … It’s just in words, the main thing is that Jani would manage to implement this)))))

First draft implementation here:
https://www.dropbox.com/sh/z359gvtknxbyush/AACMWapZ32Ma9I9OISaYDSEta?dl=0

Open RealDash CAN connection settings and tap ‘CAN Monitor’ to see all incoming CAN frames. No need to import any XML to use CAN Monitor.

Wow. I am being tested. And unsubscribe

Какой скетч для ардуино использовать?

https://youtu.be/Om6yrSwF6Gk
And so I tested. And it works. But not the entire Kan bus is visible. I think I can’t see the entire bus due to the fact that I limited some data by changing the sketch to arduino for myself.
I think I can use a test sketch with github and then the entire bus will be visible.
Also, if you see this video, then the effect for which I wrote is visible on it, some empty bytes are blocked by those that are changing now. So I turned on the alarm on the car, and we see it everywhere where the zeros are … Why this affect occurs, I don’t know. Maybe because these fields are not filled?

I also want to ask you to make sure that you don’t change the sketch for Arduino every time, if you want to add new frames. Let the sketch for arduino see all the frames. A file. Xml will describe what we need)))
And ideally, of course, it would be nice if you could directly select the data for the sensor directly from the CAN bus directly in RealDash))))

In general, I did some tests with different sketches. And so in the first case a limited number of frames up to 10 is used. And we see them in the can monitor.

But if I try to display all my frames, there are 33 frames in my car, then I can see only one random frame in the channel monitor which is static. In addition, after each connection, this frame is changed, but still one.
I think that this is a problem on the side of RealDash, because the same Arduino board, but with a different sketch and with another program "CanHacker ‘’, quietly skips the entire stream of frames from my car, without any hint of slowdown. .

I suppose that not the ability to display a large number of packets is associated with any internal buffer limitation or overflow … I do not know, but I hope for your help

Its hard to say, but on my tests, the monitor has shown up to 250 frames without any problems. I assume that your Arduino-CAN solution is not sending all the frames for some reason. But for me its impossible to say if that is the problem or not.

I understood. It turns out 250 frames to send without problems. So I’m not doing the right sketch or sending.
Can I ask you then, are you using the MCP2515? Can you give an example of a sketch or fix my sketch?

I will give an example of my working sketch:

#include <mcp_can.h>

#include <SPI.h>

bool GABAR;
unsigned int CAN_ID;
byte Byte_01;
byte Byte_02;
byte Byte_03;
byte Byte_04;
byte Byte_05;
byte Byte_06;
byte Byte_07;
byte Byte_08;
const int SPI_CS_PIN= 9;
const int LED= 8;
boolean ledON= 1;
MCP_CAN CAN(SPI_CS_PIN);
void setup()
{
pinMode(4, INPUT); 
pinMode(5, INPUT); 
pinMode(6, INPUT); 
pinMode(7, INPUT); 
pinMode(2, INPUT); 
pinMode(8, INPUT); 

// init serial
   Serial.begin(115200);
   pinMode(LED,OUTPUT);
   
   while (CAN_OK != CAN.begin(CAN_1000KBPS))
    {
        delay(1);// ожидаем конекта
    }
}
void loop()
{




//Плата:2
    unsigned char len = 0;
    byte buf[8];

    
if(CAN_MSGAVAIL == CAN.checkReceive())            // check if data coming
    {
        CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf
         CAN_ID  = CAN.getCanId();
    Byte_01 = buf[0];
    Byte_02 = buf[1];
    Byte_03 = buf[2];
    Byte_04 = buf[3];
    Byte_05 = buf[4];
    Byte_06 = buf[5];
    Byte_07 = buf[6];
    Byte_08 = buf[7];

    }
  

  SendCANFramesToSerial();
  
}


void SendCANFramesToSerial()
{
  
//Все адреса CAN ID должны быть переведены из HEX в DEC. Например : 0х5DA = 1498,
//а информационные байты остаются как есть! Это нужно для получения правильных
//данных в файле описания.XML

  byte buf[8];

                                  //обороты ДВС 
  if (CAN_ID == 0x186)
  {
  buf[0] = (Byte_01 & 0xff);
  buf[1] = (Byte_02 & 0xff);
  buf[2] = (Byte_06 & 0xff);       //TPS
  buf[3] = (Byte_07 & 0xff);
  SendCANFrameToSerial(390, buf);
  }
  
  
                                  //Скорость АВТО делить на 10 000 Так как
                                  // с машины приходят сантиметры в час
    if (CAN_ID == 0x217)
  {
  buf[0] = (Byte_04 & 0xff);
  buf[1] = (Byte_05 & 0xff);
  buf[2] = (Byte_06 & 0xff);
  SendCANFrameToSerial(535, buf);
  }
                                  //Температура ДВС "-40"
    if (CAN_ID == 0x5DA)
  {
  buf[0] = (Byte_01 & 0xff);
  SendCANFrameToSerial(1498, buf);
  }
                                  //Напряжение батареи "/10"
    if (CAN_ID == 0x4AC)
  {
  buf[0] = (Byte_02 & 0xff);
  SendCANFrameToSerial(1196, buf);
  }
                                    //СВЕТ  
    if (CAN_ID == 0x5DE)
  {
  buf[0] = (Byte_01 & 0xff); //левый поворот
  buf[1] = (Byte_01 & 0xff); //правый поворот
  buf[2] = (Byte_01 & 0xff); //дальний свет
  buf[3] = (Byte_01 & 0xff); //габариты бит 02 
  buf[4] = (Byte_01 & 0xff); //ближний
  //buf[5] = (Byte_01 & 0xff); //аварийка
  buf[6] = (Byte_01 & 0xff); //ПТФ
  buf[7] = (Byte_01 & 0xff); //ЗТФ
  
  SendCANFrameToSerial(1502, buf);
  digitalWrite(LED, (bitRead((buf[3]), (2)))); // еденица на 8м пине при включеных габаритах
  GABAR = (bitRead((buf[3]), (2)));
  }

                                  //Задний ход
    if (CAN_ID == 0x648)
  {
  buf[0] = (Byte_07 & 0xff);
  SendCANFrameToSerial(1608, buf);
  }

                                  //ПРОБЕГ
                                  
    if (CAN_ID == 0x5D7)
  {
  buf[0] = (Byte_03 & 0xff);
  buf[1] = (Byte_04 & 0xff);
  buf[2] = (Byte_05 & 0xff);
  buf[3] = (Byte_06 & 0xff);
  SendCANFrameToSerial(1495, buf);
  }
                                 
                                     //ДВЕРИ  
    if (CAN_ID == 0x5DE)
  {
  buf[0] = (Byte_02 & 0xff); //ВОДИТЕЛЬ 3й бит
  buf[1] = (Byte_02 & 0xff); //ПАССАЖИР 1й бит
  SendCANFrameToSerial(1505, buf);
  }   

                                       //ОБОГРЕВ и СЦЕПЛЕНИЕ 
    if (CAN_ID == 0x5DD)
  {
  buf[0] = (Byte_03 & 0xff); // обогрев 3й бит
  buf[1] = (Byte_03 & 0xff); // сцепление 5й бит
  SendCANFrameToSerial(1501, buf);
  }

 




}
void SendCANFrameToSerial(unsigned long canFrameId, const byte* frameData)
{

  // the 4 byte identifier at the beginning of each CAN frame
  // this is required for RealDash to 'catch-up' on ongoing stream of CAN frames
  const unsigned long serialBlockTag = 0x11223344;
  Serial.write((const byte*)&serialBlockTag, 4);

  //the CAN frame id number
  Serial.write((const byte*)&canFrameId, 4);

  // CAN frame payload
  Serial.write(frameData, 8);

}

This code works