Skip to content

Commit

Permalink
fix(i2c.py): remove exception for valid API call
Browse files Browse the repository at this point in the history
Fixes Issue #359
  • Loading branch information
bhass1 committed Apr 26, 2024
1 parent 327a1a7 commit a28502f
Showing 1 changed file with 2 additions and 3 deletions.
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

0 comments on commit a28502f

Please sign in to comment.