Performing DAQmx Device Reset or Self-Test Programmatically

Updated Aug 20, 2018

Reported In


  • LabVIEW Full
  • LabVIEW Base
  • LabVIEW Professional
  • LabWindows/CVI Full
  • LabWindows/CVI Base

Programming Language

  • C# .NET
  • Visual Basic .NET

Issue Details

I want to programmatically perform a device self-test or reset, similar to that available in Measurement & Automation Explorer (MAX), but I cannot find the corresponding functions. Where can I find these functions and how should I implement a reset or self-test in my program?


Function Location

In NI-DAQmx 8.9 and later you can use the DAQmx Self-Test Device function or the DAQmx Reset function in LabVIEW. You can also call similar DAQmx Reset and Self-test functions through our support for LabWindows/CVI or ANSI C, and .NET with C# or Visual Basic.


The DAQmx Reset VI and Self-Test functions are located in the Hardware Interfaces»NI-DAQmx»Device Configuration palette on the Diagram.


DAQmx Driver:
The DAQmx Reset VI and Self-Test functions are located in the Measurement I/O»NI-DAQmx»Dev Config palette on the Block Diagram. ​​

Traditional DAQ Driver:
​The Device Reset function is located in the Measurement I/O»Data Acquisition»Calibration and Configuration palette on the Block Diagram.

LabWindows/CVI & ANSI C: 

The DAQmx Reset and Self-test functions can be found in Libraries»NI-DAQmx Library»Advanced»Device Control. 

DAQmx Reset: 
Function prototype: int32 DAQmxResetDevice (const char deviceName[]) 
Example: int errorResult = DAQmxResetDevice("Dev1");

DAQmx Self-Test: 
Function prototype: int32 DAQmxSelfTestDevice (const char deviceName[]) 
Example: int selfTestResult = DAQmxSelfTestDevice("Dev1");

C# .NET:

To perform a DAQmx reset or self-test in C# you must first have a Device object for your DAQ device and then you can call the reset or self-test functions on the Device object.

DAQmx Reset:
Function prototype: void Device.Reset();
   Device dev = DaqSystem.Local.LoadDevice("Dev1");

DAQmx Self-Test:
Function prototype: void Device.SelfTest();
   Device dev = DaqSystem.Local.LoadDevice("Dev1");

Visual Basic. NET:

Similar to C# .NET, to perform a DAQmx reset or self-test in Visual Basic. NET you need a Device object to call the reset and self-test functions.

DAQmx Reset:
Function prototype: Public Sub Reset()
   Dim dev As Device = DaqSystem.Local.LoadDevice("Dev1")

DAQmx Self-Test:
Function prototype: Public Sub SelfTest()
   Dim dev As Device = DaqSystem.Local.LoadDevice("Dev1")


Function Implementation

The Reset Device function is usually used at the beginning or end of a program. If the Reset Device is used in the middle of a program it will immediately abort all active tasks associated with a device, disconnect any routes, and return the device to an initialized state. Aborting a task immediately terminates the currently active operation, such as a read or a write. Aborting a task puts the task into an unstable but recoverable state. To recover the task in NI-DAQmx, use DAQmx Start to restart the task or use DAQmx Stop to reset the task without starting it. The reset process is asynchronous and the function returns before reset completion. For more information on these functions please see the NI-DAQmx help files.

Additional Information

While there is no Self-Test VI or function in NI-DAQmx prior to 8.9, using the Reset Device function is another option. It provides roughly the same, and slightly more extensive, functionality as the Self-Test in MAX. This reset is a good option to add to the beginning of code in the case that you are aborting or crashing your application and therefore unable to gracefully close and release references. 


Not Helpful