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

Fix COBSPrint::abort() and add PacketPrint::reset() #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lopsided98
Copy link

COBSPrint::abort() has two bugs: the leftover buffer is not reset, causing old data to be printed after the abort, and the counter is reset to 0 instead of 1, causing the next packet to fail.

For my application, I need the ability to reset the internal packet state without trying to terminate the current packet, so I added the PacketPrint::reset() method.

These changes build off each other, so I put them in the same PR.

abort() did not reset the leftover buffer, causing the aborted packet to
be retried. It also didn't reset the counter correctly.
This method allows a new packet to be started even if we are in the
middle of writing the previous packet. No attempt is made to make sure
the transition between packets is valid.
@@ -126,8 +126,6 @@ class COBSPrint : public PacketPrint
}

virtual void abort() override {
_counter = 0;
Copy link
Owner

Choose a reason for hiding this comment

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

Nice catch. Sorry for not spotting this PR two years ago...

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