Skip to content

Importing examplesMaxConfig.ini causes calculated-power example acceptance test to fail #1015

Description

@karhin1990

Bug Report

Importing the optional examplesMaxConfig.ini causes the calculated-power shipping example acceptance test to fail.

That configuration defines Dev1 as a PCIe-6363, while calculated_power_acq_int_clk.py uses Dev1/ai0 and Dev1/ai1 but requires a PXIe-4311. The acceptance test verifies only that Dev1 and its physical channels exist, so it runs the example without checking whether the device supports calculated-power measurements. DAQmx then returns error -200431.

Without examplesMaxConfig.ini, Dev1 is absent and the test is skipped. The test should account for required device capabilities, or the example/configuration device naming should be adjusted.

Repro or Code Sample

Refer to the Testing section on CONTRIBUTING.md. Import tests\max_config\examplesMaxConfig.ini then run poetry run pytest.

Expected Behavior

The pytest should be passing.

Current Behavior

Pytest failed with following error message:

========================================================================== FAILURES ===========================================================================
________________________________________ test___shipping_example___run___no_errors[library_init_kwargs-example_path10] ________________________________________

example_path = WindowsPath('C:/Development/nidaqmx-python/examples/analog_in/calculated_power_acq_int_clk.py')
system = <nidaqmx.system.system.System object at 0x000001CFA2CFF280>

    @pytest.mark.parametrize("example_path", EXAMPLE_PATHS)
    @pytest.mark.library_only(reason="The examples don't support gRPC.")
    def test___shipping_example___run___no_errors(example_path: Path, system):
        example_source = example_path.read_text()
        for device_name in _find_device_names(example_source):
            if device_name not in system.devices:
                pytest.skip(f"Cannot find device {device_name}.")
            device = system.devices[device_name]
            for physical_channel_name in _find_physical_channel_names(example_source, device_name):
                if not _has_physical_channel(device, physical_channel_name):
                    pytest.skip(
                        f"Device {device_name} does not have physical channel {physical_channel_name}"
                    )
        if example_path.name in ["read_freq.py", "read_pulse_freq.py"]:
            pytest.skip("Example times out if there is no signal.")
        if example_path.name in [
            "voltage_acq_int_clk_dig_start_ref.py",
            "voltage_acq_int_clk_dig_ref.py",
        ]:
            pytest.skip("Example times out if there is no trigger signal.")
        if re.search(r"\binput\(|\bKeyboardInterrupt\b", example_source):
            pytest.skip("Example waits for keyboard input.")
        if re.search(r"\bmatplotlib\b", example_source):
            pytest.skip("Example plots waveform.")
        if re.search(r"\bnptdms\b", example_source):
            pytest.skip("Example performs TDMS logging.")
        if example_path.name == "nidaqmx_warnings.py":
            # Ignore warnings from this example.
            context_manager: contextlib.AbstractContextManager = warnings.catch_warnings(record=True)
        else:
            context_manager = contextlib.nullcontext()

        with context_manager:
>           runpy.run_path(str(example_path))

tests\acceptance\test_examples.py:51:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<frozen runpy>:291: in run_path
    ???
<frozen runpy>:98: in _run_module_code
    ???
<frozen runpy>:88: in _run_code
    ???
examples\analog_in\calculated_power_acq_int_clk.py:15: in <module>
    task.ai_channels.add_ai_calculated_power_chan(
generated\nidaqmx\task\collections\_ai_channel_collection.py:378: in add_ai_calculated_power_chan
    self._interpreter.create_ai_calculated_power_chan(
generated\nidaqmx\_library_interpreter.py:720: in create_ai_calculated_power_chan
    self.check_for_error(error_code)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <nidaqmx._library_interpreter.LibraryInterpreter object at 0x000001CFA2CFFFD0>, error_code = -200431, samps_per_chan_written = None
samps_per_chan_read = None

    def check_for_error(self, error_code, samps_per_chan_written=None, samps_per_chan_read=None):
        if not error_code:
            return

        if error_code < 0:
            extended_error_info = self.get_extended_error_info()

            if samps_per_chan_read is not None:
                raise DaqReadError(extended_error_info, error_code, samps_per_chan_read)
            elif samps_per_chan_written is not None:
                raise DaqWriteError(extended_error_info, error_code, samps_per_chan_written)
            else:
>               raise DaqError(extended_error_info, error_code)
E               nidaqmx.errors.DaqError: Selected physical channel does not support the measurement type required by the virtual channel you are creating.
E
E               Create a channel of a measurement type that is supported by the physical channel, or select a physical channel that supports the measurement type.
E
E               Property: DAQmx_AI_MeasType
E               Requested Value: DAQmx_Val_Calculated_Power
E               Possible Values: DAQmx_Val_Current, DAQmx_Val_Resistance, DAQmx_Val_Strain_Gage, DAQmx_Val_Temp_BuiltInSensor, DAQmx_Val_Temp_RTD, DAQmx_Val_Temp_Thrmstr, DAQmx_Val_Temp_TC, DAQmx_Val_Voltage, DAQmx_Val_Voltage_CustomWithExcitation
E
E               Task Name: _unnamedTask<8>
E
E               Status Code: -200431

generated\nidaqmx\_library_interpreter.py:7271: DaqError

Possible Solution

Update the shipping-example acceptance test (test_examples.py) to detect calls to add_ai_calculated_power_chan and verify that the referenced device advertises UsageTypeAI.CALCULATED_POWER in device.ai_meas_types. Skip the example with a clear reason when unsupported.

device = system.devices[device_name]

if (
    "add_ai_calculated_power_chan" in example_source
    and nidaqmx.constants.UsageTypeAI.CALCULATED_POWER not in device.ai_meas_types
):
    pytest.skip(f"Device {device_name} does not support calculated power.")

This preserves Dev1 as the PCIe-6363 required by other examples while preventing calculated-power examples from running on an incompatible device.

Also, we would add a PXIe-4311 to examplesMaxConfig.ini under a recognizable name such as PXI1Slot4, then update the example to use:

voltage_physical_channel="PXI1Slot4/ai0",
current_physical_channel="PXI1Slot4/ai1",

Context

I would like to contribute to this repo, thus following the CONTRIBUTING.md to run regression test before start development.

Your Environment

  • Operating system and version: Windows 11 24H2
  • NI-DAQmx version: 2026 Q3
  • nidaqmx-python version: 1.7.0
  • Python version: 3.11.9

AB#4050189

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions