Programming Manual UTG1000X Series
Instruments.uni-trend.com
38
/
51
}
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 to query the device information.
Steps
:
1.
Open Visual Studio software and create a new C# console project.
2.
Add C# quote Ivi.Visa.dll and NationalInstruments.Visa.dll of VISA.
3.
Source code
a)
USBTMC Example
class Program
{
void usbtmc_test()
{
using (var rmSession = new ResourceManager())
{
var resources = rmSession.Find("USB?*INSTR");
foreach (string s in resources)
{
try
{
var mbSession = (MessageBasedSession)rmSession.Open(s);
mbSession.RawIO.Write("*IDN?\n");
System.Console.WriteLine(mbSession.RawIO.ReadString());
}