AnsweredAssumed Answered

viFindRsrc issue

Question asked by torete43 on Nov 20, 2008
Latest reply on Apr 1, 2009 by testlab
I'm testing a function to search for gpib instruments. It's implemented in C++ and uses VISA to communicate.  This is the code (shorted):

-------FUNCTION---------------------------------------------
status = viOpenDefaultRM(&defaultRM);
status = viFindRsrc(defaultRM, "GPIB?*INSTR", &fList, &numInstrs, address);
          
   if (numInstrs==0)          
   {
   // Message to the user: No instruments found.
   }
   else
   {
     while (numInstrs--)
       {
        status = viOpen(defaultRM,address,VI_NULL,VI_NULL,&instr);               
        status += viFlush(instr,VI_READ_BUF_DISCARD);                    
        status += viClear(instr);                    
        status += viQueryf(instr,"*IDN?\n","%100[^,],%100[^,],%100[^,]",vendor,model,serialnumb);                    
        status += viGpibControlREN(instr,VI_GPIB_REN_ADDRESS_GTL);
                    
        if (status>=VI_SUCCESS)
        {
             // Code to add a tree node with vendor and model in a tree view
        }
        else
        {
                // Message to the user: One instrument failed to communicate
        }

        status = viClose(instr);     

           if (numInstrs>0)
        {
          status = viFindNext(fList,address);     
        }
       }
   }
          
status = viClose(fList);
status = viClose(defaultRM);

------------------------------------------------------------


This function is called first by the application when it starts, so the user can see a list of instruments in the gpib bus. The user has the possibility to refresh the list through a button 'refresh'. This refreshing consists in calling the function again. The function works ok till one or more instrumets are turned off and then the list is refreshed. I use IO monitor to check the VISA operations and surprisingly the function still search for the address of the instrument turned off! Its like if the address of the instrument which has been turned off remains in the findlist.

But there is something more weird. Lets suppose two instruments with addresses 10 and 15. Run the app -> Both appears in the list ->OK. Then I turn off 15 and refresh the list. 10 is found and listed ->OK. But then ...  surprise! viFindNext says that 15 is there, and the function does the first visa operations (viOpen session, viFlush and viClear) succesfully !!! How the hell is this possible? Its turned off !! Then, when it does the viQuery appears an error (obviously).
Another way to get this issue is to change an instrument's gpib address and then refresh the list.

Any idea ???  

Outcomes