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

Remove the single byte read/write inherent functions #2915

Merged
merged 11 commits into from
Jan 10, 2025

Conversation

JurajSadel
Copy link
Contributor

closes #2808

cc #2882

Copy link
Member

@SergioGasquez SergioGasquez left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, left some nitpicks, some of them can be ignored, I guess

esp-hal/MIGRATING-0.22.md Outdated Show resolved Hide resolved
esp-hal/MIGRATING-0.22.md Outdated Show resolved Hide resolved
esp-hal/MIGRATING-0.22.md Outdated Show resolved Hide resolved
esp-hal/src/uart.rs Outdated Show resolved Hide resolved
@SergioGasquez
Copy link
Member

We should also remove the read_byte method from UartRx and write_byte from UartTx

@JurajSadel
Copy link
Contributor Author

We should also remove the read_byte method from UartRx and write_byte from UartTx

I made private functions from read_byte in UartRx - other should be private as well. They are low-level so we need to have them, I guess.

@@ -459,6 +471,12 @@ The Address and Command enums have similarly had their variants changed from e.g
+ Command::_1Bit
```

`write_byte` and `read_byte` were removed and `write_bytes` and `read_bytes` can be used as replacement.
Copy link
Contributor

Choose a reason for hiding this comment

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

You could expand on this a little bit - like mentioning to use a one byte sized buffer and checking the returned length

esp-hal/MIGRATING-0.22.md Outdated Show resolved Hide resolved
esp-hal/MIGRATING-0.22.md Outdated Show resolved Hide resolved
@@ -526,6 +512,11 @@ where
Ok(())
}

/// Read bytes from SPI.
pub fn read_bytes(&mut self, words: &mut [u8]) -> Result<(), Error> {
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll have to take a bit of care here. UART's read_bytes is not blocking, SPI's read_bytes is blocking. As the peripherals work differently, it makes logical sense, but I'm not sure if we want the function use the same name, but do different things.

Copy link
Member

Choose a reason for hiding this comment

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

I guess this should be resolved in #2882 which is a bit stalled due to 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.

Please elaborate how it will be resolved, that PR still has a non-blocking pub fn read_bytes(&mut self, buf: &mut [u8]) -> usize {. Non-blocking in the sense that it doesn't fill up the buffer, but returns early if there is not enough data to read.

Copy link
Member

Choose a reason for hiding this comment

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

I guess we could add some documentation or rename, it can also be done here, no hard opinions

Copy link
Member

Choose a reason for hiding this comment

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

Imo this is fine as is, and if anything we should change uart's read_bytes back to being blocking and introduce a nb API post 1.0

Copy link
Contributor

Choose a reason for hiding this comment

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

A little bit more documentation wouldn't hurt probably. "Read bytes from SPI" is very brief

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A little bit more documentation wouldn't hurt probably. "Read bytes from SPI" is very brief

Well, it matches write_bytes and transfer 😆

Copy link
Contributor

@bugadani bugadani Jan 10, 2025

Choose a reason for hiding this comment

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

I'll do the UART changes once these PRs land.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please leave a non-blocking one around, in my application I don't know how much data the transmitter is going to send so I need the non-blocking version to just read what is available 😅

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

@JurajSadel JurajSadel enabled auto-merge January 10, 2025 14:30
Copy link
Member

@SergioGasquez SergioGasquez left a comment

Choose a reason for hiding this comment

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

LGTM!

@JurajSadel JurajSadel added this pull request to the merge queue Jan 10, 2025
Merged via the queue into esp-rs:main with commit 03ea4f6 Jan 10, 2025
28 checks passed
@JurajSadel JurajSadel deleted the read/write_byte branch January 10, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the single byte read/write inherent functions
6 participants