diff --git a/mtkclient/Library/Connection/usblib.py b/mtkclient/Library/Connection/usblib.py index 8917852b..6657a697 100755 --- a/mtkclient/Library/Connection/usblib.py +++ b/mtkclient/Library/Connection/usblib.py @@ -424,15 +424,16 @@ def usbread(self, resplen=None, maxtimeout=100): wMaxPacketSize = self.EP_IN.wMaxPacketSize extend = res.extend buffer = None + buflen=min(resplen,wMaxPacketSize) if self.fast: - buffer = self.buffer[:resplen] + buffer = self.buffer[:buflen] while len(res) < resplen: try: if self.fast: rlen = epr(buffer, timeout) extend(buffer[:rlen]) else: - extend(epr(resplen)) + extend(epr(buflen)) except usb.core.USBError as e: error = str(e.strerror) if "timed out" in error: @@ -454,7 +455,6 @@ def usbread(self, resplen=None, maxtimeout=100): self.verify_data(res[:resplen], "RX:") return res[:resplen] - def usbxmlread(self, maxtimeout=100): res = bytearray() timeout = 0