Example #1
0
        public static void FlashNuttx(string dfuOsPath, string dfuUserPath)
        {
            DfuContext.Init();
            var devices = DfuContext.Current.GetDevices();

            if (devices.Count < 1)
            {
                Console.WriteLine("Attach a device in DFU mode, mofo.");
            }
            else
            {
                if (!string.IsNullOrEmpty(dfuOsPath))
                {
                    if (!File.Exists(dfuOsPath))
                    {
                        Console.WriteLine($"Cannot find {dfuOsPath} file.");
                        return;
                    }
                }
                else if (!File.Exists($"{Environment.CurrentDirectory}\\{os}"))
                {
                    Console.WriteLine($"Cannot find {os} file.");
                    return;
                }

                if (!string.IsNullOrEmpty(dfuUserPath))
                {
                    if (!File.Exists(dfuUserPath))
                    {
                        Console.WriteLine($"Cannot find {dfuUserPath} file.");
                        return;
                    }
                }
                else if (!File.Exists($"{Environment.CurrentDirectory}\\{user}"))
                {
                    Console.WriteLine($"Cannot find {user} file.");
                    return;
                }

                devices[0].Uploading += Program_Uploading;

                Upload(devices[0], $"{dfuOsPath ?? Environment.CurrentDirectory + "\\" + os}", os_address);
                Upload(devices[0], $"{dfuUserPath ?? Environment.CurrentDirectory + "\\" + user}", user_address);
            }
        }
Example #2
0
 public static void Init()
 {
     Current          = new DfuContext();
     Current._context = new Context();
 }