param_server: add error when params are provided too late #2739
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.



The mavlink parameter protocol uses an index to set/get specific parameters. When all parameters are requested, the total count is sent out, together with all the parameters.
Now once this overall count has been sent out, we can't add/provide more parameters on the server side. Until now, MAVSDK didn't care, but with this commit, we are adding a new error to signal that we can no longer change the param list.
This implementation has a bit of a race condition unfortunately: if a request list message is received right in the beginning when all parameters are added, we lock the list too early. The correct fix for this would be a specific method to "end param provisions" and lock them down. However, requiring such a method would be a breaking change, so I'm not adding this now but I'm considering it for the next major version of MAVSDK.
Alternative to #2085.
Requires mavlink/MAVSDK-Proto#388 to be merged first.