-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Multiple API fixes in UART driver #2851
Conversation
esp-hal/src/uart.rs
Outdated
@@ -528,25 +531,14 @@ pub struct AtCmdConfig { | |||
pub char_num: Option<u8>, |
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 wonder if we should make this Option<core::num::NonZeroU8>
- Some(0)
doesn't make sense and if None
we use 1
Would save us two bytes - not sure if it's worth it - makes things a bit less nice in user code
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.
This can also just be u8
, can't it?
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.
yes - sounds good
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.
(probably needs some explanation in the doc-comment)
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 we need to validate AtCmdConfig
if char_num
is not 0 which is related to #2839 and probably should not be done in this PR (?)
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.
0 might be a perfectly reasonable value of "I don't want to detect AT commands"
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.
0
just means the same as currently None
- shouldn't change anything?
BUT I just realized that some chips (e.g. ESP32 at least) offer more than 16 bits for the counts and the time-out.
Big question before stabilization would be if we are fine with artificially limiting this or not
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.
oh and I think it solves a problem: currently we cannot undo the at-cmd-config once set? After the change the user could set char_num
to 0
and effectivly disable it
esp-hal/src/uart.rs
Outdated
@@ -1582,7 +1575,15 @@ where | |||
} | |||
|
|||
fn flush(&mut self) -> Result<(), Self::Error> { | |||
self.tx.flush() | |||
loop { |
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.
embedded_io::Write::flush(&mut self.tx)
would safe us from duplicating this code
b702b8a
to
a0c4772
Compare
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.
Maybe the constructor change should be in the migration guide.
a0c4772
to
9f6a400
Compare
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.
LGTM
closes #2733
closes #2726
closes #2724
closes #2636 (public methods only, post your thoughts here if you want private functions to follow these conventions too)