-
Notifications
You must be signed in to change notification settings - Fork 15
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
Clarify whether non-blocking or stateless is the more important aspect of nb #13
Comments
@Nemo157 I haven't tried but maybe it's possible to set
I can give it a whirl later. |
I just attempted that and it doesn't seem to take, I'm pretty sure the event registers are clear-only. |
@Nemo157 The documentation is not quite clear about that. But another person in the interwebs attempted the same and also failed. ;) I'll try a few more variants later, maybe just send a dummy character into the void before setting up the peripheral pins... |
Leaving aside the implementability of this on the concrete hardware, I'd interpret the stateless aspect of a nb method to pertain to state from the individual calls (like the arguments being stored from one method call to the next), not internal management state of the callee. A UART implementation can get away with having all its management state in registers, but can just as well be a statefull component (like a bit-banging UART that has its registers in software and clocks out bits inside interrupts), or might be a hybrid of that (eg. this UART peripheral that needs additional management that lives inside its wrapper). |
I suppose one thing i'm influenced by is that i'd often consider a generator implementation for a nb call to be reasonable. At which point you are implicitly storing a bunch of state. |
In reference to @japaric's comment here.
Unfortunately this is not always possible, as an example consider the
embedded_hal::serial::Write
implementation from thenrf51_hal
crate:This is currently a blocking implementation. To convert it to a non-blocking implementation we need to introduce some state of whether we're currently transmitting a byte (as far as I can tell, there is no way to derive this from the microcontroller registers):
In my mind the whole purpose of
nb
is to support implementing non-blocking IO primitives suitable for integrating into something like afutures
event loop (although, I'm still trying to work out how to support interrupt-driven task notifications without having to have event loop specific implementations anyway...). If implementations are going to be forced to block to not have a tiny bit of important state, that undermines the entire utility of this crate.Once this is clarified I will try and open a PR documenting this along with other stuff mentioned in that comment.
cc @therealprof (in case you have some other ideas about non-blocking uart support on the nrf51)
The text was updated successfully, but these errors were encountered: