You can use inWaiting()
to get the amount of bytes available at the input queue.
Then you can use read()
to read the bytes, something like that:
While True:
bytesToRead = ser.inWaiting()
ser.read(bytesToRead)
Why not to use readline()
at this case from Docs:
Read a line which is terminated with end-of-line (eol) character (\n by default) or until timeout.
You are waiting for the timeout at each reading since it waits for eol. the serial input Q remains the same it just a lot of time to get to the “end” of the buffer, To understand it better: you are writing to the input Q like a race car, and reading like an old car 🙂