Programming Examples 36
Keysight InfiniiVision DSOX1204A/G Oscilloscopes Programmer's Guide 895
namespace Example
{
class Program
{
static void Main(string[] args)
{
// Change this variable to the address of your instrument
string VISA_ADDRESS = "USB0::0x2A8D::0x1797::CN56240004::0::INSTR"
;
// Create a connection (session) to the instrument
IMessageBasedSession session;
try
{
session = GlobalResourceManager.Open(VISA_ADDRESS) as
IMessageBasedSession;
}
catch (NativeVisaException visaException)
{
Console.WriteLine("Couldn't connect.");
Console.WriteLine("Error is:\r\n{0}\r\n", visaException);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
return;
}
// Create a formatted I/O object which will help us format the
// data we want to send/receive to/from the instrument
MessageBasedFormattedIO myScope =
new MessageBasedFormattedIO(session);
// For Serial and TCP/IP socket connections enable the read
// Termination Character, or read's will timeout
if (session.ResourceName.Contains("ASRL") ||
session.ResourceName.Contains("SOCKET"))
session.TerminationCharacterEnabled = true;
session.TimeoutMilliseconds = 20000;
// Initialize - start from a known state.
// ==============================================================
string strResults;
FileStream fStream;
// Get and display the device's *IDN? string.
myScope.WriteLine("*IDN?");
strResults = myScope.ReadLine();
Console.WriteLine("*IDN? result is: {0}", strResults);
// Clear status and load the default setup.
myScope.WriteLine("*CLS");
myScope.WriteLine("*RST");
// Capture data.