09-11-2017 09:38 PM
Using cDAQ-9184 with 9205 module
Set DAQ IP address to 192.168.1.20 and PC NIC to 192.168.1.11
REPRO STEPS
* Find 9205 via NI-MAX and set alias to DAQ1_Slot1
* Connect to it via C# code successfully and log data samples
* Reboot the PC leaving the 9184 and 9205 powered up
* Re run the same exact C# code
EXPECTED
* C# code connects to the device successfully as before
* Device shows up as connected in NI MAX
ACTUAL
* C# code fails to connect
* Device shows up as dis-connected in NI MAX
RECOVERY
* Manually remove and then re-add the device using NI-MAX
* Now the code works
PROBLEM
This is an unacceptable situation. The PC is a headless device that needs to be able to recover in the case of power failure or other reboot cause.
What is causing this problem and is there a way to reconnect programmatically? Either in my C# code or some other automated tool?
Solved! Go to Solution.
09-12-2017 01:31 PM
Hi cmz,
would it be possible for you to post the initialize portions of your code so we can see how you're trying to add the device?
My first inclination would be to add the steps you've taken in MAX, to your C# code. I've included a link with instructions for performing a reset/self-test in C#. You could include this to the setup portion of your code and see if that helps.
How Can I Perform a Reset/Self-Test of My DAQmx Device Programmatically?
http://digital.ni.com/public.nsf/allkb/124D580AE300335E86256FDD006CE798
09-12-2017 05:52 PM
Thank You Nick, this is what I needed.
Here is the code I am now using at start up to re-reserve the device (sorry for the formatting and some stuff specific to us, but you get the idea)
// The DAQ devce may have been left reserved.
// Re-reserve and do a self test.
Exception slotException = null;
using (Device dev = DaqSystem.Local.LoadDevice(this.daqDeviceName))
{
dev.ReserveNetworkDevice(true);
dev.Reset();
dev.SelfTest();
// Wait for attached module to connect
Device slotDevice = null;
for (int tries = 0; tries < 10; ++tries)
{
try
{
slotDevice = DaqSystem.Local.LoadDevice(this.daqSlotName);
break;
}
catch(Exception ex)
{
Thread.Sleep(10000);
slotException = ex;
}
}
if (slotDevice == null)
{
throw new VendorDriverExceptionException("Could not find DAQ Module: " + slotException.Message);
}
else
{
slotDevice.Dispose();
}
}