Beispiel #1
0
        private void btnDetect_Click(object sender, EventArgs e)
        {
            this.btnDetect.Enabled = false;

            FirmwareLoader.outputType = FirmwareLoader.probeModel();

            if ((FirmwareLoader.outputType < FirmwareLoader.OutputType.OutputType_GD77) || (FirmwareLoader.outputType > FirmwareLoader.OutputType.OutputType_DM1801))
            {
                MessageBox.Show("Error: Unable to detect your radio.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                FirmwareLoader.outputType = FirmwareLoader.OutputType.OutputType_GD77;
            }

            this.rbModels[(int)FirmwareLoader.outputType].Checked = true;
            this.btnDetect.Enabled = true;
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            int exitCode = 0;

            /* Testing only
             * args = new string[2];
             * args[0] = "test.bin";
             * args[1] = "GUI";
             */
            if (args.Length == 0)
            {
                FirmwareLoader.outputType = FirmwareLoader.probeModel();

                if ((FirmwareLoader.outputType < FirmwareLoader.OutputType.OutputType_GD77) || (FirmwareLoader.outputType > FirmwareLoader.OutputType.OutputType_DM1801))
                {
                    Console.WriteLine("Unable to detect HT model, using GD-77 as fallback.");
                    FirmwareLoader.outputType = FirmwareLoader.OutputType.OutputType_GD77;
                }
                else
                {
                    Console.WriteLine(String.Format("Detected mode: {0}", FirmwareLoader.getModelName()));
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
            else
            {
                if (args.Contains("--help") || args.Contains("-h") || args.Contains("/h"))
                {
                    //FirmwareLoader.OutputType[] models = new FirmwareLoader.OutputType[] { FirmwareLoader.OutputType.OutputType_GD77, FirmwareLoader.OutputType.OutputType_GD77S, FirmwareLoader.OutputType.OutputType_DM1801 };
                    String[] modelsString =
                    {
                        FirmwareLoader.getModelString(FirmwareLoader.OutputType.OutputType_GD77),
                        FirmwareLoader.getModelString(FirmwareLoader.OutputType.OutputType_GD77S),
                        FirmwareLoader.getModelString(FirmwareLoader.OutputType.OutputType_DM1801)
                    };
                    String allModels = String.Join(" | ", modelsString);

                    Console.WriteLine(String.Format("\nUsage: GD77_FirmwareLoader [GUI] [{0}] [filename]\n\n", allModels));
                    Environment.Exit(exitCode);
                }

                int idxGD77   = Array.IndexOf(args, "GD-77");
                int idxDM1801 = Array.IndexOf(args, "DM-1801");
                int idxGD77S  = Array.IndexOf(args, "GD-77S");

                if (idxGD77 >= 0)
                {
                    FirmwareLoader.outputType = FirmwareLoader.OutputType.OutputType_GD77;
                    args = RemoveArgAt(args, idxGD77);
                }
                else if (idxGD77S >= 0)
                {
                    FirmwareLoader.outputType = FirmwareLoader.OutputType.OutputType_GD77S;
                    args = RemoveArgAt(args, idxGD77S);
                }
                else if (idxDM1801 >= 0)
                {
                    FirmwareLoader.outputType = FirmwareLoader.OutputType.OutputType_DM1801;
                    args = RemoveArgAt(args, idxDM1801);
                }
                else
                {
                    FirmwareLoader.outputType = FirmwareLoader.probeModel();
                    Console.WriteLine(String.Format(" - Detected model: {0}", FirmwareLoader.getModelName()));
                }

                if (args.Length == 0)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new MainForm());
                }

                int idx = Array.IndexOf(args, "GUI");
                if (idx >= 0)
                {
                    args = RemoveArgAt(args, idx);

                    if (args.Length <= 0)
                    {
                        Console.WriteLine("ERROR: No filename specified.");
                        Environment.Exit(-1);
                    }

                    FrmProgress frmProgress = new FrmProgress();
                    frmProgress.SetLabel("");
                    frmProgress.SetProgressPercentage(0);
                    frmProgress.Show();

                    exitCode = FirmwareLoader.UploadFirmware(args[0], frmProgress);
                    frmProgress.Close();
                }
                else
                {
                    if (args.Length <= 0)
                    {
                        Console.WriteLine("ERROR: No filename specified.");
                        Environment.Exit(-1);
                    }

                    exitCode = FirmwareLoader.UploadFirmware(args[0]);
                }
            }
            //	Console.WriteLine("Usage GD77_FirmwareLoader filename");

            Environment.Exit(exitCode);
        }