Closed thinkrapido closed 1 week ago
Hi Romeo,
it's nice to hear from you again, how are you? We've been co-organizing Rust meetup Stuttgart if you remember.
What platform are you running this code on? It it a microcontroller? What's the type of uart2
?
SmlReader
contains an internal buffer, which is 8KiB by default. You can use a different size, see SmlReader::with_static_buffer<N>()
. Ideally, your uart
port would implement either std::io::Read
or embedded_hal
s equivalent trait. you could then pass your port into SmlReader
and wouldn't need another buffer
.
Let me know if that helps
Looking at this again today:
You're using esp_idf_hal
, right? Its UartRxDriver
(which I'm pretty sure you're using in the example above) also implements the embedded_hal::serial::Read
trait. SmlReader
has support for this when using the optional feature "embedded-hal". You can use it with sml-rs
like this:
# Cargo.toml
[dependencies]
sml-rs = { path = "...", features = ["embedded_hal"] }
let mut reader = SmlReader::from_eh_reader(uart2);
// if you want to customize the internal buffer size:
// let mut reader = SmlReader::with_static_buffer::<1024>().from_eh_reader(uart2);
while let Some(res) = reader.next::<File>() {
match res {
Ok(file) => println!("{:#?}", file),
Err(e) => println!("Err({:?})", e),
}
}
Let me know whether that works for you and if you have suggestions regarding the crate.
Hi Romeo, I'm closing this issue as I haven't heard back from you. Feel free to reopen if you still have issues with the lib.
let _ = reader.read::<File>();
creates a stack overflow Maybe this is a problem with the buffer I created. I haven't figured it out, yet.