Skip to content
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

Merged
merged 5 commits into from
Dec 20, 2024
Merged

Conversation

playfulFence
Copy link
Contributor

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)

@@ -528,25 +531,14 @@ pub struct AtCmdConfig {
pub char_num: Option<u8>,
Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - sounds good

Copy link
Contributor

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)

Copy link
Contributor Author

@playfulFence playfulFence Dec 20, 2024

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 (?)

Copy link
Contributor

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"

Copy link
Contributor

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

Copy link
Contributor

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

@@ -1582,7 +1575,15 @@ where
}

fn flush(&mut self) -> Result<(), Self::Error> {
self.tx.flush()
loop {
Copy link
Contributor

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

Copy link
Contributor

@bugadani bugadani left a 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.

Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bjoernQ bjoernQ enabled auto-merge December 20, 2024 13:37
@bjoernQ bjoernQ added this pull request to the merge queue Dec 20, 2024
Merged via the queue into esp-rs:main with commit 62c7294 Dec 20, 2024
28 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
3 participants