RFmx Wlan Python API Documentation
About
The nirfmx-python repository generates Python bindings (Application Programming Interface) for interacting with the NI-RFmx drivers.
nirfmx-python follows Python Software Foundation support policy for different versions.
Operating System Support
nirfmxwlan supports Windows systems where the supported drivers are installed. Refer to NI Hardware and Operating System Compatibility for which versions of the driver support your hardware on a given operating system.
Installation
You can use pip to download nirfmxwlan and install it.
$ python -m pip install nirfmxwlan
Support and Feedback
For support with Python API, hardware, the driver runtime or any other questions, please visit NI Community Forums.
Documentation:
Example:
import nirfmxinstr
import nirfmxwlan
import numpy
instr_session = None
wlan_signal = None
try:
# Create a new RFmx Session
instr_session = nirfmxinstr.Session(resource_name="RFSA", option_string="")
# Get WLAN Signal
wlan_signal = instr_session.get_wlan_signal_configuration()
# Configure measurement
instr_session.configure_frequency_reference(
selector_string="", frequency_reference_source="PXI_CLK",
frequency_reference_frequency=10e6
)
wlan_signal.configure_frequency(selector_string="", center_frequency=2.412e9)
wlan_signal.configure_reference_level(selector_string="", reference_level=0.0)
wlan_signal.configure_external_attenuation(selector_string="", external_attenuation=0.0)
wlan_signal.configure_iq_power_edge_trigger(
selector_string="",
iq_power_edge_source="0",
iq_power_edge_slope=nirfmxwlan.IQPowerEdgeTriggerSlope.RISING_SLOPE,
iq_power_edge_level=-20.0,
trigger_delay=0.0,
trigger_min_quiet_time_mode=nirfmxwlan.TriggerMinimumQuietTimeMode.AUTO,
trigger_min_quiet_time_duration=5.0e-6,
iq_power_edge_level_type=nirfmxwlan.IQPowerEdgeTriggerLevelType.RELATIVE,
enable_trigger=True,
)
wlan_signal.configure_standard(selector_string="",
standard=nirfmxwlan.Standard.STANDARD_802_11_AG)
wlan_signal.configure_channel_bandwidth(selector_string="", channel_bandwidth=20e6)
wlan_signal.select_measurements(selector_string="",
measurements=nirfmxwlan.MeasurementTypes.SEM, enable_all_traces=True)
wlan_signal.sem.configuration.configure_mask_type(selector_string="",
mask_type=nirfmxwlan.SemMaskType.STANDARD)
wlan_signal.sem.configuration.configure_averaging(
selector_string="",
averaging_enabled=nirfmxwlan.SemAveragingEnabled.FALSE,
averaging_count=10,
averaging_type=nirfmxwlan.SemAveragingType.RMS
)
wlan_signal.sem.configuration.configure_sweep_time(selector_string="",
sweep_time_auto=nirfmxwlan.SemSweepTimeAuto.TRUE, sweep_time_interval=1.0e-3)
wlan_signal.sem.configuration.configure_span(selector_string="",
span_auto=nirfmxwlan.SemSpanAuto.TRUE, span=66.0e6)
error_code = wlan_signal.initiate(selector_string="", result_name="")
# Retrieve results
measurement_status, error_code = wlan_signal.sem.results.fetch_measurement_status(
selector_string="", timeout=10.0)
absolute_power, relative_power, error_code = (
wlan_signal.sem.results.fetch_carrier_measurement(selector_string="", timeout=10.0)
)
(
lower_offset_measurement_status,
lower_offset_margin,
lower_offset_margin_frequency,
lower_offset_margin_absolute_power,
lower_offset_margin_relative_power,
error_code,
) = wlan_signal.sem.results.fetch_lower_offset_margin_array
(selector_string="", timeout=10.0)
(
upper_offset_measurement_status,
upper_offset_margin,
upper_offset_margin_frequency,
upper_offset_margin_absolute_power,
upper_offset_margin_relative_power,
error_code,
) = wlan_signal.sem.results.fetch_upper_offset_margin_array
(selector_string="", timeout=10.0)
spectrum = numpy.empty(0, dtype=numpy.float32)
composite_mask = numpy.empty(0, dtype=numpy.float32)
(
x0,
dx,
error_code
) = wlan_signal.sem.results.fetch_spectrum
(selector_string="", timeout=10.0, spectrum=spectrum, composite_mask=composite_mask)
# Print Results
print(f"Measurement Status : {measurement_status}")
print(f"Carrier Absolute Power (dBm) : {absolute_power}\n")
print("----------Lower Offset Measurements----------\n")
for i in range(len(lower_offset_margin)):
print(f"Offset {i}")
print(f"Measurement Status : {lower_offset_measurement_status[i]}")
print(f"Margin (dB) : {lower_offset_margin[i]}")
print(f"Margin Frequency (Hz) : {lower_offset_margin_frequency[i]}")
print(f"Margin Absolute Power (dBm) : {lower_offset_margin_absolute_power[i]}\n")
print("\n----------Upper Offset Measurements----------\n")
for i in range(len(upper_offset_margin)):
print(f"Offset {i}")
print(f"Measurement Status : {upper_offset_measurement_status[i]}")
print(f"Margin (dB) : {upper_offset_margin[i]}")
print(f"Margin Frequency (Hz) : {upper_offset_margin_frequency[i]}")
print(f"Margin Absolute Power (dBm) : {upper_offset_margin_absolute_power[i]}\n")
except Exception as e:
print("ERROR: " + str(e))
finally:
# Close session
if wlan_signal is not None:
wlan_signal.dispose()
wlan_signal = None
if instr_session is not None:
instr_session.close()
instr_session = None
Additional Documentation
Refer to the NI-RFmx User Manual for an overview of NI-RFmx, system requirements, troubleshooting, key concepts, etc.
License
This project is licensed under the MIT License. While the source code is not publicly released, the license permits binary distribution with attribution.
Note: This Python driver depends on several third-party components that are subject to separate commercial licenses. Users are responsible for ensuring they have the appropriate rights and licenses to use those dependencies in their environments.