diff --git a/examples/adxl345_example.py b/examples/adxl345_example.py
index 03f643568..d58d6165a 100644
--- a/examples/adxl345_example.py
+++ b/examples/adxl345_example.py
@@ -2,37 +2,55 @@
#
# SPDX short identifier: ADIBSD
+import argparse
import time
import adi
+# Optionally pass URI as command line argument with -u option,
+# else use default to "ip:analog.local"
+parser = argparse.ArgumentParser(description="ADXL345 Example Script")
+parser.add_argument(
+ "-u",
+ default=["ip:analog.local"],
+ help="-u (arg) URI of target device's context, eg: 'ip:analog.local',\
+ 'ip:192.168.2.1',\
+ 'serial:COM4,115200,8n1n'",
+ action="store",
+ nargs="*",
+)
+args = parser.parse_args()
+my_uri = args.u[0]
+
+print("uri: " + str(my_uri))
+
# Set up ADXL345
-myacc = adi.adxl345(uri="ip:192.168.1.232")
-myacc.rx_output_type = "SI"
-myacc.rx_buffer_size = 4
-myacc.rx_enabled_channels = [0, 1, 2]
+my_acc = adi.adxl345(uri=my_uri)
+my_acc.rx_output_type = "SI"
+my_acc.rx_buffer_size = 4
+my_acc.rx_enabled_channels = [0, 1, 2]
-sfa = myacc.sampling_frequency_available
+sfa = my_acc.sampling_frequency_available
print("Sampling frequencies available:")
print(sfa)
-print("\nX acceleration: " + str(myacc.accel_x.raw))
-print("Y acceleration: " + str(myacc.accel_y.raw))
-print("Z acceleration: " + str(myacc.accel_z.raw))
+print("\nX acceleration: " + str(my_acc.accel_x.raw))
+print("Y acceleration: " + str(my_acc.accel_y.raw))
+print("Z acceleration: " + str(my_acc.accel_z.raw))
-print("\nSample rate: " + str(myacc.sampling_frequency))
+print("\nSample rate: " + str(my_acc.sampling_frequency))
print("Setting sample rate to 12.5 sps...")
-myacc.sampling_frequency = 12.5
+my_acc.sampling_frequency = 12.5
time.sleep(0.25)
-print("new sample rate: " + str(myacc.sampling_frequency))
-myacc.sampling_frequency = 100.0 # Set back to default
+print("new sample rate: " + str(my_acc.sampling_frequency))
+my_acc.sampling_frequency = 100.0 # Set back to default
print("\nData using unbuffered rx(), SI (m/s^2):")
-print(myacc.rx())
+print(my_acc.rx())
-myacc.rx_output_type = "raw"
+my_acc.rx_output_type = "raw"
print("\nData using unbuffered rx(), raw:")
-print(myacc.rx())
+print(my_acc.rx())
-del myacc
+del my_acc
diff --git a/examples/adxl355_example.py b/examples/adxl355_example.py
index 0bd0649a9..3e8aa3370 100644
--- a/examples/adxl355_example.py
+++ b/examples/adxl355_example.py
@@ -2,95 +2,141 @@
#
# SPDX short identifier: ADIBSD
-import sys
+import argparse
import time
import adi
-# 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
+# Optionally pass URI as command line argument with -u option,
+# else use default to "ip:analog.local"
+parser = argparse.ArgumentParser(description="ADXL355 Example Script")
+parser.add_argument(
+ "-u",
+ default=["ip:analog.local"],
+ help="-u (arg) URI of target device's context, eg: 'ip:analog.local',\
+ 'ip:192.168.2.1',\
+ 'serial:COM4,115200,8n1n'",
+ action="store",
+ nargs="*",
+)
+args = parser.parse_args()
+my_uri = args.u[0]
+
print("uri: " + str(my_uri))
# Set up ADXL355
-myacc = adi.adxl355(uri=my_uri)
-myacc.rx_buffer_size = 32
-myacc.rx_enabled_channels = [0, 1, 2]
+my_acc = adi.adxl355(uri=my_uri)
+my_acc.rx_buffer_size = 32
+my_acc.rx_enabled_channels = [0, 1, 2]
print("\nChecking temperature channel...")
-print("Temperature raw: " + str(myacc.temp.raw))
-print("Calculated Temperature: " + str(myacc.to_degrees(myacc.temp.raw)))
+print("Temperature raw: " + str(my_acc.temp.raw))
+print("Calculated Temperature: " + str(my_acc.to_degrees(my_acc.temp.raw)))
-print("\nCurrent Timestamp: " + str(myacc.current_timestamp_clock))
+# print("\nCurrent Timestamp: " + str(my_acc.current_timestamp_clock))
+# Not enabled as of Kuiper 2022_r2, and not implemented in no-OS
-sfa = myacc.accel_x.sampling_frequency_available
+sfa = my_acc.accel_x.sampling_frequency_available
print("\nSampling frequencies available:")
print(sfa)
print("\nInitial sample frequency:")
-print("X Sample frequency: " + str(myacc.accel_x.sampling_frequency))
-print("Y Sample frequency: " + str(myacc.accel_y.sampling_frequency))
-print("Z Sample frequency: " + str(myacc.accel_z.sampling_frequency))
+print("X Sample frequency: " + str(my_acc.accel_x.sampling_frequency))
+print("Y Sample frequency: " + str(my_acc.accel_y.sampling_frequency))
+print("Z Sample frequency: " + str(my_acc.accel_z.sampling_frequency))
-print("Single raw acceleration values:")
-print("\nX acceleration: " + str(myacc.accel_x.raw * myacc.accel_x.scale) + " m/s^2")
-print("Y acceleration: " + str(myacc.accel_y.raw * myacc.accel_y.scale) + " m/s^2")
-print("Z acceleration: " + str(myacc.accel_z.raw * myacc.accel_z.scale) + " m/s^2")
+print("Single calculated acceleration values:")
+print("\nX acceleration: " + str(my_acc.accel_x.raw * my_acc.accel_x.scale) + " m/s^2")
+print("Y acceleration: " + str(my_acc.accel_y.raw * my_acc.accel_y.scale) + " m/s^2")
+print("Z acceleration: " + str(my_acc.accel_z.raw * my_acc.accel_z.scale) + " m/s^2")
print("\nSetting sample frequencies to 1000 sps...")
-myacc.accel_x.sampling_frequency = sfa[2]
-myacc.accel_y.sampling_frequency = sfa[2]
-myacc.accel_z.sampling_frequency = sfa[2]
+my_acc.accel_x.sampling_frequency = "{:.6f}".format(sfa[2])
+my_acc.accel_y.sampling_frequency = "{:.6f}".format(sfa[2])
+my_acc.accel_z.sampling_frequency = "{:.6f}".format(sfa[2])
time.sleep(0.25)
-print("Verifying new sample rate: " + str(myacc.accel_x.sampling_frequency))
+print("Verifying new sample rate: " + str(my_acc.accel_x.sampling_frequency))
print("Setting back to 4000 sps...")
-myacc.accel_x.sampling_frequency = 4000.0
-myacc.accel_y.sampling_frequency = 4000.0
-myacc.accel_z.sampling_frequency = 4000.0 # Set back to default
+my_acc.accel_x.sampling_frequency = "{:.6f}".format(4000.0)
+my_acc.accel_y.sampling_frequency = "{:.6f}".format(4000.0)
+my_acc.accel_z.sampling_frequency = "{:.6f}".format(4000.0)
time.sleep(0.25)
print("\nData using buffered rx(), SI (m/s^2):")
-myacc.rx_output_type = "SI"
-print(myacc.rx())
+my_acc.rx_output_type = "SI"
+print(my_acc.rx())
-myacc.rx_output_type = "raw"
+my_acc.rx_output_type = "raw"
print("\nData using buffered rx(), raw:")
-print(myacc.rx())
+print(my_acc.rx())
-cutoffs = myacc.accel_x.filter_high_pass_3db_frequency_available
-print("\nX available highpass cutoff frequencies: " + str(cutoffs))
+cutoffs = my_acc.accel_x.filter_high_pass_3db_frequency_available
+print("\nAvailable highpass cutoff frequencies: " + str(cutoffs))
print(
- "Setting highpass cutoff frequency to "
+ "\nSetting highpass cutoff frequency to "
+ str(cutoffs[1])
- + " then taking a nap to settle..."
+ + " then taking a 2 second nap to settle..."
)
-myacc.accel_x.filter_high_pass_3db_frequency = cutoffs[1]
-myacc.accel_y.filter_high_pass_3db_frequency = cutoffs[1]
-myacc.accel_z.filter_high_pass_3db_frequency = cutoffs[1]
+my_acc.accel_x.filter_high_pass_3db_frequency = "{:.6f}".format(cutoffs[1])
+my_acc.accel_y.filter_high_pass_3db_frequency = "{:.6f}".format(cutoffs[1])
+my_acc.accel_z.filter_high_pass_3db_frequency = "{:.6f}".format(cutoffs[1])
print(
"\nX highpass cutoff frequency: "
- + str(myacc.accel_x.filter_high_pass_3db_frequency)
+ + str(my_acc.accel_x.filter_high_pass_3db_frequency)
)
print(
- "Y highpass cutoff frequency: " + str(myacc.accel_y.filter_high_pass_3db_frequency)
+ "Y highpass cutoff frequency: " + str(my_acc.accel_y.filter_high_pass_3db_frequency)
)
print(
- "Z highpass cutoff frequency: " + str(myacc.accel_z.filter_high_pass_3db_frequency)
+ "Z highpass cutoff frequency: " + str(my_acc.accel_z.filter_high_pass_3db_frequency)
)
time.sleep(2.0)
-print("\nAccelerations after highpass, should be close to zero if the")
-print("ADXL355 is sitting still...")
-print("X acceleration: " + str(myacc.accel_x.raw))
-print("Y acceleration: " + str(myacc.accel_y.raw))
-print("Z acceleration: " + str(myacc.accel_z.raw))
-
-print("\nSetting highpass cutoff frequency back to zero...")
-myacc.accel_x.filter_high_pass_3db_frequency = 0.0000
-myacc.accel_y.filter_high_pass_3db_frequency = 0.0000
-myacc.accel_z.filter_high_pass_3db_frequency = 0.0000
-
-del myacc
+
+print(
+ "\nAccelerations after highpass, should be close to zero if the ADXL355 is sitting still...\n"
+)
+print("X acceleration: " + str(my_acc.accel_x.raw * my_acc.accel_x.scale) + " m/s^2")
+print("Y acceleration: " + str(my_acc.accel_y.raw * my_acc.accel_y.scale) + " m/s^2")
+print("Z acceleration: " + str(my_acc.accel_z.raw * my_acc.accel_z.scale) + " m/s^2")
+
+print(
+ "\nSetting highpass cutoff frequency back to zero, then taking a 4 second nap to settle..."
+)
+my_acc.accel_x.filter_high_pass_3db_frequency = "{:.6f}".format(0.0)
+my_acc.accel_y.filter_high_pass_3db_frequency = "{:.6f}".format(0.0)
+my_acc.accel_z.filter_high_pass_3db_frequency = "{:.6f}".format(0.0)
+
+time.sleep(4.0)
+
+print("\nAccelerations after highpass settling...")
+
+print("X acceleration: " + str(my_acc.accel_x.raw * my_acc.accel_x.scale) + " m/s^2")
+print("Y acceleration: " + str(my_acc.accel_y.raw * my_acc.accel_y.scale) + " m/s^2")
+print("Z acceleration: " + str(my_acc.accel_z.raw * my_acc.accel_z.scale) + " m/s^2")
+
+print("\nSetting offset for each axis...\n")
+print("X offset set to: " + str(my_acc.accel_x.raw >> 4))
+print("Y offset set to: " + str(my_acc.accel_y.raw >> 4))
+print("Z offset set to: " + str(my_acc.accel_z.raw >> 4))
+
+my_acc.accel_x.calibbias = "{:.6f}".format(my_acc.accel_x.raw >> 4)
+my_acc.accel_y.calibbias = "{:.6f}".format(my_acc.accel_y.raw >> 4)
+my_acc.accel_z.calibbias = "{:.6f}".format(my_acc.accel_z.raw >> 4)
+
+print(
+ "\nAccelerations after setting offset, should be close to zero if the ADXL355 is sitting still...\n"
+)
+print("X acceleration: " + str(my_acc.accel_x.raw * my_acc.accel_x.scale) + " m/s^2")
+print("Y acceleration: " + str(my_acc.accel_y.raw * my_acc.accel_y.scale) + " m/s^2")
+print("Z acceleration: " + str(my_acc.accel_z.raw * my_acc.accel_z.scale) + " m/s^2")
+
+print("\nSetting offset for each axis back to 0...")
+my_acc.accel_x.calibbias = "{:.6f}".format(0.0)
+my_acc.accel_y.calibbias = "{:.6f}".format(0.0)
+my_acc.accel_z.calibbias = "{:.6f}".format(0.0)
+
+del my_acc
diff --git a/examples/adxl355_no_os_example.py b/examples/adxl355_no_os_example.py
deleted file mode 100644
index 5895ba3b1..000000000
--- a/examples/adxl355_no_os_example.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# Copyright (C) 2022 Analog Devices, Inc.
-#
-# SPDX short identifier: ADIBSD
-
-import sys
-import time
-
-import adi
-
-# 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))
-
-# Set up ADXL355
-myacc = adi.adxl355(uri=my_uri)
-myacc.rx_buffer_size = 32
-myacc.rx_enabled_channels = [0, 1, 2]
-
-print("\nChecking temperature channel...")
-print("Temperature raw: " + str(myacc.temp.raw))
-print("Calculated Temperature: " + str(myacc.to_degrees(myacc.temp.raw)))
-
-sfa = myacc.accel_x.sampling_frequency_available
-print("\nSampling frequencies available:")
-print(sfa)
-
-print("\nInitial sample frequency:")
-print("X Sample frequency: " + str(myacc.accel_x.sampling_frequency))
-print("Y Sample frequency: " + str(myacc.accel_y.sampling_frequency))
-print("Z Sample frequency: " + str(myacc.accel_z.sampling_frequency))
-
-print("Single calculated acceleration values:")
-print("\nX acceleration: " + str(myacc.accel_x.raw * myacc.accel_x.scale) + " m/s^2")
-print("Y acceleration: " + str(myacc.accel_y.raw * myacc.accel_y.scale) + " m/s^2")
-print("Z acceleration: " + str(myacc.accel_z.raw * myacc.accel_z.scale) + " m/s^2")
-
-print("\nSetting sample frequencies to 1000 sps...")
-myacc.accel_x.sampling_frequency = "{:.6f}".format(sfa[2])
-myacc.accel_y.sampling_frequency = "{:.6f}".format(sfa[2])
-myacc.accel_z.sampling_frequency = "{:.6f}".format(sfa[2])
-time.sleep(0.25)
-
-print("Verifying new sample rate: " + str(myacc.accel_x.sampling_frequency))
-print("Setting back to 4000 sps...")
-myacc.accel_x.sampling_frequency = "{:.6f}".format(4000.0)
-myacc.accel_y.sampling_frequency = "{:.6f}".format(4000.0)
-myacc.accel_z.sampling_frequency = "{:.6f}".format(4000.0)
-time.sleep(0.25)
-
-print("\nData using buffered rx(), SI (m/s^2):")
-myacc.rx_output_type = "SI"
-print(myacc.rx())
-
-myacc.rx_output_type = "raw"
-print("\nData using buffered rx(), raw:")
-print(myacc.rx())
-
-cutoffs = myacc.accel_x.filter_high_pass_3db_frequency_available
-print("\nX available highpass cutoff frequencies: " + str(cutoffs))
-
-print(
- "Setting highpass cutoff frequency to "
- + str(cutoffs[1])
- + " then taking a nap to settle..."
-)
-myacc.accel_x.filter_high_pass_3db_frequency = "{:.6f}".format(cutoffs[1])
-myacc.accel_y.filter_high_pass_3db_frequency = "{:.6f}".format(cutoffs[1])
-myacc.accel_z.filter_high_pass_3db_frequency = "{:.6f}".format(cutoffs[1])
-
-print(
- "\nX highpass cutoff frequency: "
- + str(myacc.accel_x.filter_high_pass_3db_frequency)
-)
-print(
- "Y highpass cutoff frequency: " + str(myacc.accel_y.filter_high_pass_3db_frequency)
-)
-print(
- "Z highpass cutoff frequency: " + str(myacc.accel_z.filter_high_pass_3db_frequency)
-)
-
-time.sleep(2.0)
-print("X acceleration: " + str(myacc.accel_x.raw))
-print("Y acceleration: " + str(myacc.accel_y.raw))
-print("Z acceleration: " + str(myacc.accel_z.raw))
-
-print("\nSetting highpass cutoff frequency back to zero...")
-myacc.accel_x.filter_high_pass_3db_frequency = "{:.6f}".format(0.0)
-myacc.accel_y.filter_high_pass_3db_frequency = "{:.6f}".format(0.0)
-myacc.accel_z.filter_high_pass_3db_frequency = "{:.6f}".format(0.0)
-
-
-print("Setting offset for each axis...")
-print("\nX offset: " + str(myacc.accel_x.raw >> 4))
-print("Y offset: " + str(myacc.accel_y.raw >> 4))
-print("Z offset: " + str(myacc.accel_z.raw >> 4))
-
-myacc.accel_x.calibbias = "{:.6f}".format(myacc.accel_x.raw >> 4)
-myacc.accel_y.calibbias = "{:.6f}".format(myacc.accel_y.raw >> 4)
-myacc.accel_z.calibbias = "{:.6f}".format(myacc.accel_z.raw >> 4)
-
-print(
- "\nAccelerations after offset, should be close to zero if the ADXL355 is sitting still..."
-)
-print("\nX acceleration: " + str(myacc.accel_x.raw * myacc.accel_x.scale) + " m/s^2")
-print("Y acceleration: " + str(myacc.accel_y.raw * myacc.accel_y.scale) + " m/s^2")
-print("Z acceleration: " + str(myacc.accel_z.raw * myacc.accel_z.scale) + " m/s^2")
-
-print("\nSetting offset for each axis back to 0...")
-myacc.accel_x.calibbias = "{:.6f}".format(0.0)
-myacc.accel_y.calibbias = "{:.6f}".format(0.0)
-myacc.accel_z.calibbias = "{:.6f}".format(0.0)
-
-del myacc
diff --git a/examples/lm75_example.py b/examples/lm75_example.py
index 27a42e711..9cc16c436 100644
--- a/examples/lm75_example.py
+++ b/examples/lm75_example.py
@@ -2,13 +2,25 @@
#
# SPDX short identifier: ADIBSD
-import sys
+import argparse
import adi
-# 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
+# Optionally pass URI as command line argument with -u option,
+# else use default to "ip:analog.local"
+parser = argparse.ArgumentParser(description="LM75 Example Script")
+parser.add_argument(
+ "-u",
+ default=["ip:analog.local"],
+ help="-u (arg) URI of target device's context, eg: 'ip:analog.local',\
+ 'ip:192.168.2.1',\
+ 'serial:COM4,115200,8n1n'",
+ action="store",
+ nargs="*",
+)
+args = parser.parse_args()
+my_uri = args.u[0]
+
print("uri: " + str(my_uri))
# Set up LM75
diff --git a/test/emu/devices/adxl345.xml b/test/emu/devices/adxl345.xml
new file mode 100644
index 000000000..450815487
--- /dev/null
+++ b/test/emu/devices/adxl345.xml
@@ -0,0 +1 @@
+]>
\ No newline at end of file
diff --git a/test/emu/devices/lm75.xml b/test/emu/devices/lm75.xml
new file mode 100644
index 000000000..ab0322fe8
--- /dev/null
+++ b/test/emu/devices/lm75.xml
@@ -0,0 +1 @@
+]>
\ No newline at end of file
diff --git a/test/emu/hardware_map.yml b/test/emu/hardware_map.yml
index 888c62db0..e088bd9a9 100644
--- a/test/emu/hardware_map.yml
+++ b/test/emu/hardware_map.yml
@@ -307,12 +307,22 @@ adrv9375:
- iio:device4
- iio:device5
- iio:device6
+adxl345:
+ - adxl345
+ - pyadi_iio_class_support:
+ - adxl345
+ - emulate:
+ - filename: adxl345.xml
+ - data_devices:
+ - iio:device0
adxl355:
- adxl355
- - emulate:
- - filename: adxl355.xml
- pyadi_iio_class_support:
- adxl355
+ - emulate:
+ - filename: adxl355.xml
+ - data_devices:
+ - iio:device0
ad9434:
- axi-ad9434-core-lpc
- ad9517-4
@@ -521,3 +531,12 @@ ad7124-8:
- iio:device0
- pyadi_iio_class_support:
- ad7124
+
+lm75:
+ - lm75
+ - pyadi_iio_class_support:
+ - lm75
+ - emulate:
+ - filename: lm75.xml
+ - data_devices:
+ - hwmon0
\ No newline at end of file
diff --git a/test/test_adxl345.py b/test/test_adxl345.py
new file mode 100644
index 000000000..b4e00a551
--- /dev/null
+++ b/test/test_adxl345.py
@@ -0,0 +1,39 @@
+import pytest
+
+hardware = "adxl345"
+classname = "adi.adxl345"
+
+#########################################
+@pytest.mark.iio_hardware(hardware)
+@pytest.mark.parametrize("classname", [(classname)])
+@pytest.mark.parametrize("channel", [0, 1, 2])
+def test_adxl345_rx_data(test_dma_rx, iio_uri, classname, channel):
+ test_dma_rx(iio_uri, classname, channel, buffer_size=2 ** 5)
+
+
+#########################################
+@pytest.mark.iio_hardware(hardware)
+@pytest.mark.parametrize("classname", [(classname)])
+@pytest.mark.parametrize(
+ "attr, start, stop, step, tol, repeats, sub_channel",
+ [
+ ("calibbias", -300, 300, 100, 1, 3, "accel_x"),
+ ("calibbias", -300, 300, 100, 1, 3, "accel_y"),
+ ("calibbias", -300, 300, 100, 1, 3, "accel_z"),
+ ],
+)
+def test_adxl345_attr(
+ test_attribute_single_value,
+ iio_uri,
+ classname,
+ attr,
+ start,
+ stop,
+ step,
+ tol,
+ repeats,
+ sub_channel,
+):
+ test_attribute_single_value(
+ iio_uri, classname, attr, start, stop, step, tol, repeats, sub_channel
+ )