1

Topic: Timing when setting values of one frame based on a value in another

When implementing a CAN gateway, is there a good method or general "best practice" for setting a value in one CAN data frame based on a value in a different frame, when those two frames are sent at different intervals?


Here's a simplified example to demonstrate what I mean:

A data frame (CAN ID 001) is sent through the gateway at an interval of once per second.
A different frame (CAN ID 005) is sent through the gateway once every 5 seconds.
(The CAN IDs  aren't real, I just made them to correspond to the intervals)


When a bit is set to 1 on frame 001, I want to set a bit in 005 to 1.
What's the best way to implement this?


When the 001 frame comes through the gateway I could do the following:
Option 1: Generate a new 005 data frame - It seems like this would not be ideal, because I don't know what the other values in that frame should be.  I could set them all to 0, but that seems like a bad idea.

Option 2: Constantly store the most recent values that come through in the 005 frames, so that if I need to generate a new frame then I have the data I need to populate it.  This seems like it would work, but might be a lot of overhead to constantly read and store those values.

Option 3: When the bit is set or unset on the 001 frame, set a flag that enables or disables the rewrite rule on the 005 frame.  It seems like this would be the best and cleanest option.


Am I on the right track with this?  Or is there a better way that I'm missing?

2

Re: Timing when setting values of one frame based on a value in another

As for me, Option 2 & Option 3 sounds great.
For such long sending intervals, the overhead can be neglected. Moreover, CAN gateway driver running asynchronously to the diagram. So I personally prefer Option 2 as a clearer solution - no need to disturb the CAN GW driver for nothing.

3

Re: Timing when setting values of one frame based on a value in another

Thanks Konstantin. Can you tell me more about what you mean when you say the CAN gateway runs asynchronously to the diagram?

I guess the main problem I'm having is that I am unclear about when a message is processed in the diagram and when it isn't.

Is it possible to have the message sent through from CAN0 to CAN1 unmodified, but still use the diagram to inspect (but not change) the data in the message?

4

Re: Timing when setting values of one frame based on a value in another

You are welcome!
Then CAN GW is enabled, the messages selection / altering / modifying / retransmission is performed by it asynchronously, at the moment when the message arrived, regardless of the current diagram step.

By default, the diagram receives via CAN-driver's registers each message that was caught by any active CAN GW selector . But you can disable this through the CAN GW driver's Tracing mode registers.
Please: https://cannylogic.com/docs/c72duo/cang … on_diagram