Skip to content

Conversation

@pv42
Copy link
Contributor

@pv42 pv42 commented Nov 28, 2025

MAV_CMD should get better support that the current method of manually having to fill the paramters fields. This adds the XML parsing part and used it for documentation but can later be used for codegen too.
Also simplify the XML parsing by treating self closing tags as an start and end tag, the self closing tag handling had just copied code anyways. This should also avoid some bugs like #393.

Example of new doc:
grafik

pv42 added 3 commits November 28, 2025 03:50
Adds parsing for params into the MavProfile data structure.
Add a table of paramters to all MAV_CMD variants including description, valid values and unit.
Change xml parser to use expand_empty_elements=true, this removed a lot of duplicate code and prevents a some of potential bugs.
Copy link
Collaborator

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A snapshot test coverage would be nice.

Comment on lines +784 to +801
match (self.min_value, self.max_value, self.increment) {
(Some(min), Some(max), Some(inc)) => {
if min + inc == max {
format!("{min}, {max}")
} else if min + 2. * inc == max {
format!("{}, {}, {}", min, min + inc, max)
} else {
format!("{}, {}, .. , {}", min, min + inc, max)
}
}
(Some(min), Some(max), None) => format!("{min} .. {max}"),
(Some(min), None, Some(inc)) => format!("{}, {}, .. ", min, min + inc),
(Some(min), None, None) => format!("≥ {min}"),
(None, Some(max), Some(inc)) => format!(".. , {}, {}", max - inc, max),
(None, Some(max), None) => format!("≤ {max}"),
(None, None, Some(inc)) => format!("Multiples of {inc}"),
(None, None, _) => String::new(),
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very hard to follow and debug. Also, moving lines would change the behavior significantly (which is dangerous). Can we somehow re-write this in a better and safer way?

}
params[param_index - 1] = MavParam {
index: param_index,
description: param_description.unwrap_or_default(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not making description Option<String as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants