CAN Bus shield doesn't read message

Hello guys,

I'm trying to use a can bus shield to read messages from my car.

The shield is the Seedstudio's model (but I didn't buy it, i made it following the shield schematic and all the components of the Seedstudio), it works correctly when I want to send messages on the bus and it workED fine when trying to read them from the bus.

The problem is that for the second time since I started the project the module stopped working: the program/Arduino (which doesn't shows error messages) runs and initializes the bus correctly but after the initialization the module doesn't find any message on the bus (serial monitor output: "no msg on the bus").

What i checked is:

  1. 120 ohm resistor at the end of the bus;
  2. set the baudrate at the same baudrate of the bus;
  3. the delays i set in the preogram (I thought that maybe they could give prolem in synchronization);
  4. the conditions of the mcps (I also changed them with brand new ones);

Yesterday it worked correctly, so I really don't know what the error could be, maybe there is some bad administration of the control registers? It looks like the RX buffers aren't able to store the message...

If you have any suggestion I'm open to every idea, I attach the sketch of the receiving program.

Thank you

#include <SPI.h>
#include <mcp_can.h>

//Seleziono il pin 6 per lasciare liberi i pin 9 e 10 per l'SPI dell'NRF24

const int CAN_CS_PIN = 9; 

//Creo un'istanza della classe MCP_CAN

MCP_CAN CAN(CAN_CS_PIN);

uint8_t data[8];
float valore1, valore2, valore3;
uint8_t len = sizeof(data);
uint8_t dataLen = 0;
uint32_t referenceID = 0x250;
uint32_t canID;


void setup() 
{
  //Inizializzazione della porta seriale. Necessaria solo per lettura del dato da monitor seriale
  
  Serial.begin(115200);

  //Initialize CAN bus  

  while(CAN_OK != CAN.begin(CAN_500KBPS))
   {
     Serial.println("Inizializzazione CAN bus fallita");
     Serial.println("Nuovo tentativo");
     delay(10);
   }
  
  Serial.println("Can initialized");
}

void canRead()
{
  /*
   * Il metodo  descritto si articola in tre punti:
   * 1. Verifica che vi sia un messaggio presente sulla linea CAN; se negativo ritorna;
   * 2. Verifica che l'ID del messaggio CAN sulla linea coincide con quello da cui voglio ricevere;
   * 3. Se affermativo, riceve il messaggio e lo mostra a terminale;
   */

  if(CAN_MSGAVAIL == CAN.checkReceive())
  {
    /*
     * Nota: la lettura dell'ID non può avvenire prima che il dato venga letto, altrimenti 
     * non vi è lettura effettiva e il confronto degli ID ritorna errore;
     */
    
    CAN.readMsgBuf(&dataLen, data);
    canID = CAN.getCanId();
    
    if(canID == referenceID)
    {
      Serial.println("________________________");
      Serial.print("data from ID: ");
      Serial.println(canID, HEX);

      /*
       * Stampa a video del messaggio; dato che dalla linea CAN della macchina
       * un valore viene espresso tramide due byte, nella ricezione è necessario
       * ricomporre tale valore;
       */

      int i = 0;

      while(i < dataLen)
      {
        /* 
         *  Il valore con l'offset più basso è il byte più significativo fra i due;
         */     

        valore1 = data[i]*256;

        i++;

        valore2 = valore1 + data[i];

        valore3 = valore2/10;

        Serial.print(valore3);
        Serial.print("\t");

        i++;
      }

      Serial.println();

      /*for (int i = 0; i < len; i++)
      {
        Serial.print(data[i]);
        Serial.print("\t");
      }

      Serial.println();*/
    }

    else
      Serial.println("No ID matches the referenceID");
    
  }

  else 
    Serial.println("No msg on the bus");
}

void loop()
{
  canRead();

  delay(100);
}