/*===================================================================== | MAIN PROGRAM | ====================================================================*/ public static void Main(string[] args) { int port; int handle; int result; AardvarkApi.AardvarkExt aaExt = new AardvarkApi.AardvarkExt(); if (args.Length != 1) { Console.WriteLine("usage: aamonitor PORT"); return; } // Parse the port argument try { port = Convert.ToInt32(args[0]); } catch (Exception) { Console.WriteLine("Error: invalid port"); return; } // Open the device handle = AardvarkApi.aa_open_ext(port, ref aaExt); if (handle <= 0) { Console.WriteLine("Unable to open Aardvark device on port {0}", port); Console.WriteLine("error: {0}", AardvarkApi.aa_status_string(handle)); return; } Console.WriteLine("Opened Aardvark; features = 0x{0:x2}", aaExt.features); // Disable the I2C bus pullup resistors (2.2k resistors). // This command is only effective on v2.0 hardware or greater. // The pullup resistors on the v1.02 hardware are enabled by default. AardvarkApi.aa_i2c_pullup(handle, AardvarkApi.AA_I2C_PULLUP_NONE); // Disable the Aardvark adapter's power pins. // This command is only effective on v2.0 hardware or greater. // The power pins on the v1.02 hardware are not enabled by default. AardvarkApi.aa_target_power(handle, AardvarkApi.AA_TARGET_POWER_NONE); // Enable the monitor result = AardvarkApi.aa_i2c_monitor_enable(handle); if (result < 0) { Console.WriteLine("error: {0}", AardvarkApi.aa_status_string(result)); return; } Console.WriteLine("Enabled I2C monitor."); // Dump the data to the console dump(handle); // Disable the monitor and close the device AardvarkApi.aa_i2c_monitor_disable(handle); AardvarkApi.aa_close(handle); }