LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you test to see if a board is present?

I have an application that has two modes of operation:  Delivered, with two NI boards, DAQmx installed; and a simulation mode with no boards and DaqMX runtime installed

 

How can I tell if a boards is installed, to determine if the mode should be delivered or simulated? 

 

Right now on my desktop I have the application installed, both DAQmx and the runtime installed, but no cards.  The first call teh DAQmxCreateTask goes off to never-never land, and the app completely hangs.  (BTW, why is there no timeout in DaqMx calls? )

 

Help will be appreciated...

 

Running CVI 2009, DaqMx 8.9.5.

0 Kudos
Message 1 of 6
(4,058 Views)

If you happen to know the exact name of your device you could query if it is a real board or a simulated one with

DAQmxGetDeviceAttribute ("DeviceName", DAQmx_Dev_IsSimulated, &sim, 0);

 

If you don't know how the devices are named, daqmx can list all available devices in the system, next you can scan this list. See this post for reference.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 6
(4,028 Views)
Hello hendra@ngms

There is a DAQmx property DAQmxGetDevIsSimulated, that will return a Boolean on whether the device is simulated or not. For more information on this property in addition to any other available properties you can reference the NI-DAQmx C Reference Help, under the NI-DAQmx C Properties.

As far as the application hanging what type of Error Handling are your using?

Regards,
Glenn
0 Kudos
Message 3 of 6
(4,026 Views)

You folks have brought up a couple interesting points.  But first, just to clarify, the application needs to operate whether or not the boards are present.  The boards are NI6518's, two of them.  So the best thing for my app would be a test -- the very first thing done -- to see whether or not they are installed.  If not, execution branches to a simulation section of code.

 

You askedabout error handling.  I am testing the return value for every DAQmx call, but I don't expect a DAQmx call to go away and just hang, which it does with no boards present.  Is there some switch I need to set to ensure that I receive a failure code back even for a TaskCreate call when no boards are present?

0 Kudos
Message 4 of 6
(4,007 Views)

Ok, so what you can do in your program if to execute something like this:

 

// Get informations from the system

size = DAQmxGetSystemInfoAttribute (DAQmx_Sys_DevNames, msg, 0);   // Get size of string to allocate
msg = malloc (size);
DAQmxGetSystemInfoAttribute (DAQmx_Sys_DevNames, msg, size);
DebugPrintf ("%s\n", msg);

 

// Scan the returned, comma-separated string

 

// Free resources

free (msg);
 

Y cannot test here since I have some devices installed on my system but you may test with an empty system wether in this case the required space to allocate is 0, in which case you may directly switch to simulated code. Otherwise scan the list and verify if the installed devices are actual or simulated boards and decide what to do afterwards.

 

Regarding your CreateTask notation, I never tested it in an empty system so I cannot comment anything on that. It surely is strange and it should be fixed if this instruction hangs up the system in this case.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 6
(4,003 Views)

Roberto (and NI support people, if you are reading),

 

Thank you for the suggestion.  I used a fixed buffer size, installed the function call, stepped through it and when the function is called, execution goes off to who knows where and the application hangs.  0% CPU load during this time.  It did return after more than 5 minutes, with this error message (dang I have to type this, there doesn't seem to be any way to copy it):  "The client process cannot communicate with the configuration server process.  If this problem persists, please note the steps you performed that led to this error and contact technical support."

 

One other interesting and very distressing thing:  When I select the function call DAQmxGetSystemInfoAttribute, right click and select to show the function panel, CVI hangs and I have to force quit.  Other DAQmx functions do not do this.  Do these problems sound like bugs?

 

Before the above tests, I wiped NI software off this desktop, all of it, going back to 8.1, and reinstalled 2009 and the Device Drivers.

 

 

0 Kudos
Message 6 of 6
(3,994 Views)