static async void i2cdetect(string[] input) { try { if (input.Length == 2) { UpBridge.Up upb = new UpBridge.Up(); // I2cController controller = await I2cController.GetDefaultAsync(); Console.WriteLine("step 1 add controller"); I2cController controller = (await I2cController.GetControllersAsync(UpWinApis.UpI2cProvider.GetI2cProvider()))[0]; Console.WriteLine("step 2 setting"); I2cConnectionSettings Settings = new I2cConnectionSettings(0x00); Console.WriteLine("step 3"); Console.WriteLine(controller.GetDevice(Settings)); Console.WriteLine(controller.GetDevice(Settings).DeviceId); Console.WriteLine(" 0 1 2 3 4 5 6 7 8 9 a b c d e f"); byte[] writebuf = { 0x00 }; byte[] readbuf = new byte[1]; for (uint i = 0; i < 256; i += 16) { if (i == 0) { Console.Write("00: "); } else { Console.Write(Convert.ToString(i, 16) + ": "); } for (uint j = 0; j < 16; j++) { Settings.SlaveAddress = (int)(i + j); try { controller.GetDevice(Settings).WriteRead(writebuf, readbuf); if (i + j < 0x10) { Console.Write("0" + Convert.ToString(i + j, 16) + " "); } else { Console.Write(Convert.ToString(i + j, 16) + " "); } } catch (Exception e) { Console.Write("--" + " "); } } Console.Write("\n"); } } else { Console.WriteLine("command error,plese refer to below example \n" + "i2cdetect\n"); Console.WriteLine(Usage); } } catch (Exception e) { Console.WriteLine(e.Message); } }