Hi all,
Can anyone help?
I am using the CAN_Ex1 Example for the STM107 (for MCBSTM32C Target Board) chip however any similar CAN programs may help, Where does all the CAN Id's be read by the Microcontroller to establish if a message has the correct ID for the node?
I am trying to create a program that at this initial point if a CAN message does not have the correct ID for the node it is simply echoed (or Re-transmitted) unchanged on another CAN port (CAN2). Does anyone know how this could be carried out?
Any help or info is greatly appreciated
S
If you are going to forward all ID:s not specifically handled, then you can obviously not use a CAN controller configured for hardware filtering.
So then you have to write your own code to possibly make use if a switch statement to separate the ID:s you support and have the default action forward the rest of the frames.
Or, if your chip supports it, you might be able to use FullCAN filtering of "your" frames and have the remaining frames be accepted separately - so messages sent to individual "mailboxes" are for your program, and the other messages are for forwarding.
Thank you for your reply.
I was thinking of using a simple if statement for each of the small number of ID's I want to manipulate and just forward all other ID's and information, however I am not sure where the initial filtering is carried out on the Arm to allow me to use for the statement.
"Thank you for your reply.
I was thinking of using a simple if statement for each of the small number of ID's I want to manipulate and just forward all other ID's and information, however I am not sure where the initial filtering is carried out on the Arm to allow me to use for the statement."
Or to allow me to do the forwarding I should say.
If you don't turn on any filtering, then you don't need to worry about any filtering. You just check the ID of the received frames.
Why use "if" when the language have "switch"?
No reason I was just thinking of using only one desired command initially and its the first thing that came to my head. I will most likely use a switch statement in the end.
I wonder are the rejected ID's traditioinally moved to a register after filtering before they are dumped/Ignored?...
...if so I could relay the contents of such a register via the second CAN port. The program will be dealing with a very large number of commands that will have to be forwarded without editing, and only a small few will be required for manipulation 2 or 3 different ID's really.
In this case, you can't reject any frames since frames should either be locally processed or forwarded to your second CAN interface.
Some CAN controllers can perform filtering of specific IDs to specific "mailboxes" and then either throw away all other frames or report them all to normal ISR or perform separate filtering before potentially report them to normal ISR.
If the majority of frames should be echoed, then you don't have much choice but picking them up from first interface and dropping them on second interface. And the main issue is how much time your processor needs to figure out if received frame is one of "your" frames or one that should be forwarded.
If you need to listen to a few number of IDs, then multiple if statements or a switch statement will manage well. If the list of IDs you should process locally is huge, then you may need to look into using bitmaps or similar hashing solutions to be able to quickly figure out if the received frame is one of the few intended for you, or one of the huge number intended to be forwarded.
Thanks for you help!
Is there a type of mask that can be used initially for the hardware controller to initially pass all commands to allow them through to the software?
I know this will take a large amount of CPU processing time, but I am not concerned about this initially, if I can get it to work any way to start of and then make the software more efficient at that stage... I just need everything to pass initiailly, I can't seem to disable filtering all together at this stage or at least haven't yet discovered how, and I don't want to have to ask the software to search for each ID seperately as I won't know all the specified ID's I wish to forward.
I just know what I want to keep and want to forward eveything else. Which I can do if I can get all messages through to the software somewhere.
Anyone any ideas...?