esp-rs / esp-println

Provides print! and println! implementations various Espressif devices
Apache License 2.0
19 stars 13 forks source link

Add an example #29

Closed bjoernQ closed 6 months ago

bjoernQ commented 1 year ago

While an example wouldn't really help to understand the usage of the library it would make it easier to smoke-test things on PRs

brainstorm commented 7 months ago

Totally second that and today I was also wondering if it's possible to output raw bytes to stdout to pipe/redirect I2S mems microphone data through one of the esp-hal examples, i.e:

$ cargo xtask run-example esp-hal esp32c6 embassy_i2s_read > mic.data

On the one hand I suspect this is not the crate to ask about this since print/println's task is to format data instead of passing bytes as-is, but on the other hand SO answers like this one point to std (while the embassy and other I2S examples are obviously for no_std).

Folks seem to default on re-implementing core::fmt::Write for no_std or use crates like core2, so probably this could be an opportunity to have some sort of a print_bytes! wrapper/function in esp-println (as a re-export?) for ease of use?

Am I the first one with this (weird?) usecase? :-S

Related: https://github.com/esp-rs/esp-hal/issues/1277

MabezDev commented 7 months ago

Hey @brainstorm, swinging by on mobile right now, but generally if you want to write useful bytes (not just logging) out of a uart, you should use the uart in esp-hal, and use the embedded-io traits: https://docs.esp-rs.org/esp-hal/esp-hal/0.16.1/esp32s3/esp_hal/uart/struct.Uart.html#method.write_all-1 to do so. embedded-io is backed by the embedded working group and is the proper replacement for core io traits :).

danclive commented 7 months ago

I tried to add a complete example tonight, but it ended up having reverse dependencies like esp-hal and esp-backtrace, and I'm not sure how to handle that. Maybe in the future we'll need a dedicated repository, like esp-examples, to store more examples.

MabezDev commented 6 months ago

@danclive Thanks for looking into this, I think you're right, we'll end up in rev dependency hell if we try and add an example here. Let's close this for now, we already have some usage of esp_println in the esp-hal examples anyways.