Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SaikiranGudla authored Oct 4, 2023
2 parents ea1b389 + bdc6fa2 commit 7c05d6d
Show file tree
Hide file tree
Showing 74 changed files with 9,037 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/install_libiio.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
sudo apt-get -qq update
sudo apt-get install -y git cmake graphviz libavahi-common-dev libavahi-client-dev libaio-dev libusb-1.0-0-dev libxml2-dev rpm tar bzip2 gzip flex bison git
git clone -b 'master' --single-branch --depth 1 https://github.com/analogdevicesinc/libiio.git
git clone -b 'v0.25' --single-branch --depth 1 https://github.com/analogdevicesinc/libiio.git
cd libiio
cmake . -DHAVE_DNS_SD=OFF
make
Expand Down
18 changes: 5 additions & 13 deletions JenkinsfileHW
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,21 @@ lock(label: 'adgt_test_harness_boards') {
def linuxBranch = "NA"
def bootPartitionBranch = "master"
def jenkins_job_trigger = "ci"
def firmwareVersion = 'v0.34'
def firmwareVersion = 'v0.37'
def bootfile_source = 'artifactory' // options: sftp, artifactory, http, local
def harness = getGauntlet(hdlBranch, linuxBranch, bootPartitionBranch, firmwareVersion, bootfile_source)

//Update repos
harness.set_env('nebula_repo', 'https://github.com/sdgtt/nebula.git')
harness.set_env('nebula_branch','dev')
harness.set_env('telemetry_repo', 'https://github.com/sdgtt/telemetry.git')
harness.set_env('telemetry_branch', 'master')

def pyadi_branch = scm.branches.first().getExpandedName(env.getEnvironment())
harness.set_env('pyadi_iio_branch', pyadi_branch.toString())

//Update nebula config from netbox
harness.set_update_nebula_config(true)
harness.set_env('nebula_config_source','netbox')
harness.set_env('netbox_ip','192.168.10.11')
harness.set_env('netbox_ip','primary.englab')
harness.set_env('netbox_port','8000')
harness.set_env('netbox_base_url','netbox')
withCredentials([string(credentialsId: 'netbox_token', variable: 'TOKEN')]) {
harness.set_env('netbox_token', TOKEN)
}
harness.set_env('netbox_devices_tag','active')

//update first the agent with the required deps
harness.set_required_agent(["sdg-nuc-01","sdg-nuc-02"])
harness.update_agents()
Expand All @@ -36,11 +28,11 @@ lock(label: 'adgt_test_harness_boards') {
harness.set_nebula_debug(true)
harness.set_enable_docker(true)
harness.set_docker_host_mode(true)
harness.set_send_telemetry(true)
harness.set_send_telemetry(false)
harness.set_log_artifacts(false)
harness.set_log_jira(false)
harness.set_enable_resource_queuing(true)
harness.set_elastic_server('192.168.10.11')
harness.set_elastic_server('primary.englab')
harness.set_docker_args(['Vivado'])
harness.set_nebula_local_fs_source_root("artifactory.analog.com")

Expand Down
9 changes: 8 additions & 1 deletion adi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
from adi.ad4110 import ad4110
from adi.ad4130 import ad4130
from adi.ad4630 import ad4630
from adi.ad4858 import ad4858
from adi.ad5592r import ad5592r
from adi.ad5686 import ad5686
from adi.ad5754r import ad5754r
from adi.ad5940 import ad5940
from adi.ad6676 import ad6676
from adi.ad7124 import ad7124
Expand All @@ -26,6 +28,8 @@
from adi.ad9081 import ad9081
from adi.ad9081_mc import QuadMxFE, ad9081_mc
from adi.ad9083 import ad9083
from adi.ad9084 import ad9084
from adi.ad9084_mc import Triton, ad9084_mc
from adi.ad9094 import ad9094
from adi.ad9136 import ad9136
from adi.ad9144 import ad9144
Expand All @@ -49,6 +53,7 @@
from adi.adf5610 import adf5610
from adi.adg2128 import adg2128
from adi.adis16460 import adis16460
from adi.adis16475 import adis16475
from adi.adis16495 import adis16495
from adi.adis16507 import adis16507
from adi.adl5240 import adl5240
Expand All @@ -71,7 +76,9 @@
from adi.cn0511 import cn0511
from adi.cn0532 import cn0532
from adi.cn0554 import cn0554
from adi.cn0566 import CN0566
from adi.cn0575 import cn0575
from adi.cn0579 import cn0579
from adi.daq2 import DAQ2
from adi.daq3 import DAQ3
from adi.fmc_vna import fmcvna
Expand Down Expand Up @@ -101,5 +108,5 @@
except ImportError:
pass

__version__ = "0.0.16"
__version__ = "0.0.17"
name = "Analog Devices Hardware Interfaces"
206 changes: 206 additions & 0 deletions adi/ad4858.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# Copyright (C) 2020-2023 Analog Devices, Inc.
#
# SPDX short identifier: ADIBSD

from decimal import Decimal

import numpy as np
from adi.attribute import attribute
from adi.context_manager import context_manager
from adi.rx_tx import rx


class ad4858(rx, context_manager):

""" AD4858 ADC """

_complex_data = False
channel = [] # type: ignore
_device_name = ""

def __init__(self, uri="", device_name=""):
"""Constructor for ad4858 class."""
context_manager.__init__(self, uri, self._device_name)

compatible_parts = ["ad4858"]

self._ctrl = None

if not device_name:
device_name = compatible_parts[0]
else:
if device_name not in compatible_parts:
raise Exception(f"Not a compatible device: {device_name}")

# Select the device matching device_name as working device
for device in self._ctx.devices:
if device.name == device_name:
self._ctrl = device
self._rxadc = device
break

if not self._ctrl:
raise Exception("Error in selecting matching device")

if not self._rxadc:
raise Exception("Error in selecting matching device")

for ch in self._ctrl.channels:
name = ch._id
self._rx_channel_names.append(name)
self.channel.append(self._channel(self._ctrl, name))

rx.__init__(self)

@property
def sampling_frequency(self):
"""Get sampling frequency."""
return self._get_iio_dev_attr("sampling_frequency")

@sampling_frequency.setter
def sampling_frequency(self, value):
"""Set sampling frequency."""
self._set_iio_dev_attr("sampling_frequency", value)

@property
def oversampling_ratio_avail(self):
"""Get list of all available oversampling rates."""
return self._get_iio_dev_attr_str("oversampling_ratio_available")

@property
def oversampling_ratio(self):
"""Get oversampling ratio."""
return self._get_iio_dev_attr_str("oversampling_ratio")

@oversampling_ratio.setter
def oversampling_ratio(self, value):
"""Set oversampling ratio."""
if value in self.oversampling_ratio_avail:
self._set_iio_dev_attr_str("oversampling_ratio", value)
else:
raise ValueError(
"Error: oversampling ratio not supported \nUse one of: "
+ str(self.oversampling_ratio_avail)
)

@property
def packet_format_avail(self):
"""Get list of all available packet formats."""
return self._get_iio_dev_attr_str("packet_format_available")

@property
def packet_format(self):
"""Get packet format."""
return self._get_iio_dev_attr_str("packet_format")

@packet_format.setter
def packet_format(self, value):
"""Set packet format."""
if value in self.packet_format_avail:
self._set_iio_dev_attr_str("packet_format", value)
else:
raise ValueError(
"Error: packet format not supported \nUse one of: "
+ str(self.packet_format_avail)
)

class _channel(attribute):

""" ad4858 channel """

def __init__(self, ctrl, channel_name):
self.name = channel_name
self._ctrl = ctrl

@property
def raw(self):
"""Get channel raw value."""
return self._get_iio_attr(self.name, "raw", False)

@property
def scale(self):
"""Get channel scale."""
return self._get_iio_attr(self.name, "scale", False)

@scale.setter
def scale(self, value):
"""Set channel scale."""
self._set_iio_attr(self.name, "scale", False, Decimal(value).real)

@property
def offset(self):
"""Get channel offset."""
return self._get_iio_attr(self.name, "offset", False)

@offset.setter
def offset(self, value):
"""Set channel offset."""
self._set_iio_attr(self.name, "offset", False, value)

@property
def calibbias(self):
"""Get calibration bias/offset value."""
return self._get_iio_attr(self.name, "calibbias", False)

@calibbias.setter
def calibbias(self, value):
"""Set channel calibration bias/offset."""
self._set_iio_attr(self.name, "calibbias", False, value)

@property
def calibphase(self):
"""Get calibration phase value."""
return self._get_iio_attr(self.name, "calibphase", False)

@calibphase.setter
def calibphase(self, value):
"""Set channel calibration phase."""
self._set_iio_attr(self.name, "calibphase", False, value)

@property
def hardwaregain(self):
"""Get calibration gain value."""
return self._get_iio_attr(self.name, "hardwaregain", False)

@hardwaregain.setter
def hardwaregain(self, value):
"""Set channel calibration gain."""
self._set_iio_attr(self.name, "hardwaregain", False, value)

@property
def softspan_avail(self):
"""Get list of all available softspans."""
return self._get_iio_attr_str(self.name, "softspan_available", False)

@property
def softspan(self):
"""Get softspan value."""
return self._get_iio_attr_str(self.name, "softspan", False)

@softspan.setter
def softspan(self, value):
"""Set softspan value."""
if value in self.softspan_avail:
self._set_iio_attr(self.name, "softspan", False, value)
else:
raise ValueError(
"Error: softspan not supported \nUse one of: "
+ str(self.softspan_avail)
)

def to_volts(self, index, val):
"""Converts raw value to SI."""
_scale = self.channel[index].scale

ret = None

if isinstance(val, np.int32):
ret = val * _scale

if isinstance(val, np.ndarray):
ret = [x * _scale for x in val]

if ret is None:
raise Exception("Error in converting to actual voltage")

return ret
Loading

0 comments on commit 7c05d6d

Please sign in to comment.