Why am I getting a 'NoneType' object after calling self-test method using nimi Python modules

Updated May 26, 2023

Reported In

Other

  • NI-DCPower (Python module: nidcpower)
  • NI-Digital Pattern Driver (Python module: nidigital)
  • NI-DMM (Python module: nidmm)
  • NI-FGEN (Python module: nifgen)
  • NI-ModInst (Python module: nimodinst)
  • NI-SCOPE (Python module: niscope)
  • NI Switch Executive (Python module: nise)
  • NI-SWITCH (Python module: niswitch)
  • NI-TClk (Python module: nitclk)

Issue Details

From the nimi Python modules documentation ,  if we take niswitch module for example; when I refer to the section talking about the 'self-test' method, thereis a table saying that Self-Test Code 0 represents Passed self-test, while code 1 represents Failed self-test.
Please refer to the screenshot below for details:
self-test.JPG


However, when I invoke this method in my Python code, it is the 'NoneType' that returned from this method. Why is this happening and is it normal? on the other hand, if it's indeed returnning NoneType, how do I know if there is an error during the self-test procedure?

Solution

It is normal that the method is returnning the NoneType to its caller.
Whether the self-test code is 0 or 1 is checked within the Self-Test method.

For example, you could refer to the implementation of this method (please feel free to take a look at the souce code as it's an opensource project of nimi Pyhton modules), or the Python code snippet below:
    @ivi_synchronized
    def self_test(self):
        code, msg = self._self_test()
        if code:
            raise errors.SelfTestError(code, msg)
        return None

you may find out the variable 'code' is checked by the if statement to determine the behavior based on the self-test code; in addition, if you would like to know whether there is an error during the self-test proceudre, you could try to catch the SelfTestError object by except syntax for further steps to take in your code.
For example:
try: 
      self_test()
except SelfTestError:
      """
       your action upon catching the self-test error.
      """
      pass

Additional Information

NI Modular Instruments Python Documentation
nimi-Python Github repository