Closed johnc219 closed 7 years ago
Hello, @johnc219! This is your first Pull Request that will be reviewed by Ebert, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information.
Thank you so much for your detailed write-up and the PR!
I agree with your analysis and the choice to use the flush
approach especially since quite a few people have custom framers. I appreciate you writing up the reset
version, though. Part of me likes it better and I'll probably think about it again when/if I make a more major change to the framer interface.
Cheers! Thanks for making this project 👍
Aims to fix the following issue:
Repro Steps
On master,
framing
, e.g.expected (this branch)
{:error, :ebadf}
actual
When closing, the
framing_state
is set tonil
, butframing
is left intact (Nerves.UART.Framing.Line
) The second test I added breaks in master with this error, but passes on this branch.Proposed solution
The goal is to reset the
framing_state
when closing, rather than clearing it tonil
. When we clear it tonil
we lose info about the Framing options, e.g.:separator
.Flushing the framing clears the
:processed
and:in_process
binary while leaving the client-supplied options intact.I'm not certain flushing is the best long-term approach however as the
flush
callback now has the added the responsibility of knowing what to do when the port is closed. So perhaps when closing you could do something likewhere
:reset
is a Framing callback. Here is the diff of a separate branch that fixes this issue with thisreset
approach instead. I'm guessing that would break anyone who's implemented their own framings though, so it would require a major version bump. Therefore i think theflush
approach is the (possibly less correct) safer alternative.Current workaround
After closing i explicitly configure the uart like such: