Example #1
0
        static async void pwmlist()
        {
            UpBridge.Up   upb        = new UpBridge.Up();
            PwmController controller = await PwmController.GetDefaultAsync();

            Console.WriteLine(controller.PinCount);
        }
Example #2
0
        static async Task spiread(string[] input)
        {
            try
            {
                if (input.Length == 2)
                {
                    UpBridge.Up   upb        = new UpBridge.Up();
                    SpiController controller = await SpiController.GetDefaultAsync();

                    SpiConnectionSettings settings = new SpiConnectionSettings(spi.ChipSelectLine);
                    settings.ClockFrequency = spi.ClockFrequency;
                    settings.DataBitLength  = spi.DataBitLength;
                    settings.Mode           = spi.Mode;
                    settings.SharingMode    = spi.SharingMode;
                    byte[] readbuf = new byte[Convert.ToInt32(input[1])];
                    controller.GetDevice(settings).Read(readbuf);
                    for (int i = 0; i < readbuf.Length; i++)
                    {
                        Console.WriteLine(i + " byte: " + readbuf[i].ToString("X"));
                    }
                }
                else
                {
                    Console.WriteLine("please input : read N");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #3
0
        static async Task spifullduplex(string[] input)
        {
            try
            {
                UpBridge.Up   upb        = new UpBridge.Up();
                SpiController controller = await SpiController.GetDefaultAsync();

                SpiConnectionSettings settings = new SpiConnectionSettings(spi.ChipSelectLine);
                settings.ClockFrequency = spi.ClockFrequency;
                settings.DataBitLength  = spi.DataBitLength;
                settings.Mode           = spi.Mode;
                settings.SharingMode    = spi.SharingMode;
                byte[] wrtiebuf = new byte[input.Length - 1];
                byte[] readbuf  = new byte[wrtiebuf.Length];
                for (int i = 1; i < input.Length; i++)
                {
                    wrtiebuf[i - 1] = Convert.ToByte(input[i], 16);
                }
                controller.GetDevice(settings).TransferFullDuplex(wrtiebuf, readbuf);
                for (int i = 0; i < readbuf.Length; i++)
                {
                    Console.WriteLine(i + " byte: " + readbuf[i].ToString("X"));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #4
0
        static async void i2cget(string[] input)
        {
            if (input.Length == 3)
            {
                int           slave      = Convert.ToInt32(input[1], 16);
                UpBridge.Up   upb        = new UpBridge.Up();
                I2cController controller = await I2cController.GetDefaultAsync();

                // Int32.TryParse(input[1], out slave);
                I2cConnectionSettings Settings = new I2cConnectionSettings(slave);
                byte[] writebuf = new byte[1];
                writebuf[0] = Convert.ToByte(input[2], 16);
                byte[] readbuf = new byte[1];
                try
                {
                    controller.GetDevice(Settings).WriteRead(writebuf, readbuf);
                    Console.WriteLine("Sucess to get data,\n" +
                                      Convert.ToString(readbuf[0], 16));
                }
                catch (Exception e)
                {
                    Console.WriteLine("error to get data\n");
                }
            }
            else
            {
                Console.WriteLine("command error,plese refer to below example \n" +
                                  "i2cget {i2c address} {i2c register}\n");
                Console.WriteLine(Usage);
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            string input = "";
            bool   exit  = true;

            UpBridge.Up upb = new UpBridge.Up();
            Console.WriteLine("UWP console ADC test:");

            //print Board INFO
            Console.WriteLine(upb.BoardGetManufacture() + "\n"
                              + "Board Name:  " + upb.BoardGetName() + "\n"
                              + "BIOS Ver:    " + upb.BoardGetBIOSVersion() + "\n"
                              + "Firmware Ver:" + upb.BoardGetFirmwareVersion().ToString("X") + "\n");

            Console.WriteLine(Usage);
            adcnum().Wait();
            while (exit)
            {
                Console.Write(">");
                input = Console.ReadLine();
                string[] inputnum = input.Split(' ');
                switch (inputnum[0])
                {
                case "read":
                    int index = Convert.ToInt32(inputnum[1]);
                    if (index < adcmax)
                    {
                        Console.WriteLine("select " + inputnum[1]);
                        adc(index).Wait();
                    }
                    else
                    {
                        Console.WriteLine("Not Get " + index + " controller");
                        break;
                    }
                    break;

                case "count":
                    adcnum().Wait();
                    break;

                case "max":
                    adcmaxvalue().Wait();
                    break;

                case "min":
                    adcminvalue().Wait();
                    break;

                case "exit":
                    exit = false;

                    break;

                default:
                    break;
                }
            }
        }
Example #6
0
 static async Task i2cdump(string[] input)
 {
     if (input.Length == 3)
     {
         int         slave = Convert.ToInt32(input[2], 16);
         UpBridge.Up upb   = new UpBridge.Up();
         int         index = Int32.Parse(input[1]);
         if (index > 2)
         {
             Console.WriteLine("i2c have 0 & 1");
             throw new InvalidOperationException("i2c have 0 & 1");
         }
         I2cController         controller = (await I2cController.GetControllersAsync(UpWinApis.UpI2cProvider.GetI2cProvider()))[index];
         I2cConnectionSettings Settings   = new I2cConnectionSettings(slave);
         Settings.BusSpeed = speed[index];
         Console.WriteLine("     0    1   2   3   4   5   6   7   8   9   a   b   c   d   e   f");
         byte[] writebuf = new byte[1];
         byte[] readbuf  = new byte[1];
         try
         {
             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++)
                 {
                     writebuf[0] = (byte)(i + j);
                     controller.GetDevice(Settings).WriteRead(writebuf, readbuf);
                     if (readbuf[0] < 0x10)
                     {
                         Console.Write("0" + Convert.ToString(readbuf[0], 16) + "  ");
                     }
                     else
                     {
                         Console.Write(Convert.ToString(readbuf[0], 16) + "  ");
                     }
                 }
                 Console.Write("\n");
             }
         }
         catch (Exception)
         {
             Console.Write("NOT to read Data" + "\n");
         }
     }
     else
     {
         Console.WriteLine("command error,plese refer to below example \n" +
                           "i2cdump {bus number} {i2c address}\n");
         Console.WriteLine(Usage);
     }
 }
Example #7
0
        static async void i2cdump(string[] input)
        {
            if (input.Length == 2)
            {
                int           slave      = Convert.ToInt32(input[1], 16);
                UpBridge.Up   upb        = new UpBridge.Up();
                I2cController controller = await I2cController.GetDefaultAsync();

                //  Int32.TryParse(input[1],out slave);

                I2cConnectionSettings Settings = new I2cConnectionSettings(slave);
                Console.WriteLine("     0    1   2   3   4   5   6   7   8   9   a   b   c   d   e   f");
                byte[] writebuf = new byte[1];
                byte[] readbuf  = new byte[1];
                try
                {
                    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++)
                        {
                            writebuf[0] = (byte)(i + j);
                            controller.GetDevice(Settings).WriteRead(writebuf, readbuf);
                            if (readbuf[0] < 0x10)
                            {
                                Console.Write("0" + Convert.ToString(readbuf[0], 16) + "  ");
                            }
                            else
                            {
                                Console.Write(Convert.ToString(readbuf[0], 16) + "  ");
                            }
                        }
                        Console.Write("\n");
                    }
                }
                catch (Exception)
                {
                    Console.Write("NOT to read Data" + "\n");
                }
            }
            else
            {
                Console.WriteLine("command error,plese refer to below example \n" +
                                  "i2cdump {i2c address}\n");
                Console.WriteLine(Usage);
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            string input = "";
            bool   exit  = input.Equals("exit");

            UpBridge.Up upb = new UpBridge.Up();
            Console.WriteLine("UWP console I2C test:");

            //print Board INFO
            Console.WriteLine(upb.BoardGetManufacture() + "\n"
                              + "Board Name:  " + upb.BoardGetName() + "\n"
                              + "BIOS Ver:    " + upb.BoardGetBIOSVersion() + "\n"
                              + "Firmware Ver:" + upb.BoardGetFirmwareVersion().ToString("X") + "\n");

            Console.WriteLine(Usage);
            while (exit == false)
            {
                Console.Write(">");
                input = Console.ReadLine();
                string[] inputnum = input.Split(' ');
                switch (inputnum[0])
                {
                case "i2cdetect":
                    i2cdetect(inputnum).Wait();
                    break;

                case "i2cdump":
                    i2cdump(inputnum).Wait();
                    break;

                case "i2cset":
                    i2cset(inputnum).Wait();
                    break;

                case "i2cget":
                    i2cget(inputnum).Wait();
                    break;

                case "StandardMode":
                case "FastMode":
                    i2cspeed(inputnum);
                    break;

                case "exit":
                    exit = inputnum[0].Equals("exit");
                    break;

                case "help":
                default:
                    Console.WriteLine(Usage);
                    break;
                }
            }
        }
Example #9
0
        static async void pwmlist()
        {
            try
            {
                UpBridge.Up   upb        = new UpBridge.Up();
                PwmController controller = await PwmController.GetDefaultAsync();

                Console.WriteLine(controller.PinCount);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #10
0
        static async Task adcminvalue()
        {
            try
            {
                UpBridge.Up   upb        = new UpBridge.Up();
                AdcController controller = await AdcController.GetDefaultAsync();

                Console.WriteLine("Min Value    :  " + controller.MinValue);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #11
0
        static async Task adc(int channelint)
        {
            try
            {
                UpBridge.Up   upb        = new UpBridge.Up();
                AdcController controller = await AdcController.GetDefaultAsync();

                AdcChannel channel = controller.OpenChannel(channelint);
                Console.WriteLine(channel.ReadValue());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #12
0
        static async Task adcnum()
        {
            try
            {
                UpBridge.Up upb = new UpBridge.Up();

                AdcController controller = await AdcController.GetDefaultAsync();

                adcmax = controller.ChannelCount;
                Console.WriteLine("Get  " + adcmax + "  controller");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #13
0
        static async Task i2cset(string[] input)
        {
            if (input.Length == 5)
            {
                int         slave = Convert.ToInt32(input[2], 16);
                UpBridge.Up upb   = new UpBridge.Up();
                int         index = Int32.Parse(input[1]);
                if (index > 2)
                {
                    Console.WriteLine("i2c have 0 & 1");
                    throw new InvalidOperationException("i2c have 0 & 1");
                }
                I2cController controller = (await I2cController.GetControllersAsync(UpWinApis.UpI2cProvider.GetI2cProvider()))[index];

                I2cConnectionSettings Settings = new I2cConnectionSettings(slave);
                Settings.BusSpeed = speed[index];
                byte[] writebuf = new byte[2];
                writebuf[0] = Convert.ToByte(input[3], 16);
                writebuf[1] = Convert.ToByte(input[4], 16);

                try
                {
                    controller.GetDevice(Settings).Write(writebuf);
                    Console.WriteLine("Sucess to set data,\n");
                }
                catch (Exception e)
                {
                    Console.WriteLine("error to set data\n");
                }
            }
            else
            {
                Console.WriteLine("command error,plese refer to below example \n" +
                                  "i2cset {bus number} {i2c address} {i2c register} {i2cdata}\n");
                Console.WriteLine(Usage);
            }
        }
Example #14
0
        static async void spiwrite(string [] input)
        {
            try
            {
                UpBridge.Up   upb        = new UpBridge.Up();
                SpiController controller = await SpiController.GetDefaultAsync();

                SpiConnectionSettings settings = new SpiConnectionSettings(spi.ChipSelectLine);
                settings.ClockFrequency = spi.ClockFrequency;
                settings.DataBitLength  = spi.DataBitLength;
                settings.Mode           = spi.Mode;
                settings.SharingMode    = spi.SharingMode;
                byte[] wrtiebuf = new byte[input.Length - 1];
                for (int i = 1; i < input.Length; i++)
                {
                    wrtiebuf[i - 1] = Convert.ToByte(input[i], 16);
                }
                controller.GetDevice(settings).Write(wrtiebuf);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #15
0
        static void Main(string[] args)
        {
            string input = "";
            bool   exit  = input.Equals("exit");

            UpBridge.Up upb = new UpBridge.Up();
            Console.WriteLine("UWP console SPI test:");
            //print Board INFO
            Console.WriteLine(upb.BoardGetManufacture() + "\n"
                              + "Board Name:  " + upb.BoardGetName() + "\n"
                              + "BIOS Ver:    " + upb.BoardGetBIOSVersion() + "\n"
                              + "Firmware Ver:" + upb.BoardGetFirmwareVersion().ToString("X") + "\n");
            Console.WriteLine(Usage);
            spi.ChipSelectLine = 0;
            spi.ClockFrequency = 8000000;
            spi.DataBitLength  = 8;
            spi.Mode           = 0;
            spi.SharingMode    = 0;
            while (exit == false)
            {
                Console.Write(">");
                input = Console.ReadLine();
                string[] inputnum = input.Split(' ');
                switch (inputnum[0].ToLower())
                {
                case "set":
                    spiset();
                    break;

                case "write":
                    spiwrite(inputnum).Wait();
                    break;

                case "read":
                    spiread(inputnum).Wait();
                    break;

                case "writeread":
                    spiwriteread(inputnum).Wait();
                    break;

                case "fullduplex":
                    spifullduplex(inputnum).Wait();
                    break;

                case "info":
                    Console.WriteLine("ChipSelectLine   :   " + spi.ChipSelectLine + "\n");
                    Console.WriteLine("ClockFrequency   :   " + spi.ClockFrequency + "\n");
                    Console.WriteLine("DataBitLength    :   " + spi.DataBitLength + "\n");
                    Console.WriteLine("Mode             :   " + spi.Mode + "\n");
                    Console.WriteLine("SharingMode      :   " + spi.SharingMode + "\n");
                    break;

                case "exit":
                    exit = inputnum[0].Equals("exit");
                    break;

                case "help":
                default:
                    Console.WriteLine(Usage);
                    break;
                }
            }
        }
Example #16
0
        static async Task MainAsync()
        {
            string input = "";
            bool   exit  = input.Equals("exit");

            UpBridge.Up upb = new UpBridge.Up();
            Console.WriteLine("UWP console PWM test:");
            PwmController controller = await PwmController.GetDefaultAsync();

            pin1.pin = 0;
            //print Board INFO
            Console.WriteLine(upb.BoardGetManufacture() + "\n"
                              + "Board Name:  " + upb.BoardGetName() + "\n"
                              + "BIOS Ver:    " + upb.BoardGetBIOSVersion() + "\n"
                              + "Firmware Ver:" + upb.BoardGetFirmwareVersion().ToString("X") + "\n");
            PwmPin pin = controller.OpenPin(0);

            Console.WriteLine(Usage);
            while (exit == false)
            {
                Console.Write(pin1.pin.ToString() + ">");
                input = Console.ReadLine();
                string[] inputnum = input.Split(' ');
                switch (inputnum[0].ToLower())
                {
                case "list":
                    pwmlist();
                    break;

                case "set":
                    if (inputnum.Length == 2)
                    {
                        int pin_convert;
                        if (int.TryParse(inputnum[1], out pin_convert))
                        {
                            if (pin_convert == pin1.pin)
                            {
                                Console.WriteLine("This Pin is currently setting");
                            }
                            else
                            {
                                pin1.pin = pin_convert;
                                try
                                {
                                    controller = await PwmController.GetDefaultAsync();

                                    pin = controller.OpenPin(pin1.pin);
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e.Message);
                                }
                                Console.WriteLine("You select pin   " + pin1.pin + "   to set");
                            }
                        }
                        else
                        {
                            Console.WriteLine("Please input : set {int}");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Please input : set {int}");
                    }
                    break;

                case "get":
                    if (inputnum.Length == 1)
                    {
                        Console.WriteLine("Pin  " + pin1.pin + "\n");
                        Console.WriteLine("Max Frequency    :   " + controller.MaxFrequency + "\n");
                        Console.WriteLine("Min Frequency    :   " + controller.MinFrequency + "\n");
                        Console.WriteLine("Actual Frequency :   " + controller.ActualFrequency + "\n");
                        Console.WriteLine("Duty Cycle       :   " + pin.GetActiveDutyCyclePercentage() + "\n");
                        Console.WriteLine("Pin Status       :   " + pin.IsStarted + "\n");
                    }
                    else
                    {
                        Console.WriteLine("Please input : get");
                    }
                    break;

                case "frequency":
                    if (inputnum.Length == 2)
                    {
                        try
                        {
                            if (double.TryParse(inputnum[1], out pin1.pin_ActualFrequency))
                            {
                                Console.WriteLine("Frequency set : " + pin1.pin_ActualFrequency);
                                controller.SetDesiredFrequency(pin1.pin_ActualFrequency);
                                pin.Start();
                            }
                            else
                            {
                                Console.WriteLine("Please input : frequency {double}");
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Please input : frequency {double}");
                    }
                    break;

                case "duty":
                    if (inputnum.Length == 2)
                    {
                        try
                        {
                            if (double.TryParse(inputnum[1], out pin1.pin_DutyCycle))
                            {
                                Console.WriteLine("duty set : " + pin1.pin_DutyCycle);
                                pin.SetActiveDutyCyclePercentage(pin1.pin_DutyCycle);
                                pin.Start();
                            }
                            else
                            {
                                Console.WriteLine("Please input : duty {double}");
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Please input : duty {double}");
                    }
                    break;

                case "exit":
                    exit = inputnum[0].Equals("exit");
                    pin.Dispose();
                    break;

                case "help":
                default:
                    Console.WriteLine(Usage);
                    break;
                }
            }
        }
Example #17
0
        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);
            }
        }
Example #18
0
        static void Main(string[] args)
        {
            UpBridge.Up upb = new UpBridge.Up();

            Console.WriteLine(upb.BoardGetManufacture() + "\n"
                              + "Board Name:  " + upb.BoardGetName() + "\n"
                              + "BIOS Ver:    " + upb.BoardGetBIOSVersion() + "\n"
                              + "Firmware Ver:" + upb.BoardGetFirmwareVersion().ToString("X") + "\n");

            Console.WriteLine("Up UWP console GPIO test:");

            if (GpioController.GetDefault().PinCount > 0)
            {
                GpioPin gpioPin = null;
                int     selpin  = -1;
                while (true)
                {
                    string input;
                    if (selpin == -1)
                    {
                        Console.WriteLine("please select pin to control(pin %s)");
                    }
                    Console.Write(selpin.ToString() + ">");
                    input = Console.ReadLine();
                    string[] inArgs = input.Split(' ');
                    if (inArgs[0] == "pin")
                    {
                        if (inArgs.Length == 2)
                        {
                            selpin = int.Parse(inArgs[1]);
                            try
                            {
                                gpioPin = GpioController.GetDefault().OpenPin(selpin);
                            }catch (InvalidOperationException ie)
                            {
                                Console.WriteLine(ie.Message);
                                selpin = -1;
                            }
                        }
                        continue;
                    }

                    switch (input)
                    {
                    case "status":
                        Console.WriteLine(gpioPin.GetDriveMode().ToString());
                        break;

                    case "input":
                        gpioPin.SetDriveMode(GpioPinDriveMode.Input);
                        Console.WriteLine(gpioPin.GetDriveMode().ToString());
                        break;

                    case "output":
                        gpioPin.SetDriveMode(GpioPinDriveMode.Output);
                        Console.WriteLine(gpioPin.GetDriveMode().ToString());
                        break;

                    case "high":
                        gpioPin.Write(GpioPinValue.High);
                        Console.WriteLine(gpioPin.Read().ToString());
                        break;

                    case "low":
                        gpioPin.Write(GpioPinValue.Low);
                        Console.WriteLine(gpioPin.Read().ToString());
                        break;

                    case "read":
                        Console.WriteLine(gpioPin.Read().ToString());
                        break;

                    case "list":
                        Console.WriteLine("Available Pins:" + GpioController.GetDefault().PinCount.ToString() + " (start from 0)");
                        break;

                    case "help":
                    default:
                        Console.WriteLine(Usage);
                        break;
                    }
                }
            }
            else
            {
                Console.WriteLine("No available GPIO pins!");
                Console.WriteLine("Press any key to exit...");
                Console.ReadLine();
            }
        }
Example #19
0
 static async Task i2cdetect(string[] input)
 {
     try
     {
         if (input.Length == 2)
         {
             UpBridge.Up upb   = new UpBridge.Up();
             int         index = Int32.Parse(input[1]);
             if (index > 2)
             {
                 Console.WriteLine("i2c have 0 & 1");
                 throw new InvalidOperationException("i2c have 0 & 1");
             }
             I2cController         controller = (await I2cController.GetControllersAsync(UpWinApis.UpI2cProvider.GetI2cProvider()))[index];
             I2cConnectionSettings Settings   = new I2cConnectionSettings(0x00);
             Settings.BusSpeed = speed[index];
             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 {busnumber}\n");
             Console.WriteLine(Usage);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }