The read method is improved.
pull/6/head
Quan Lin 2019-01-16 15:51:11 +11:00
rodzic 7cddcc1765
commit c0f45b73f2
4 zmienionych plików z 15 dodań i 11 usunięć

Wyświetl plik

@ -2,7 +2,7 @@ from setuptools import setup
setup(
name="usbserial4a",
version="0.1.5",
version="0.1.6",
description="Python package for Kivy Android USB serial port.",
long_description="https://github.com/jacklinquan/usbserial4a",
long_description_content_type="text/markdown",

Wyświetl plik

@ -9,4 +9,4 @@ Requires: kivy, pyjnius, pyserial, usb4a
'''
# Project version
__version__ = '0.1.5'
__version__ = '0.1.6'

Wyświetl plik

@ -37,7 +37,7 @@ class CdcAcmSerial(SerialBase):
DEFAULT_READ_BUFFER_SIZE = 1024
DEFAULT_WRITE_BUFFER_SIZE = 16 * 1024
USB_READ_TIMEOUT_MILLIS = 1
USB_READ_TIMEOUT_MILLIS = 50
USB_WRITE_TIMEOUT_MILLIS = 5000
def __init__(self, *args, **kwargs):
@ -176,10 +176,12 @@ class CdcAcmSerial(SerialBase):
read = bytearray()
timeout = Timeout(self.timeout)
# Keep reading until there is enough data or timeout.
while self.in_waiting < size:
if timeout.expired():
break
# If there is enough data in the buffer, do not bother to read.
if len(self._read_buffer) < size:
# Keep reading until there is enough data or timeout.
while self.in_waiting < size:
if timeout.expired():
break
# Get data from read buffer.
read = self._read_buffer[:size]

Wyświetl plik

@ -185,10 +185,12 @@ class FtdiSerial(SerialBase):
read = bytearray()
timeout = Timeout(self.timeout)
# Keep reading until there is enough data or timeout.
while self.in_waiting < size:
if timeout.expired():
break
# If there is enough data in the buffer, do not bother to read.
if len(self._read_buffer) < size:
# Keep reading until there is enough data or timeout.
while self.in_waiting < size:
if timeout.expired():
break
# Get data from read buffer.
read = self._read_buffer[:size]