Need help debuging, sketch stopps at: if(Canbus.init(CANSPEED_500))

Hi All,

I'm new to programming. I had some issues with installing libraries and the forum helped me solve them. (THANK YOU!)

I'm now successfully compiling the example sketch and I need help debugging it.

I've attached the full .ino file.

I've also attached a screen shot of the IDE and serial monitor side by side to show where I think I'm running into the first issue. I think the sketch is hanging in this section of the code: (see screenshot)

clear_lcd();
  
  Serial.println("CAN Init test");
  if(Canbus.init(CANSPEED_500))  /* Initialise MCP2515 CAN controller at the specified speed */
  {
    
    sLCD.print("CAN Init ok");
    Serial.println("CAN Init OK");
  } else
  {
    sLCD.print("Can't init CAN");
    Serial.println("Can't init CAN");
  } 
   
  delay(1000); 

}

As far as I can teel, the next action would be for the "if(Canbus.init(CANSPEED_500))" to return either a yes/no.. true/false or something to that effect and either display one of the two following responses:

CAN Init OK.... Serial.println("CAN Init OK");
Can' init CAN... Serial.println("Can't init CAN");

Am I missing something?

Thanks for the help.

ecu_reader_logger.ino (15.5 KB)

Sorry, I forgot to add the screenshot referenced in the original post.

Seems that it is not returning from Canbus.init(). I suggest you look at the source for that library to see what circumstances could cause that. You're at liberty to add Serial.print statements to the library if necessary to find out what it happening inside it. You may also find it already has debug capabilities that just need to be enabled.

You're at liberty to add Serial.print statements to the library if necessary to find out what it happening inside it.

You know, I don't know why that hadn't occurred to me.Thank you! I'd already been adding the serial.print statements to the sketch. That's how I got this far.

I'll do some more debugging and get back to the post asap.