Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Using NI-VISA in Linux to address E8510a RS-232 port

I'm trying to use the NI-VISA library in Linux to control the RS-232 port on an E8510a Lan GPIB controller.  The code I'm attempting to execute is below:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "visa.h"


static ViStatus status;                 /* For Checking error */
static ViSession defaultRM, instr;      /* Communications channels */

main ()
{
        status=viOpenDefaultRM (&defaultRM);
        if (status < VI_SUCCESS) {
                printf("Could not open a session to the VISA Resource Manager!\n");
                exit(EXIT_FAILURE);
        }
        status = viOpen (defaultRM, "TCPIP0::xx.xxx.xxx.xxx::COM1,488::INSTR", VI_NULL, VI_NULL, &instr);
        if (status < VI_SUCCESS) {
                printf("Cannot open a session to the device.\n");
                goto Close;
        }

        status = viSetAttribute (instr, VI_ATTR_TMO_VALUE, 5000);

Close:
   status = viClose(instr);
   status = viClose(defaultRM);

   return 0;
}

 

 

This does not work.  However, this code is valid and works just find for the GPIB addresses such as:

TCPIP0::xx.xxx.xxx.xx::gpib0,1::INSTR

 

Everything I've been able to find suggests that the above code should work.  It compiles and executes, but I always receive the unsuccessful message "Cannot open a session to the device.".  I've checked to make sure that the address is correct using the E5810a web tool.

 

Anyone who could possibly help would be appreciated. 

 

System is a Red Hat Enterprise 6 64-bit install:

Linux posey 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

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

Adding to the available information, the return status of the viOpen command appears to be:

VI_ERROR_RSRC_NFOUND

According to the Programmers reference: Insufficient location information or resource not present in the system.

 

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

Hi kilurb,

 

Are you ablet to ping that address at all? Does the controller have different modes that need to be configured for your GPIB settings?

KyleP
Applications Engineer
National Instruments
0 Kudos
Message 3 of 3
(2,961 Views)