06-04-2020 08:52 AM
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! 🙂
Solved! Go to Solution.
06-04-2020 10:32 AM
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).
06-09-2020 08:36 AM
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?
06-11-2020 07:07 AM
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