Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pyftdi/i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,6 @@ def exchange(self, address: int,
if not self.configured:
raise I2cIOError("FTDI controller not initialized")
self.validate_address(address)
if readlen < 1:
raise I2cIOError('Nothing to read')
if readlen > (self.PAYLOAD_MAX_LENGTH/3-1):
raise I2cIOError("Input payload is too large")
if address is None:
Expand All @@ -767,13 +765,14 @@ def exchange(self, address: int,
i2caddress = (address << 1) & self.HIGH
retries = self._retry_count
do_epilog = True
data = bytearray()
with self._lock:
while True:
try:
self._do_prolog(i2caddress)
self._do_write(out)
self._do_prolog(i2caddress | self.BIT0)
if readlen:
self._do_prolog(i2caddress | self.BIT0)
data = self._do_read(readlen)
do_epilog = relax
return data
Expand Down