Config serialization eror handling and adding serialized data length #406
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I mainly went to add the serialized data length, but thought I'd fix some error handling when touching that part. I can split it off if needed.
The error handling motivation is primarily for the
vesc_tool --xmlConfToCode ...to fail on errors. Right now it will generate the files even if there are errors and the user will likely not notice in the build output, meaning they find out after some time wasted investigating why the code doesn't work.Regarding the serialized data length: I changed my package config storing to EEPROM to use the confparser serialization to save space. It works well (and saves over 40%), the only hurdle is there is no information about the size of the buffer needed, and with the current API it's not possible to check if the buffer is long enough. On write, I can recognize it after the fact (random memory was overwritten, very bad), on read I can't tell at all.
I thought it'd be easy to add the size (so that I can allocate the exact size for the buffer), but there are variable length strings in the config. AFAIK these are not supported in Custom Config, so that's one thing. The strings have the
maxLengthattribute, I used it, but looking at how it's handled, it seems it can be 0 too. I haven't entirely found if and when exactly themaxLengthis enforced, and what's the situation when it's 0. Any advice, what do you think?