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

bring in class LogListHelper into MavlinkLogHandler #14452

Merged
merged 3 commits into from May 25, 2020

Conversation

BazookaJoe1900
Copy link
Member

@BazookaJoe1900 BazookaJoe1900 commented Mar 22, 2020

this is followup to 'return with error from _log_request_list() in case of failed allocation #14451'

Describe problem solved by this pull request
The class LogListHelper created and destroyed dynamically during logs download process. which mean some new and delete built in in MavlinkLogHandler code. the existence of the class then checked, to decide the state of the downloader.
This PR remove the dynamic allocation. to ensure enough memory on creation of MavlinkLogHandler (meaning, creation of mavlink instance)

Describe your solution
The class LogListHelper removed, all its functions and variants moved into MavlinkLogHandler and created when MavlinkLogHandler allocated.
LOG_HANDLER_STATE::INACTIVE state is the state to indicate that the behavior as if LogListHelper not exists

Describe possible alternatives
question:
now, on every creation of mavlink a MavlinkLogHandler allocated, with an about extra 150 bytes.
most of this memory is _current_log_filename[128].
661d538#diff-e56b8d1bc66526d6f124b0bf662f02fdR105
is that acceptable?
it can be done that only _current_log_filename[] will be malloc dynamically, only if process of download is initiated.

Test data / coverage
tested proper behavior on FMUv5, download speed hasn't been changed and still ~330kBps

Additional context
more improvements can be done to the module. the commits that done keep the exact same behavior. and according to the response about this change, I can do more small/big fix on the process of downloading logs.

@julianoes julianoes requested a review from bkueng March 26, 2020 07:17
@BazookaJoe1900
Copy link
Member Author

@bkueng, can you review?

src/modules/mavlink/mavlink_log_handler.cpp Outdated Show resolved Hide resolved
src/modules/mavlink/mavlink_log_handler.cpp Show resolved Hide resolved
src/modules/mavlink/mavlink_log_handler.cpp Outdated Show resolved Hide resolved
src/modules/mavlink/mavlink_log_handler.cpp Show resolved Hide resolved
@@ -105,15 +65,42 @@ class MavlinkLogHandler
unsigned get_size();

private:
enum class LOG_HANDLER_STATE {
INACTIVE,
Copy link
Member

Choose a reason for hiding this comment

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

Can you clarify the difference between idle and inactive? Maybe use more descriptive names?

Copy link
Member Author

Choose a reason for hiding this comment

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

@bkueng I tried not to change the logic too much, not for now. so INACTIVE is similar to the case that the LogListHelper has not been created.
I added notes, and I know its a bit confusing, but without wider changes I don't want to change it much more.

this is in order to avoid dynamic allocation of LogListHelper when downloading logs.
LOG_HANDLER_STATE::INACTIVE state is the state to indicate that the behavior of LogListHelper not exists
fixed function name _close_and_ulink_files() to _close_and_unlink_files()
@BazookaJoe1900
Copy link
Member Author

@bkueng thanks for the review, I have made changes. and rebased.
can you re-review?

@bkueng bkueng changed the title [WIP] bring in class LogListHelper into MavlinkLogHandler bring in class LogListHelper into MavlinkLogHandler May 14, 2020
Copy link
Member

@bkueng bkueng left a comment

Choose a reason for hiding this comment

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

Thanks, almost good to go.
I assume you tested this?

src/modules/mavlink/mavlink_log_handler.cpp Outdated Show resolved Hide resolved
src/modules/mavlink/mavlink_log_handler.cpp Show resolved Hide resolved
src/modules/mavlink/mavlink_log_handler.h Outdated Show resolved Hide resolved
@BazookaJoe1900
Copy link
Member Author

@bkueng Changes done according to your notes, thanks.
Its also been tested on FMUv5 by downloading logs by the USB

@bkueng bkueng merged commit cd8850b into PX4:master May 25, 2020
@BazookaJoe1900 BazookaJoe1900 deleted the pr-mavlink_log_remove_helper branch April 30, 2021 13:04
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.

None yet

2 participants