You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a protocol definition where each frame consists of 64 bytes, with the first byte fixed at 0xAA and the last byte fixed at 0x55. The initial byte represents the frame ID, and depending on the frame ID, different data is included. Specifically, when the frame ID is 0x01, the data included is considered global, meaning that subsequent frames should also include the data associated with frame ID 0x01 during parsing. However, I am uncertain about how to include the data associated with frame ID 0x01 when parsing other data frames. The appearance of 0x01 is not fixed; it may occur at the beginning or in the middle of the file. I have been trying to address this for a while without success.
Below is my KSY file. Could you please advise on how to handle this situation or if it's possible to implement this functionality?
Specifically, when the frame ID is 0x01, the data included is considered global, meaning that subsequent frames should also include the data associated with frame ID 0x01 during parsing.
If the "global data" from the frame with ID 0x01 doesn't affect parsing decisions in subsequent frames, then the easiest way would be to handle this in your application code.
If you want to do this in Kaitai Struct, you can achieve this using a parameter that transfers the last seen "global data" from one frame to the next one:
This technique works when the number of things you need to keep track of is static, i.e. known at the time of authoring the .ksy spec. For the general case, #172 would need to be implemented, but this trick is sufficient in many cases.
Thank you for your response. Using this approach does indeed address my issue. However, when there is more than one global data ID, where should I split them? For example, if there are 10 global data IDs from 0x01 to 0x0a, how can I implement this based on the above method? Different global data IDs represent different amounts of data, so at which level should I handle the processing of these data? Kindly guide me on this. Thank you.
I have a protocol definition where each frame consists of 64 bytes, with the first byte fixed at 0xAA and the last byte fixed at 0x55. The initial byte represents the frame ID, and depending on the frame ID, different data is included. Specifically, when the frame ID is 0x01, the data included is considered global, meaning that subsequent frames should also include the data associated with frame ID 0x01 during parsing. However, I am uncertain about how to include the data associated with frame ID 0x01 when parsing other data frames. The appearance of 0x01 is not fixed; it may occur at the beginning or in the middle of the file. I have been trying to address this for a while without success.
Below is my KSY file. Could you please advise on how to handle this situation or if it's possible to implement this functionality?
I appreciate your assistance in advance.
Best regards,
The text was updated successfully, but these errors were encountered: