LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Mocking reading of NI card and driver and device names

Solved!
Go to solution

Hello,

 

I am currently using a CVI 2010 version (v10) on a Windows 10 PC in order to read NI device and driver configurations, like device name and product type using DAQmxGetDeviceAttribute in my current source code which depends on <NIDAQmx.h> and "NIDAQEx.h" files, and stores the read information in a database. 

 

How can I simulate (mock) the functionality of reading NI card and driver without the actual hardware? 

 

The following are the few lines which are necessary to read info from NI: 

 

int HWConfigCardRead(void)
{
  int  i=0;
  int j=0;
  int i32Status=0;
  short int i16Board=0;

  char sDev[256] = {0};     
  char sDevNameBuf[512] = {0};
  char sProdTypeBuf[512] = {0};
  char word[256] = {0};

  char sDriverType[512] = {0};
  char sDevType[512] = {0};
  char sDevName[512] = {0};
  int i32DevNum = -1;
 
  ViSession vi = VI_NULL;
 
  // obtain names of DAQmx devices from system
  i32Status = DAQmxGetSystemInfoAttribute (DAQmx_Sys_DevNames, sDevNameBuf, 512);
 
  // DAQMX Loop
  for ( i=0 ; i<HWConfig_CountChars(sDevNameBuf, ',')+1 ; i++ )
  {
    // Next device name
    HWConfig_StrListElemExt(sDevNameBuf, ", ", i+1, sDevName, sizeof(word));
   
    // Get product type
    i32Status = DAQmxGetDeviceAttribute (sDevName, DAQmx_Dev_ProdType, sProdTypeBuf, 512); //
  
 // DAQmx_Dev_ProductType  
    strcpy(sDrivType, "DAQMX");
    strcpy(sDevType, sProdTypeBuf);
    i32DevNum = i;
   
    // Check DIO
    if (!stricmp(HWConfig_DIO.sDevType, sDevType))    // DIO card found
    {
      if (!stricmp(HWConfig_DIO.sDriverType, sDriverType))  // DIO driver found
      {
        HWConfig_DIO.i32DeviceNr = i32DeviceNr;
        strcpy(HWConfig_DIO.sDeviceName, sDeviceName);
       
        i32ExistingDIO = 1;
      }
    }
    
    // Check MIO
    if (!stricmp(HWConfig_MIO.sDevType, sDevType))    // DIO card found
    {
      if (!stricmp(HWConfig_MIO.sDrivType, sDrivType))  // DIO driver found
      {
        HWConfig_MIO.i32DevNr = i32DevNr;
        strcpy(HWConfig_MIO.sDevName, sDevName);
       
        i32ExistingMIO = 1;
      }
    }

}

 

Thank you! 🙂

0 Kudos
Message 1 of 4
(2,349 Views)
Solution
Accepted by topic author arjunitedred

Have you tried creating your devices as simulated ones in MAX? You could probably get some info from the simulated devices as well (at least you can query DAQmxGetDeviceAttribute  for DAQmx_Dev_IsSimulated attribute to begin testing your code).



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?
Message 2 of 4
(2,311 Views)

Hello Roberto,

 

That only gives an idea of what kind of devices are connected (via NI MAX) which is helpful. But I am looking to completely simulate hardware access functionality without using HW at all. Can this be replicated right before the point of HW access? If so how and what testing framework on CVI? 

0 Kudos
Message 3 of 4
(2,255 Views)

Simulated devices offer a limited set of functionality to permit you to start program development without actual hardware.They are more or less operative with basic tasks (AI,AO,DIO) but do not cover the full set of functionalities of a real DAQ board.

The limitations of simulated devices are listed in this knowledgebase article,which also links some additional information page:

Limitations of NI-DAQmx Simulated Devices 



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 4 of 4
(2,234 Views)