Skip to content

Commit

Permalink
Merge pull request #584 from tagoylo/test-fixes
Browse files Browse the repository at this point in the history
Fixes for adrv9371 and adrv9009
  • Loading branch information
tfcollins authored Jan 21, 2025
2 parents 39a62ea + 43cf048 commit 4beb33a
Show file tree
Hide file tree
Showing 10 changed files with 873 additions and 633 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ jobs:
bash ./.github/scripts/install_pydeps.sh
sudo apt install -y python3-tk
- name: Test
- name: Test without optional dependencies
run: |
pip uninstall -y paramiko
pytest -vs --cov=adi --scan-verbose --emu --junitxml="results.xml" -k 'not prod'
- name: Report coverage
Expand All @@ -65,12 +66,6 @@ jobs:
with:
files: results.xml

- name: Test without optional dependencies
run: |
pip uninstall -y paramiko
pytest -vs --scan-verbose --emu --junitxml="results.xml" -k 'not prod'
Lint:
runs-on: ubuntu-latest
strategy:
Expand Down
80 changes: 52 additions & 28 deletions adi/ad937x.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,44 +170,68 @@ def tx_rf_bandwidth(self):
@property
def rx_enable_dec8(self):
"""rx_enable_dec8: Enable x8 decimation filter in RX path"""
avail = self._get_iio_attr_str(
"voltage0_i", "sampling_frequency_available", False, self._rxadc
)
avail = avail.strip().split(" ")
val = self._get_iio_attr_str(
"voltage0_i", "sampling_frequency", False, self._rxadc
)
return val == avail[1]
try:
avail = self._get_iio_attr_str(
"voltage0_i", "sampling_frequency_available", False, self._rxadc
)
except KeyError:
return False
else:
avail = avail.strip().split(" ")
val = self._get_iio_attr_str(
"voltage0_i", "sampling_frequency", False, self._rxadc
)
return val == avail[1]

@rx_enable_dec8.setter
def rx_enable_dec8(self, value):
avail = self._get_iio_attr_str(
"voltage0_i", "sampling_frequency_available", False, self._rxadc
)
avail = sorted(avail.strip().split(" "))
val = int(avail[1] if value else avail[0])
self._set_iio_attr("voltage0_i", "sampling_frequency", False, val, self._rxadc)
try:
avail = self._get_iio_attr_str(
"voltage0_i", "sampling_frequency_available", False, self._rxadc
)
except KeyError:
if value:
print(
"x8 decimation filter is not supported. Using default sampling frequency."
)
else:
avail = sorted(avail.strip().split(" "))
val = int(avail[1] if value else avail[0])
self._set_iio_attr(
"voltage0_i", "sampling_frequency", False, val, self._rxadc
)

@property
def tx_enable_int8(self):
"""tx_enable_int8: Enable x8 interpolation filter in TX path"""
avail = self._get_iio_attr_str(
"voltage0", "sampling_frequency_available", True, self._txdac
)
avail = avail.strip().split(" ")
val = self._get_iio_attr_str(
"voltage0", "sampling_frequency", True, self._txdac
)
return val == avail[1]
try:
avail = self._get_iio_attr_str(
"voltage0", "sampling_frequency_available", True, self._txdac
)
except KeyError:
return False
else:
avail = avail.strip().split(" ")
val = self._get_iio_attr_str(
"voltage0", "sampling_frequency", True, self._txdac
)
return val == avail[1]

@tx_enable_int8.setter
def tx_enable_int8(self, value):
avail = self._get_iio_attr_str(
"voltage0", "sampling_frequency_available", True, self._txdac
)
avail = sorted(avail.strip().split(" "))
val = int(avail[1] if value else avail[0])
self._set_iio_attr("voltage0", "sampling_frequency", True, val, self._txdac)
try:
avail = self._get_iio_attr_str(
"voltage0", "sampling_frequency_available", True, self._txdac
)
except KeyError:
if value:
print(
"x8 interpolation filter is not supported. Using default sampling frequency."
)
else:
avail = sorted(avail.strip().split(" "))
val = int(avail[1] if value else avail[0])
self._set_iio_attr("voltage0", "sampling_frequency", True, val, self._txdac)

@property
def rx_sample_rate(self):
Expand Down
7 changes: 3 additions & 4 deletions adi/adrv9009.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, uri="", jesd_monitor=False, jesd=None):
self._txdac = self._ctx.find_device("axi-adrv9009-tx-hpc")
self._ctx.set_timeout(30000) # Needed for loading profiles
if jesdadi and jesd_monitor:
self._jesd = jesd if jesd else jesdadi(uri=uri)
self._jesd = jesd if jesd else jesdadi(address=uri)
rx_tx.__init__(self)
self.obs = obs(self._ctx, self._rxobs, self._obs_channel_names)

Expand Down Expand Up @@ -214,11 +214,11 @@ def obs_powerdown_en(self, value):
@property
def aux_obs_lo(self):
"""aux_obs_lo: Carrier frequency of ORx path"""
return self._get_iio_attr("altvoltage1", "AUX_OBS_RX_LO_frequency", True)
return self._get_iio_attr("altvoltage1", "frequency", True)

@aux_obs_lo.setter
def aux_obs_lo(self, value):
self._set_iio_attr("altvoltage1", "AUX_OBS_RX_LO_frequency", True, value)
self._set_iio_attr("altvoltage1", "frequency", True, value)

@property
def obs_quadrature_tracking_en(self):
Expand Down Expand Up @@ -250,7 +250,6 @@ def obs_hardwaregain(self):

@obs_hardwaregain.setter
def obs_hardwaregain(self, value):
# if self.obs_gain_control_mode == "manual":
self._set_iio_attr("voltage2", "hardwaregain", False, value)

@property
Expand Down
9 changes: 8 additions & 1 deletion examples/ad9371.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
#
# SPDX short identifier: ADIBSD

import sys
import time

import adi
import matplotlib.pyplot as plt
import numpy as np
from scipy import signal

# Optionally pass URI as command line argument,
# else use default context manager search
my_uri = sys.argv[1] if len(sys.argv) >= 2 else None
print("uri: " + str(my_uri))

# Create radio
sdr = adi.ad9371()
sdr = adi.ad9371(uri=my_uri)

# Configure properties
sdr.rx_enabled_channels = [0, 1]
Expand Down Expand Up @@ -48,6 +54,7 @@

# Collect data
fsr = int(sdr.rx_sample_rate)
print(fsr)
for r in range(20):
x = sdr.rx()
f, Pxx_den = signal.periodogram(x[0], fsr)
Expand Down
10 changes: 8 additions & 2 deletions examples/ad9371_dec8.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
#
# SPDX short identifier: ADIBSD

import sys
import time

import adi
import matplotlib.pyplot as plt
import numpy as np
from scipy import signal

# Optionally pass URI as command line argument,
# else use default context manager search
my_uri = sys.argv[1] if len(sys.argv) >= 2 else None
print("uri: " + str(my_uri))

# Create radio
sdr = adi.ad9371(uri="ip:192.168.86.55")
sdr = adi.ad9371(uri=my_uri)

# Configure properties
sdr.rx_enabled_channels = [0, 1]
Expand Down Expand Up @@ -65,4 +71,4 @@
plt.pause(0.05)
time.sleep(0.1)

# plt.show()
plt.show()
Loading

0 comments on commit 4beb33a

Please sign in to comment.