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:
parent
c04b0a5add
commit
8388624721
@ -30,7 +30,7 @@ class SerialReader(object):
|
|||||||
"""
|
"""
|
||||||
with serial.Serial(**self.serial_settings) as serial_handle:
|
with serial.Serial(**self.serial_settings) as serial_handle:
|
||||||
while True:
|
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'))
|
self.telegram_buffer.append(data.decode('ascii'))
|
||||||
|
|
||||||
for telegram in self.telegram_buffer.get_all():
|
for telegram in self.telegram_buffer.get_all():
|
||||||
|
Loading…
Reference in New Issue
Block a user