Arduino (Teensy) CAN Bus Reader, Filter, Read Specific ID for Response from Write command

Looking to get more understanding of the overall logic behind a program.

I am building a CAN bus communication device to be able to communicate with my vehicle.

I have done several readers ect but this new one is a little more advanced and needs to filter CAN data.

Steps: 1) Read serial integer input. IF #1 do routine, IF #2 do a second routine ect.
Step: 2) Inside IF statement for serial input, write the first CAN message to start said routine.

I have made it this far no problem. But now I need to understand how to read the CAN bus for the specific response right after I send the start routine command.

Ex: I send ID: 0x0750 Data: 00 00 00 00 00 00 00 00
Get response ID: 0x0758 Data:11 11 11 11 11 11 11 11

After sending a message, I need to look for, and print, the response (data in ID 0x0758) as fast as I can.

My issue as I understand is CAN is FIFO and basically you need to continually be reading the entire bus row by row in a loop. Not sure if trying to read the Bus inside my integer IF statement is a good idea or if the read has to be part of the main loop always running with no delays ect.

I have been reading about CAN Mailboxs but am not sure if this technique is best.

Basically looking for a way to say Read the CAN Bus as this specific ID only, right after I write a message to it.

Any thoughts, advice, to help me understand the best logic for doing this?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.