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

core: add mavlink statustexts as debug printfs #119

Merged
merged 1 commit into from
Oct 23, 2017

Conversation

julianoes
Copy link
Collaborator

@julianoes julianoes commented Oct 16, 2017

By printing all mavlink statustexts we should get a bit more context
when something goes wrong on the firmware side.

@bkueng do you have a better suggestion how to make sure the statustext.text string is null terminated

mavlink_statustext_t statustext;
mavlink_msg_statustext_decode(&message, &statustext);

std::string debug_str = "mavlink ";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this enough to differentiate device as opposed to DroneCore originated warnings? Maybe text:
MAVLink: emergency or Device: emergency.
Might even be worth having a special class of debug for these. Just a thought.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed @hamishwillee, it would be good to understand when are these called and if we should be raising exceptions or alerting the users rather than just using them for debugging.

That said this PR is to have more debugging data, so we should merge and get someone to research onto what the messages mean, I want to know if we should be taking more critical actions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hamishwillee I can change it to MAVLink: emergency.

@mrpollo to catch errors, it might make sense that the plugins check for errors and inform the API user if it is relevant.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mrpollo That said this PR is to have more debugging data, so we should merge and get someone to research onto what the messages mean, I want to know if we should be taking more critical actions

@mrpollo to catch errors, it might make sense that the plugins check for errors and inform the API user if it is relevant.

@hamishwillee I can change it to MAVLink: emergency.

Agree with all above - yes, ideally plugins should check for errors and work out what is relevant but we need to do more research on this. IMO we should do change suggested (MAVLink: xxxx) for now, accept PR, and raise issue to look at errors as a separate task.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, merge whenever. I have created #127 to add eventual task to look at these messages.

mavlink_statustext_t statustext;
mavlink_msg_statustext_decode(&message, &statustext);

std::string debug_str = "mavlink ";
Copy link
Member

Choose a reason for hiding this comment

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

Agreed @hamishwillee, it would be good to understand when are these called and if we should be raising exceptions or alerting the users rather than just using them for debugging.

That said this PR is to have more debugging data, so we should merge and get someone to research onto what the messages mean, I want to know if we should be taking more critical actions

// statustext.text is not null terminated, therefore we copy it first to
// an array big enough that is zeroed.
char text_with_null[sizeof(statustext.text) + 1] {};
memcpy(text_with_null, statustext.text, sizeof(statustext.text));
Copy link
Member

Choose a reason for hiding this comment

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

dirty indeed, but I don't see any other way around this if we can't control the input, and now that I think about it, can this lead to memory leaks? can someone use this to DOS an app using DroneCore by crafting big malicious messages?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think all that a malicious drone can do here is to print a bunch of memory that follows after statustext.text until 0 appears.

Copy link
Member

Choose a reason for hiding this comment

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

In conclusion, yes we make ourselves open to a crafty mavlink attack, but I'm sure this isn't the only place where this occurs

@julianoes
Copy link
Collaborator Author

So, does anyone feel like this can be approved and be merged now? 😄

@coveralls
Copy link

Coverage Status

Coverage remained the same at 48.37% when pulling dcf20b6 on add-mavlink-statustexts into ce714f5 on develop.

@mrpollo
Copy link
Member

mrpollo commented Oct 21, 2017

@julianoes ready be to merged as soon as you rebase

By printing all mavlink statustexts we should get a bit more context
when something goes wrong on the firmware side.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 48.634% when pulling 09fc6f2 on add-mavlink-statustexts into bf80f02 on develop.

@mrpollo mrpollo merged commit 8df5d52 into develop Oct 23, 2017
@mrpollo mrpollo deleted the add-mavlink-statustexts branch October 23, 2017 14:56
@hamishwillee
Copy link
Collaborator

When do we plan to merge all this stuff into master. I don't want to document stuff that isn't merged, since currently people build off master.

@julianoes
Copy link
Collaborator Author

julianoes commented Oct 24, 2017

When do we plan to merge all this stuff into master. I don't want to document stuff that isn't merged, since currently people build off master.

I think the docs need to reference to a version. I thought you could do that?
Best case would be something like what readthedocs has.

@hamishwillee
Copy link
Collaborator

We can do versions using this plugin. I have not tried it because none of the other projects wanted real versioning.

I guess I could try creating a develop branch and merge in docs that way. I'll look into that today.

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.

4 participants