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

plugins: add log streaming #2280

Merged
merged 7 commits into from
Apr 25, 2024
Merged

plugins: add log streaming #2280

merged 7 commits into from
Apr 25, 2024

Conversation

julianoes
Copy link
Collaborator

@julianoes julianoes commented Apr 12, 2024

This adds log streaming. The stream is transmitted via a base64 string because bytes didn't compile using our gRPC infrastructure.

This PR also exposes base64 encoding and decoding functions for C++ users of the API. For Python, this comes with the batteries included.

@julianoes julianoes force-pushed the pr-log-streaming branch 5 times, most recently from d262023 to 0d969b4 Compare April 22, 2024 03:29
@julianoes julianoes marked this pull request as ready for review April 22, 2024 03:29
@julianoes
Copy link
Collaborator Author

@bkueng it would be awesome if you could give this a quick check/review. I'm basically just saving the data stream but not doing any reordering or retrying.

Signed-off-by: Julian Oes <julian@oes.ch>
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.

Looks good so far. I would also have a look at the mavlink-router implementation, as it has additional timeout handling.
You might already have thought about it, but also make sure to clear the buffer and _maybe_current_sequence after stopping (or when starting).

Instead of the magic wait time, what about just waiting 3s. This fixes
the problem after we send a LOGGING_STOP to PX4 which takes a bit of
time to wrap up.

Signed-off-by: Julian Oes <julian@oes.ch>
Signed-off-by: Julian Oes <julian@oes.ch>
This means we can ignore incoming messages if we haven't actually
started logging which makes stopping less confusing.

Signed-off-by: Julian Oes <julian@oes.ch>
Signed-off-by: Julian Oes <julian@oes.ch>
Signed-off-by: Julian Oes <julian@oes.ch>
And don't bother warning about something being too short, just log it.

Signed-off-by: Julian Oes <julian@oes.ch>
Copy link
Collaborator Author

@julianoes julianoes left a comment

Choose a reason for hiding this comment

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

Thanks @bkueng. I think I have addressed it all, minus the timeout that you suggested.

Is the timeout to basically restart logging if we haven't received data in a bit?

Copy link

sonarcloud bot commented Apr 24, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
4.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@bkueng
Copy link
Member

bkueng commented Apr 24, 2024

Is the timeout to basically restart logging if we haven't received data in a bit?

Yes exactly. It's not strictly required.

@julianoes
Copy link
Collaborator Author

Yes exactly. It's not strictly required.

We'll see if I have to add it once I'm testing it.

@julianoes julianoes merged commit e61c341 into main Apr 25, 2024
27 of 28 checks passed
@julianoes julianoes deleted the pr-log-streaming branch April 25, 2024 23:28
@julianoes
Copy link
Collaborator Author

Forgot to update proto submodule, duh.

@bkueng
Copy link
Member

bkueng commented Apr 26, 2024

I'm basically just saving the data stream but not doing any reordering or retrying.

Just keep in mind that without considering the sequence number, a message drop will likely lead to a corrupt ulog stream. Which is very likely going to happen if going through a serial link.

@julianoes
Copy link
Collaborator Author

Aha, so what do you do on drop? Remove what's currently in the buffer to be written and start fresh?

@bkueng
Copy link
Member

bkueng commented Apr 29, 2024

Yes, that's what first_message_offset is used for. If data is dropped, it tells you when there is a valid message start again.

@julianoes
Copy link
Collaborator Author

Ok thanks. I'll try to add that.

@julianoes
Copy link
Collaborator Author

Coming with #2290.

ddatsko pushed a commit to ddatsko/MAVSDK that referenced this pull request Aug 6, 2024
* plugins: add log streaming
* core: wait long enough after IN_PROGRESS
* log_streaming: additional length checks
* log_streaming: use active flag to track state
* log_streaming: add missing include
* log_streaming: prevent double stopping
* log_streaming: write what we have anyway
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