Merge pull request #37 from tneele/master

Improve performance: read more data from serial port at once
This commit is contained in:
Nigel Dokter 2019-07-29 10:13:13 +02:00 committed by GitHub
commit 50a5cb9203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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():