I am reading values from 2 UARTs. i want to read at the same time (without time shift between the 2 UART) the values they send in order to add them. How do I achieve that? I am searching on google, I don't find something similar..

  • Ah you can try python concurrent programming. You might like to read the following to get a rough idea of the python multiprocessing trick: (1) raspberrypi.stackexchange.com/questions/112309/…. There is a copy and run short demo program you can run to get a taste of concurrent/state programming.
    – tlfong01
    May 23, 2020 at 1:16
  • I also remember that Rpi python serial module has something called non blocking UART/serial read/write. That means even you starting reading one UART, the reading is not blocked, so you can immediately switch to another UART read/write. But I hae not tried that, because I prefer multiprocessing. Please feel free to ask me any newbie questions.
    – tlfong01
    May 23, 2020 at 1:24
  • You might find the following multi-threading and non-blocking serial Q&A helpful (1) “PySerial non-blocking read loop - StackOverflow Q&A, Asked 2013, Viewed 76k times”: stackoverflow.com/questions/17553543/…. Cheers.
    – tlfong01
    May 23, 2020 at 5:11
  • 1
    I read them.Can I achieve something like this: I assign one core to UART1, one core to UART2 to get the two measurements and then I sum up the two current values to get the total. ?? May 25, 2020 at 9:35
  • Ah. if you get two different values from different multiprocesses, there is no reason you cannot add the two values up, and actually any other thing you want to do with those values. Happy multiprocessing. Cheers.
    – tlfong01
    May 26, 2020 at 0:53


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.