06-04-2012 10:01 AM
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
06-04-2012 10:13 AM
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.
06-05-2012 02:52 PM
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?