Programming Guide

Digital Oscilloscopes Series
173
using NationalInstruments.VisaNS;
namespace TestVisa
{
class Program
{
static void Main(string[] args)
{
// Find all the USBTMC resources
string[] usbRsrcStrings =
ResourceManager.GetLocalManager().FindResources("USB?*INSTR");
if (usbRsrcStrings.Length <= 0)
{
Console.WriteLine("Can not find USBTMC Device!");
return;
}
//Choose the first resource string to connect the
device.
//You can input the address manually
//USBTMC:
//MessageBasedSession mbSession =
(MessageBasedSession)ResourceManager.GetLocalManager().Open("USB
0::0xF4EC::0xEE38::0123456789::INSTR");
//TCP IP:
//MessageBasedSession mbSession =
(MessageBasedSession)ResourceManager.GetLocalManager().Open("TCP
IP0::192.168.1.100::INSTR");
MessageBasedSession mbSession =
(MessageBasedSession)ResourceManager.GetLocalManager().Open(usbR
srcStrings[0]);
mbSession.Write("*IDN?");
string result = mbSession.ReadString();
mbSession.Dispose();