Programming Manual MSO/UPO2000 Series
144 / 156
Instruments.uni-trend.com
}
/* Now we will open a session via TCP/IP device */
char head[256] = "TCPIP0::";
char tail[] = "::inst0::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;
}
C# Example
Environment:Window system, Visual Studio
Description: Access the instrument via USBTMC and TCP/IP, and send "*IDN?" command on NI-VISA