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?