Programming Guide

Table Of Contents
SIGLENT
72 SVA1000X Programming Guide
2) TCP/IP access code:
Write a function TCP_IP_Test:
int TCP_IP_Test(char *pIP)
{
char outputBuffer[VI_FIND_BUFLEN];
ViSessiondefaultRM, instr;
ViStatusstatus;
/* First we will need to open the default resource manager. */
status = viOpenDefaultRM (&defaultRM);
if (status<VI_SUCCESS)
{
printf("Could not open a session to the VISA Resource Manager!\n");
}
/* Now we will open a session via TCP/IP device */
char head[256] ="TCPIP0::";
char tail[] ="::INSTR";
strcat(head,pIP);
strcat(head,tail);
status = viOpen (defaultRM, head, VI_LOAD_CONFIG, VI_NULL, &instr);
if (status<VI_SUCCESS)
{
printf ("An error occurred opening the session\n");
viClose(defaultRM);
}
status = viPrintf(instr, "*idn?\n");
status = viScanf(instr, "%t", outputBuffer);
if (status<VI_SUCCESS)
{
printf("viRead failed with error code: %x \n",status);
viClose(defaultRM);
}
else
{ printf ("\nMesseage read from device: %*s\n", 0,outputBuffer);
} status = viClose (instr);
status = viClose (defaultRM);
printf("Press 'Enter' to exit.");
fflush(stdin);
getchar(); return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
printf("Please input IP address:");
char ip[256];
fflush(stdin);
gets(ip);
TCP_IP_Test(ip);
return 0;
}
4.1.2 Example of VB
Environment: Win7 32bit system, Microsoft Visual Basic 6.0
The function of this example: Use the NI-VISA, to control the device with USBTMC and
TCP/IP access to do a write and read.
Follow the steps to complete the example:
1 Open Visual Basic, build a standard application program project (Standard EXE)
2 Set the project environment to use the NI-VISA lib, Click the Existing tab of Project>>Add