-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fixes for issues #50, #53, #54 #56
Conversation
…uliaIO#50, JuliaIO#53) The high-level API previously had defined methods of Base.write() and Base.flush() that behaved quite differently from how Base documents these functions to behave, and in some cases didn't work at all. By removing these methods, we instead simply inherit much better working and more consistent ones from the `IO` supertype instead, making the high-level API more similar to Julia's file I/O API in Base. This patch also documents and passes through the low-level functions sp_drain(), sp_flush() and sp_output_waiting() to the high-level API, as these serial-port specific functions are what users should probably be using instead of Base.flush() to ensure UART queues are empty.
Calling loc() in the arguments of handle_error() causes unnecessary string allocations in the non-error path. The entire loc() function is unnecessary since Julia's stack traces already provide information on where an exception occured.
Thanks @mgkuhn, if you’re able to split the final three commits out (docs, type conversion, and loc calls) into a separate PR we can get those merged quickly as they’re not controversial IMHO. The other fixes will need someone to properly test so may take longer. |
I'd rather not split them: the final three are just cosmetics but separating them out is unproductive work. I'm really interested in fixing the current serious brokenness in the high-level interface that the first commit fixes. I did a lot of tests on Linux (including with a logic analyser on the loop-back wire), in an application with binary communication and tight timing requirements, and it quickly became clear that the current high-level interface had received little testing previously as several of its methods either just cause exceptions (issue #50 is just one example), or were implemented in a way that quietly loses bytes, that slows down communication, or that contradicts Julia's Here is some more detail about what was broken in the old write() methods that I removed or replaced:
In summary: the high-level write API implementation had some very severe problems, and this patch goes a long way towards eliminating those. I suspect I have already tested it much more thoroughly than the methods it replaces appear to have been. I hope the improvements are so significant and obvious that the best route is to test them in master. |
@mgkuhn thanks for this merge request. Apologies; life circumstances have slowed my responsiveness to your recently filed issues. I will have a closer look and do some testing. |
I pulled your The examples/console.jl demo also runs as expected. The "Reading with timeouts" test fails in runtests.jl, but that, along with #52, are topics covered by other issues. |
I think that this PR should be merged, then subsequent work is needed for the reading methods. |
See issues and individual commit comments for details.