0

I'm listening serial port using pySerial. Data processed only when I got chunk of data, that I can process. Simple event dispatcher listen for events from readet, then event data handled. Handling may involve IO, Networking and another type of time-consuming OS operations. But who will read data from serial in time of processing last data?

For example

    Port stream >> | 1111111111111111 | 222222 | 2222222 | 33333
                   ---------------------------------------------
Programm thread >> | listen port 1 -> | handle | listen2 | .....

So data from port which come in time on handling will be lost? like starting of package of 2?

How to to guarantee, that all data from port will be processed in time?

  • Hardware: Raspberry PI 3b
  • OS: Raspbian
  • Python: v2.7
Micke
  • 2,081
  • 4
  • 32
  • 43
Neka
  • 1,474
  • 2
  • 19
  • 35

1 Answers1

1

The use of circular buffers and threads in python would be a solution. Another one would be to implement a different protocol so the sender waits for the listener to acknowledge reception before sending new data

JD_GRINDER
  • 334
  • 2
  • 6