Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

[Solved] Reset DAQ system from .NET application

Sometimes when my .NET application calls Task.AddGlobalChannel I get this error:

Device cannot be accessed.  Possible causes:

Device is no longer present in the system.
Device is not powered.
Device is powered, but was temporarily without power.
Device is damaged.

Ensure the device is properly connected and powered.  Turn the computer off and on again.  If you suspect that the device is damaged, contact National Instruments at ni.com/support.

Device Specified: cDAQ9188-1B57846Mod1

Task Name: _unnamedTask<0>

Status Code: -201003

This only occurs after my computer has been in sleep/hibernation. The solution is to click the Reset button in NI MAX. My question is however: How do I perform this reset programatically?

 

I have checked daqMX.DaqSystem.Local for any possible functions, but none seems to do what I need.

Linus Nilsson
Message 1 of 2
(3,261 Views)

Soon after I posted the question I found the answer (as usual...):

 

* Iterate through the DAQmx.DaqSystem.Local.Devices array until the right device is found.

* Load the device using DAQmx.DaqSystem.Local.LoadDevice.

* Call .Reset() on the device.

            'Look for the device
            Dim devs() As String = DAQmx.DaqSystem.Local.Devices
            Dim daqDev As DAQmx.Device = Nothing
            For Each dev As String In devs
                If dev = "myDeviceName" Then
                    daqDev = DAQmx.DaqSystem.Local.LoadDevice(dev)
                End If
            Next

            If daqDev Is Nothing Then
                Throw New Exception("Could not find DAQ device")
            End If

            'Reset device
            daqDev.Reset()

I have not figured out how to actually know when the reset is done though...

Linus Nilsson
0 Kudos
Message 2 of 2
(3,255 Views)