Hello folks,
I have an AST-CAN485 Dev Board and I want to use it to read CAN messages from a CAN bus. I used a FTDI board to load up the CAN Receiver example from the AST_CAN_Arduino_Library:
https://github.com/Atlantis-Specialist- … N_Receiver
I didn’t connect the board to a CAN bus, I just wanted to check, if the program is running correctly. But it didn’t.
I used some print outs to see, where the problem lies and figured out, that the while loop in line 45 doesn’t terminate. The can_get_status() function gives back CAN_STATUS_NOT_COMPLETED everytime. I looked into the source code of this function and I think the problem is, that the function can_get_mob_status() returns MOB_NOT_COMPLETED (see line 301 in https://github.com/Atlantis-Specialist- … /can_lib.c). After that I couldn’t find out more. I looked in the function code of can_get_mob_status() and it seems, that MOb is enabled but does not complete but I can’t figure out, why that is the case.
I would be glad if you have a solution for that and I’m looking forward to your responds.
Grettings, Jonathan
What happens if you connect to a working CAN bus that’s sending data?
It also didn’t work. But I allready figured out what the problem was. In my hurry I forgot to change the Bautrate in the code to the Baudrate on the CAN bus. Now everything is working correctly.
But thank you for your quick reply and sorry for the inconvenience.
No worries, glad you got it figured out!
I encountered a new problem with the CAN library for the AST-CAN485 board. I want the program to loop, even if no message is sent on the CAN Bus.
Lets say, I want the example program for a CAN receiver to loop even if there is no message on the CAN Bus. This is the example code I’m refering to:
https://github.com/Atlantis-Specialist- … ceiver.ino
If I just run the code like this, the while loop in line 45 loops until there is a message on the CAN Bus, then the message is printed and the code stops again at line 45 until the next message can be read. Now I change the code in line 45 to:
int i = 0;
while (can_get_status(&Msg) == CAN_STATUS_NOT_COMPLETED && i < 1000){
i++;
delay(1);
}
In my imagination the program will check the CAN Bus 1 second for messages and if it can’t receive one, the while loop terminates because i = = 100, but it doesn’t. Actualy it doesn’t even receive a message, if there is one on the CAN Bus. Through print outs I figured out, that the while loop just loops until i == 100 even if there is a message on the CAN Bus and that the main loop just loops 16 times. in the 16th loop, the while loop in line 43 doesn’t terminate anymore.
So my question is, how can I make it, so that I can listen on the CAN Bus every loop, but also do other stuff with the program if I don’t receive a message?