Read more data from serial port at once

A telegram can contain dozens of lines. Reading them one by one is somewhat inefficient.
With this change, the client tries to read all data that is available.
This significantly reduced CPU load for me.
This commit is contained in:
Thomas Neele 2019-07-22 21:33:15 +02:00
parent c04b0a5add
commit 8388624721

View File

@ -30,7 +30,7 @@ class SerialReader(object):
"""
with serial.Serial(**self.serial_settings) as serial_handle:
while True:
data = serial_handle.readline()
data = serial_handle.read(max(1, min(1024, serial_handle.in_waiting)))
self.telegram_buffer.append(data.decode('ascii'))
for telegram in self.telegram_buffer.get_all():