LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

viFindRsrc finds SOCKET but not INSTR

Hello everyone, i have 2 instruments to program using VISA functions: a Aim-TTi MX100QP (SOCKET) and a RIGOL DL3021 (INSTR).
When I use viFindRsrc I can easily find the first one, but not the second one; in order to find it I need to create the TCP/IP resource in MAX (the first one is automatically create when i call viFindRsrc), but I would prefer not to, considering that the final user won't have MAX.

Any suggestions?

 

The code I wrote for the RIGOL is the following:

 

int OpenSession(char instr_name[])
{
char * device_found = NULL; //used to understand if a device has been found
int num_matches = 0;
char device_address[260];
char device_idn[200];
memset(&device_address, '0', sizeof(device_address));

ViAttr timeout_time;

viOpenDefaultRM(&sesn);
viFindRsrc( sesn, "TCPIP?*INSTR", &findlist, &num_matches, device_address);
//printf("Number of matches: %d\n", num_matches); //DEBUG

while (num_matches > 0)
{
//printf("Device address: %s\n", device_address); //DEBUG
error = viOpen( sesn, device_address, VI_EXCLUSIVE_LOCK, 1000, &vi);
if (error < 0) //if the connection gives an error, we go straight to the next resource found
{
num_matches--;
viClose( vi);
error = viFindNext( findlist, device_address);

if (error == VI_ERROR_RSRC_NFOUND) //No more matches
{
//printf("No instrument found!\n"); //DEBUG
return -1;
}
}

viGetAttribute( vi, VI_ATTR_TMO_VALUE, &timeout_time);
timeout_time = 50;
viSetAttribute( vi, VI_ATTR_TMO_VALUE, timeout_time);

viPrintf( vi, "*IDN?\n");
viScanf( vi, "%[^\r]", &device_idn);
//printf("Device IDN: %s\n", device_idn); //DEBUG
device_found = strstr( device_idn, instr_name);
if (device_found == NULL)
{
num_matches--;
viClose( vi);
error = viFindNext( findlist, device_address);

if (error == VI_ERROR_RSRC_NFOUND) //No more matches
{
//printf("No instrument found!\n"); //DEBUG
return -1;
}
}
else
{
return 0;
}
}

//Device not present or not responding
return -4;

}

0 Kudos
Message 1 of 3
(1,789 Views)

My guess would be that the: Aim-TTi  is runing mDNS and the RIGOL is not. Go to the Web Page of each instrument and see what LXI version they have. If 1.3 or greater then they should both have mDNS. Then maybe it's shutoff on the Rigol.

0 Kudos
Message 2 of 3
(1,719 Views)

Mmh ok, I'll try, thank you. For now I've assigned a static IP to the RIGOL, but next monday I'll try you method.

0 Kudos
Message 3 of 3
(1,708 Views)