Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary write access request when trying to read a property #2031

Closed
Arkh42 opened this issue Nov 20, 2023 · 5 comments
Closed

Unnecessary write access request when trying to read a property #2031

Arkh42 opened this issue Nov 20, 2023 · 5 comments

Comments

@Arkh42
Copy link

Arkh42 commented Nov 20, 2023

Description of issue

When I try to read the current_limit property, I get an error related to the current_limit_range property, as if I were trying to write the value.

System report

E           nidcpower.errors.DriverError: -1074097882: Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.
E
E           Device: PXI1Slot2
E           Requested Value: 1.0e-3
E           Minimum Value: 100.0e-9
E           Maximum Value: 10.0e-6
E           Property: Current Limit
E           Channel Name: 0
E
E           Property: Current Limit Range
E           Corresponding Value: 10.0e-6
E
E           Property: Current Limit Autorange
E           Corresponding Value: Off
E
E           Property: Overranging Enabled
E           Corresponding Value: false

Steps to reproduce issue

``` python
import pytest

import nidcpower

@pytest.fixture
def smu() -> nidcpower.Session:
    return nidcpower.Session(
        resource_name="PXI1Slot2",
        channels=None,
        reset=True,
        options={'range_check': True,
                 'simulate': True,
                 'driver_setup': {'Model': '4163', 'BoardType': 'PXIe'}},
        independent_channels=True)

def test_default(smu):

    assert isinstance(smu.current_limit, float)

def test_lower_limit_range(smu):

    # Set a lower limit range to verify the error
    smu.current_limit_range = 10e-6

    assert isinstance(smu.current_limit, float)

def test_upper_limit_range(smu):

    # Set an upper limit range to verify the error
    smu.current_limit_range = 10e-3

    assert isinstance(smu.current_limit, float)
```
  1. Run pytest on the above script.
  2. The first test fails because a nidcpower.errors.DriverError is raised.
  3. The second test fails because a nidcpower.errors.DriverError is raised.
  4. The third test passes, proving that read-access to current limit is equivalent to a write-access, which should not be the case.
@Arkh42 Arkh42 changed the title Unnecessary rite access request when trying to read a property Unnecessary write access request when trying to read a property Nov 20, 2023
@Arkh42
Copy link
Author

Arkh42 commented Nov 20, 2023

I tested with the voltage_limit property: it is working properly, contrary to current_limit.

@marcoskirsch
Copy link
Member

marcoskirsch commented Nov 20, 2023

I don’t believe this is a bug within the nidcpower Python module, rather the underlying behavior of the driver runtime. You’d get the same results from LabVIEW or C or C#.

What is the model of the SMU you run this on?
What is the version of the NI-DCPower driver runtime you installed?
What operating system are you using this with?

@Arkh42
Copy link
Author

Arkh42 commented Nov 20, 2023

What is the model of the SMU you run this on?

The PXIe-4163.

What is the version of the NI-DCPower driver runtime you installed?

See the snapshot attached for the whole list. All packages are version 2023 Q4 Patch 1.

image

What operating system are you using this with?

Windows 10.

@Arkh42
Copy link
Author

Arkh42 commented Nov 21, 2023

In "NI DC Power Supplies and SMUs Help", I found the following:

Accessing Attributes

[...]

Setting Properties and Attributes Before Reading Them

Properties and attributes are modified when you set them or when you call a configuration VI or function that sets them, respectively. It is important to set the properties or attributes or call any configuration VIs or functions before reading back any property or attribute values for the following reasons:

  • [...]
  • The driver verifies that the configuration of the session is valid at the time the property or attribute is read. It is possible to get an error when reading a property or attribute if the configuration is not valid at that point**, even when a setting later could make it valid.
  • [...]

Could that be the reason for which a read-access operation in the above script raises an error, even though I am just trying to check the type of the returned variable?

@marcoskirsch
Copy link
Member

marcoskirsch commented Nov 22, 2023

Yes. Getting (reading) a property causes what is known as a "verify" operation, which looks at all the session's properties to confirm they are in a valid configuration, and raises if this is not the case. In your code, you get a property in order to see its type, but it doesn't really matter to the driver what your intent for getting the property is.

There are several reasons why the driver only looks at valid property values when the "verify" occurs, one example is to avoid ordering requirements on how you need to set properties.

Closing this since it isn't a bug in the nidcpower module, nor in the NI-DCPower driver runtime for that matter.

@marcoskirsch marcoskirsch reopened this Nov 22, 2023
@marcoskirsch marcoskirsch closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants