Skip to content

Commit

Permalink
adi/adrv9002.py: write_profile add 3 attempts
Browse files Browse the repository at this point in the history
Sometimes the profile load fails with IO error.
I assume the cause could come from the SPI interface. This error
arises even if the profile is loaded directly from the SD card on the system.

Signed-off-by: AndreiGrozav <[email protected]>
  • Loading branch information
AndreiGrozav committed Dec 18, 2024
1 parent 0dc0f74 commit b91a828
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions adi/adrv9002.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ def write_stream_profile(self, stream, profile):
iio._d_write_attr(self._ctrl._device, attr_encode, data)
with open(profile, "r") as file:
data = file.read()
self._set_iio_dev_attr_str("profile_config", data)
for t in range(3):
try:
self._set_iio_dev_attr_str("profile_config", data)
break
except Exception as e:
print("#" + str(t) + "profile load failed")
if t == 2:
raise Exception("Failed to load profile")
print(e)

def write_profile(self, value):
"""Load a new profile on the device
Expand All @@ -107,7 +115,15 @@ def write_profile(self, value):
"""
with open(value, "r") as file:
data = file.read()
self._set_iio_dev_attr_str("profile_config", data)
for t in range(3):
try:
self._set_iio_dev_attr_str("profile_config", data)
break
except Exception as e:
print("#" + str(t) + "profile load failed")
if t == 2:
raise Exception("Failed to load profile")
print(e)

def write_stream(self, value):
"""Load a new stream on the device
Expand Down

0 comments on commit b91a828

Please sign in to comment.