-
Notifications
You must be signed in to change notification settings - Fork 10
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
UART: Add wrapper around RIOT's UART-interface #39
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR. I've cleared it for a first CI run, but haven't yet had time to look at it. Given this needs a uart_t at construction, it might be good to look at #37 in parallel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this. It looks good over-all, and very comprehensive. I have several details and questions annotated across the source. Quite a few of them might easily be explained by inspiration from existing code; I'd still hope to not continue on the bad examples I've set in the past.
First of all, thank you for this comprehensive review. I will try to resolve your issues in the next few days :) |
CI tests are failing because RIOT's version of the riot-sys crate wasn't updated to the latest nightly yet -- but that's on the RIOT repository side of things. |
When all open issues are addressed (I think it's only the matter of safety and scoping), as with the DAC PR, I'll want to have a test around to ensure that the code is actually built during CI. Let me know whether you want to give that a try in the style of c9cf3f2, otherwise I'll do it as part of the final review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is approaching completion.
Given the many fixes and merges, please rebase onto current master and squash into one or some logically structured commits.
Would you add some small runnable test?
@kbarning hey! I accidentally started a competing PR, I overlooked your work. Do you intend of picking this PR up again? |
Sorry for having let this sit unduly long, especially after you've brought it all this way – and not having remembered that this is sitting when Teufelchen started up his PR didn't help make the situation better, yet here we are. Before I start looking through both PRs to see whether there's one that clearly outperforms (on usability, safe usability, features or clarity), would the two of you like to have a look over each other's PRs and/or a short exchange on whether there is one you both prefer or aspects missing from both? |
Okay, I gave it a thought and I believe this PR is better, in the sense that it is much more mature (documentation, api completeness, etc.). What is missing compared to my draft is the implementation of This PR needs a rebase. I did a shitty one locally to test this PR, it was annoying but not too bad. The code still works as intended. @kbarning I can imagine you want this done sooner than later, please rebase and squash. I'll poke @chrysn to review it in a timely manner :) (I can also offer to rebase & squash for you, if you like) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final round of comments while going through this again after the duplicate PR situation is being resolved.
Most of them should be easy to apply. The soundness one will need another round of review, but given that there was a lifetime in the type in earlier iterations, it should be managable.
src/uart.rs
Outdated
/// static mut CB: fn(u8) = |new_data| { | ||
/// //do something here with the received data | ||
/// }; | ||
/// let mut uart = UartDevice::new_with_static_cb(0, 115200, unsafe { &mut CB }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The better example would be to use static_cell
or maybe crate::mutex::Mutex
, or even println!("Received {:02x}", new_data);
, but unless you feel super motivate to update this, we can leave that as is for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the println!
in the examples :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then could almost just be fn cb(new_data: &[u8) { println!(...) }
, no need for a mut static that'll need unsafe and makes the linter scream.
Almost, because we don't get a &mut cb
, which hints at that user_callback should be F and not &'scope mut F … which again we can't do because we don't have a size limit.
We may need to iterate over that later on, but that'll work better when we see actual use cases. So let's have this in for now. I've just updated the example to not use static muts any more.
I will have a look in the following days :) |
Co-authored-by: chrysn <chrysn@fsfe.org>
Co-authored-by: chrysn <chrysn@fsfe.org>
Co-authored-by: chrysn <chrysn@fsfe.org>
Co-authored-by: chrysn <chrysn@fsfe.org>
Co-authored-by: chrysn <chrysn@fsfe.org>
Co-authored-by: chrysn <chrysn@fsfe.org>
Co-authored-by: chrysn <chrysn@fsfe.org>
Co-authored-by: chrysn <chrysn@fsfe.org>
Co-authored-by: chrysn <chrysn@fsfe.org>
405bfc8
to
455291e
Compare
I have rebased my branch. The squashing is done directly via this PR right? (at least I think so, if not I think @chrysn can enable it). It would be great if you can add the embedded_io stuff @Teufelchen1 because I hardly have any time at the moment 😞. |
Yes, squashing can be done via GitHub UI by chrysn (I do not have permissions). |
I wouldn't insist on squashing in general; if you prefer things squashed to a single commit, that can be done at merge time. (My general approach is that I like to have history visible in the tree, and merges from master into the feature branches, because people can always get a view as-if-squashed from git using The latest version you pushed was not tested locally, was it? I've found a few compile errors, but am fixing them locally and pushing to the branch as part of a final checking round. |
I've added a few fixes to the branch |
When you're done with the fixes, should I rebase this branch from yours? |
I think I'm happy with the branch containing your work and my fixes now; I've created #143 as to run CI on it. Can either of you run a check on that one, and look into whether anything is amiss? I'll go through the open comments, and mark as resolved what has been addressed. |
@@ -0,0 +1,331 @@ | |||
//! Access to [RIOT's UART](https://doc.riot-os.org/group__drivers__periph__uart.html) | |||
//! | |||
//! Author: Kilian Barning <barning@uni-bremen.de> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a consistent policy in Rust code for RIOT as to how to annotate authorship per module. I'd leave this in for now, especially until we do have something more generic, but as this is not a copyright note, it may be removed in a later version – realistically, I expect it to be moved into more meta data at some point.
With the review on #143, I've squashed things there; I'll merge that soon. @kbarning, you might take interest in the notes of squashing there in #143 (comment) |
Here is my attempt to create a wrapper for RIOT's UART-interface :)