From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

viOpen(); VI_ERROR_RSRC_NFOUND

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

0 Kudos
Message 1 of 3
(3,668 Views)
ViStatus status;
   status = rssmb_init((ViRsrc)"TCPIP::192.168.0.202::INSTR",VI_FALSE,VI_FALSE,&ssesion);
   if(status < VI_SUCCESS)
   {
       qDebug() << "init" << status;
       return;
   }

The code only works when adding a device to "NI MAX".

0 Kudos
Message 2 of 3
(3,657 Views)

The reason is that the API uses the information from MAX to use the devices. If the device is not present in MAX, you'll get the error. 

Message 3 of 3
(3,609 Views)