Giter VIP home page Giter VIP logo

Comments (4)

ivmarkov avatar ivmarkov commented on September 21, 2024

Do you still miss bytes if you busyloop, instead of sleeping? I.e. what happens if you comment out the thread::sleep line?

from esp-idf-hal.

callmephilip avatar callmephilip commented on September 21, 2024

Do you still miss bytes if you busyloop, instead of sleeping? I.e. what happens if you comment out the thread::sleep line?

Yes. And watchdog gets triggered

from esp-idf-hal.

callmephilip avatar callmephilip commented on September 21, 2024

i think i got it to work the following way:

let start = SystemTime::now();

const magic_buffer_size_plus_10: usize = 130;
const ticks_to_wait: u32 = 1;

let mut buffer : [u8; magic_buffer_size_plus_10] = [0; magic_buffer_size_plus_10];

while start.elapsed().unwrap().as_secs() < timeout {
  match unsafe { uart_read_bytes(self.port, &mut buffer as *mut u8 as *mut _, magic_buffer_size_plus_10 as u32, ticks_to_wait) } {
    -1 => /* error */,
    val => {
      for i in 0..val {
        data.push(buffer[i as usize]);
      }
    }
  };
}

I am still not 100% sure what is going on exactly but I suspect that current implementation of Read for Rx is inadequate when dealing withe spurs of data sent over a short period of time (600 bytes over just a few milliseconds in my particular case)

from esp-idf-hal.

MabezDev avatar MabezDev commented on September 21, 2024

With those kinds of bursts, in general, it is best to use the DMA, or at the very least interrupt-driven. Even when you busy loop the scheduler will swap out the task that your code is running in and you will easily lose data this way. I don't think the DMA has support in Rust just yet, but that may be something you wish to look at.

Thanks for issue! Closing as this doesn't seem to be a bug.

from esp-idf-hal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.