Quantcast
Channel: Instrument Control (GPIB, Serial, VISA, IVI) topics
Viewing all articles
Browse latest Browse all 5565

viOpen(); VI_ERROR_RSRC_NFOUND

$
0
0

Hello, I installed :

http://www.ni.com/download/ni-visa-5.2/3337/en/

https://www.ni.com/lwcvi/download/

https://www.rohde-schwarz.com/driver/smc100a/ install driver VXIplug&play x86 driver rssmb

Created an example in which I get the error: viOpen () -1073807343.

tested with the mingw32 compiler, mingw64, msvc2017 64 bit

ViSession defaultRM;
       ViSession instr;
       ViUInt32 numInstrs;
       ViFindList findList;
       ViUInt32 retCount;
       ViUInt32 writeCount;
       ViStatus status;
       char instrResourceString[VI_FIND_BUFLEN];
       unsigned char buffer[100];
       char stringinput[512];
       int i;
       status=viOpenDefaultRM (&defaultRM);
       if (status < VI_SUCCESS)
       {
          qDebug() << "Could not open a session to the VISA Resource Manager!";
       return;
       }
       status = viFindRsrc (defaultRM, (ViString)"TCPIP?*INSTR", &findList, &numInstrs, instrResourceString);
       if (status < VI_SUCCESS)
       {
          qDebug() << "An error occurred while finding resources.\nHit enter to continue.";
          fflush(stdin);
          getchar();
          viClose (defaultRM);
          return;
       }
       for (i=0; i < numInstrs; i++)
       {
          if (i > 0)
             viFindNext (findList, instrResourceString);
          status = viOpen (defaultRM, instrResourceString, VI_NULL, VI_NULL, &instr);
          if(!QString(instrResourceString).contains("192.168.0.202"))
              continue;
          while(status < VI_SUCCESS)
          {
            status = viOpen (defaultRM,instrResourceString, VI_NULL, VI_NULL, &instr);
            qDebug() << "viOpen" <<status<< instrResourceString;
          }
          char * cmmand = (ViString)"*IDN?\n";
          status = viPrintf (instr, cmmand);
          if (status < VI_SUCCESS)
          {
             qDebug() << "Error writing to the device i.\n";
             status = viClose (instr);
             continue;
          }
          status = viScanf(instr, (ViString)"%t", buffer);
          if (status < VI_SUCCESS)
              qDebug() << "Error reading a response from the device i.\n";
          else
             qDebug() << "VI_SUCCESS";
          status = viClose (instr);
       }
       status = viClose (defaultRM);

if i run "ni max" device and interface" -> network devices -> add network devicec then the error disappears (VI_SUCCESS).

Help please


Viewing all articles
Browse latest Browse all 5565

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>