Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve mavlink inspector #2337

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/frontend/src/utils/mavlink_prettifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const formatters = {
PARAM_VALUE(message: M2R.ParamValue) {
return `${message.param_id.join('')}: ${message.param_value}`
},
SCALED_PRESSURE(message: M2R.ScaledPressure) {
return `${message.press_abs?.toFixed(2)}hPa at ${message.temperature / 100}c`
},
STATUSTEXT(message: M2R.Statustext): string {
return `${message.severity.type.replace('MAV_SEVERITY_', '')}: ${message.text.join('')}`
},
Expand All @@ -72,5 +75,13 @@ export default function prettify(message: Message): string {
if (message_type in formatters) {
return `${message_type} - ${formatters[message_type](message)}`
}

// There is no function that matches exactly the message
// Lets check if it's an enumeration of it
const function_name = Object.keys(formatters).filter((key) => new RegExp(`^${key}\\d+$`).test(message_type))?.first()
if (function_name) {
return `${message_type} - ${formatters[function_name](message)}`
}

return message_type
}
Loading