Feature request - payload size calculation
dsabala opened this issue · comments
Hi
Although this is not a key feature, it would be nice to be able to calculate how much memory space should be allocated before encoding the frame. Currently, only the maximum possible area is known and you have to allocate whole <name>_REQUIRED_BYTES_FOR_ACN_ENCODING
before you call encode function.
Best regards
Thank you for your suggestion. However, the memory requirement for encoding a message is inherently dependent on the specific message content. For instance, when encoding a message like
MyArray ::= SEQUENCE (SIZE(0 .. 1024) OF INTEGER(0..255)
the exact memory needed can't be determined beforehand, only the maximum size can be precalculated. This design choice aligns with ASN1SCC's focus on embedded systems, ensuring predictable memory usage by precalculating the maximum encoding buffer size at compile time for each ASN.1 message.