Yes to all of that.
I have messages coming from another system, ultimately I need to serialize them and send to another system. This is fine, except that I need to process and store all the incoming components before I can encode a large outgoing message.
So I need to store objects with data lengths of 3, 5, 200, 1000, etc. This gives me a problem with how large the messagebuffer will need to be, but I can handle that.
The issue is I don’t think it’s entirely correct to just put a data structure at the end of my object and just tell the messagebuffer_send to truncate it after as many bytes as I know will exist.
Even if I’m packing the structure, it seems questionable because it only works with the array at the end. If I had two arrays in my structure and wanted the smallest representation of both, that’s clearly not going to work.
So what is the right thing to do? Include pointers and lengths to some more-static bytes somewhere? Send the actual data as a separate entry following the object entry? I must be missing something because this seems like a common issue with variable length data in C and FreeRTOS.