Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(i2c.py): remove exception for valid API call #378

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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