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:
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user