Exemple #1
0
        // codeplug
        private void WriteButton_Click(object sender, EventArgs e)
        {
            if (FilenameTextBox.Text.Equals(""))
            {
                ThemeMessageBox.ShowMessageBox("Please open a codeplug!");
                return;
            }
            byte[] cp     = File.ReadAllBytes(FilenameTextBox.Text);
            byte[] header = new byte[4];
            Array.Copy(cp, 0, header, 0, 4);
            UInt32 inn = BitConverter.ToUInt32(header, 0);

            if (inn != 0x53756644)
            {
                StatusLabel.Text = "writing codeplug...";
                (new Thread(() => {
                    tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);
                    Thread.CurrentThread.IsBackground = true;
                    tr.WriteCodeplug(FilenameTextBox.Text);
                    tr.Reboot();
                    //this.StatusLabel.Text = "Done";
                    //this.nsProgressBar.Value = 0;
                })).Start();
            }
            else
            {
                ThemeMessageBox.ShowMessageBox("Invalid file type.  Must be .dfu");
                return;
            }
        }
Exemple #2
0
        private void FlashUserDBButton_Click(object sender, EventArgs e)
        {
            if (File.Exists("userdb.bin"))
            {
                StatusLabel.Text = "writing userdb.bin ...";
                tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);

                /*tr.WriteUserDB("userdb.bin");
                 * tr.Reboot();*/

                nsProgressBar.Minimum = 0;
                nsProgressBar.Maximum = 100;
                bw = new BackgroundWorker();

                bw.WorkerSupportsCancellation = true;
                bw.WorkerReportsProgress      = true;
                bw.DoWork          += new DoWorkEventHandler(bw_DoWorkWriteUserDB);
                bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
                nsProgressBar.Value = 0;

                bw.RunWorkerAsync();

                /*(new Thread(() => {
                 *  Thread.CurrentThread.IsBackground = true;
                 *  //tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);
                 *  tr.WriteUserDB("userdb.bin");
                 *  tr.Reboot();
                 * })).Start();*/
            }
            else
            {
                ThemeMessageBox.ShowMessageBox("Please download a userdb!");
            }
        }
Exemple #3
0
 private void FlashFirmwareButton_Click(object sender, EventArgs e)
 {
     if (File.Exists("gps_fw.bin") && File.Exists("nongps_fw.bin"))
     {
         ThemeMessageBox.ShowMessageBox("Please download only one firmware!");
     }
     else
     {
         if (File.Exists("gps_fw.bin"))
         {
             StatusLabel.Text = "writing gps_fw.bin ...";
             (new Thread(() => {
                 tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);
                 Thread.CurrentThread.IsBackground = true;
                 tr.WriteFirmware("gps_fw.bin");
                 tr.Reboot();
             })).Start();
         }
         else if (File.Exists("nongps_fw.bin"))
         {
             StatusLabel.Text = "writing nongps_fw.bin ...";
             (new Thread(() => {
                 tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);
                 Thread.CurrentThread.IsBackground = true;
                 tr.WriteFirmware("nongps_fw.bin");
                 tr.Reboot();
             })).Start();
         }
     }
 }
Exemple #4
0
        static void Main(string[] args)
        {
            TyteraRadio tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);

            tr.TickleTickle();
            UInt32 bof = tr.GetSpiID();

            Console.WriteLine("SPI ID: " + bof.ToString("X"));
            //Console.ReadKey();
            //return;

            if (args[0] == "readcp")
            {
                tr.ReadClodeplug(args[1]);
                tr.Reboot();
                Console.WriteLine("Read codeplug to " + args[1]);
            }
            else if (args[0] == "writecp")
            {
                tr.WriteCodeplug(args[1]);
                tr.Reboot();
                Console.WriteLine("Wrote codeplug to " + args[1]);
            }
            else if (args[0] == "userdb")
            {
                Console.WriteLine("Flashing user database");
                tr.WriteUserDB(args[1]);
                Console.WriteLine("Rebooting");
                tr.Reboot();
                Console.WriteLine("Wrote userDB to " + args[1]);
            }
            else if (args[0] == "flash")
            {
                Console.WriteLine("Flashing firmware");
                tr.WriteFirmware(args[1]);
                Console.WriteLine("Rebooting");
                tr.Reboot();
            }
            else if (args[0] == "userdb2017")
            {
                Console.WriteLine("Flashing csv");
                tr.WriteCSV_RT82(args[1]);
                Console.WriteLine("Rebooting");
                tr.Reboot();
            }
            else
            {
                Console.WriteLine("   readcp [file]");
                Console.WriteLine("   writecp [file]");
                Console.WriteLine("   userdb [file]");
                Console.WriteLine("   flash [file]");
                Console.WriteLine("   userdb2017");
            }
            Console.WriteLine("Done!");
            Console.ReadKey();
        }
Exemple #5
0
 private void FlashFirmwareFileButton_Click(object sender, EventArgs e)
 {
     if (!FilenameTextBox.Text.Equals(""))
     {
         StatusLabel.Text = "writing firmware ...";
         (new Thread(() => {
             tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);
             Thread.CurrentThread.IsBackground = true;
             tr.WriteFirmware(FilenameTextBox.Text);
             tr.Reboot();
         })).Start();
     }
     else
     {
         ThemeMessageBox.ShowMessageBox("Please open a firmware!");
     }
 }
Exemple #6
0
        private void ReadButton_Click(object sender, EventArgs e)
        {
            SaveFileDialog textDialog = new SaveFileDialog();

            textDialog.Filter     = "Codeplug Files | *.dfu";
            textDialog.DefaultExt = "dfu";

            DialogResult r = textDialog.ShowDialog();

            if (r == DialogResult.OK)
            {
                StatusLabel.Text = "reading codeplug...";
                (new Thread(() => {
                    Thread.CurrentThread.IsBackground = true;
                    tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);
                    tr.ReadClodeplug(textDialog.FileName);
                    tr.Reboot();
                    //this.StatusLabel.Text = "Done";
                    //this.nsProgressBar.Value = 0;
                })).Start();
            }
        }
Exemple #7
0
        private void FlashfromFileUserDBButton_Click(object sender, EventArgs e)
        {
            StatusLabel.Text = "writing userDB ...";
            tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);

            nsProgressBar.Minimum = 0;
            nsProgressBar.Maximum = 100;
            bw = new BackgroundWorker();

            bw.WorkerSupportsCancellation = true;
            bw.WorkerReportsProgress      = true;
            bw.DoWork          += new DoWorkEventHandler(bw_DoWorkWriteUserDBFile);
            bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
            nsProgressBar.Value = 0;

            bw.RunWorkerAsync();

            /*(new Thread(() => {
             *  tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);
             *  tr.WriteUserDB(FilenameTextBox.Text);
             *  tr.Reboot();
             * })).Start();*/
        }
Exemple #8
0
        static void Main(string[] args)
        {
            TyteraRadio tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);

            tr.TickleTickle();
            //if (!tr.checkSpiID())
            {
                //   Console.WriteLine("USB Connection Failed. Reboot radio.");
                //    Console.ReadKey();
                //    return;
            }
            //Console.ReadKey();
            //return;

            /* Console.WriteLine("Dumping frame buffers for screen shot");
             * //byte[] shot = tr.ScreenShotBMP();
             * //File.WriteAllBytes("screenshot.bmp", shot);
             * int width2 = 160;
             * int height2 = 128;
             *
             * byte[] BMPDATA = null;
             * while (BMPDATA == null) { BMPDATA = tr.ScreenShotBMP(); }
             * //File.WriteAllBytes("bmpdata.bin", BMPDATA);
             * if (BMPDATA != null)
             * {
             *
             *   Bitmap bmp = new Bitmap(width2, height2, PixelFormat.Format24bppRgb);
             *
             *   BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width2, height2), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
             *
             *   IntPtr ptr = bmpData.Scan0;
             *   Marshal.Copy(BMPDATA, 0, ptr, height2 * width2 * 3);
             *   bmp.UnlockBits(bmpData);
             *   bmp.Save("screenshot.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
             *
             *   Console.WriteLine("Done.");
             *   Console.ReadKey();
             * }
             * return;*/

            if (args[0] == "readcp")
            {
                byte[] data = tr.ReadClodeplug();
                //byte[] FFF = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
                //Array.Copy(FFF, 0, data, 0xA0, 8);
                //tr.ReadClodeplug(args[1]);
                File.WriteAllBytes(args[1], data);
                tr.Reboot();
                Console.WriteLine("Read codeplug to " + args[1]);
            }
            else if (args[0] == "dumpspiflash")
            {
                byte[] data = tr.ReadSPIFlash(0, 1024 * 1000);
                //byte[] FFF = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
                //Array.Copy(FFF, 0, data, 0xA0, 8);
                //tr.ReadClodeplug(args[1]);
                File.WriteAllBytes(args[1], data);
                tr.Reboot();
                Console.WriteLine("dump spiflash to " + args[1]);
            }
            else if (args[0] == "fixpass")
            {
                tr.FixPassword();
            }
            else if (args[0] == "writecp")
            {
                tr.WriteCodeplug(args[1]);
                tr.Reboot();
                Console.WriteLine("Wrote codeplug to " + args[1]);
            }
            else if (args[0] == "userdb")
            {
                Console.WriteLine("Flashing user database");
                tr.WriteUserDB(args[1]);
                Console.WriteLine("Rebooting");
                tr.Reboot();
                Console.WriteLine("Wrote userDB to " + args[1]);
            }
            else if (args[0] == "flash")
            {
                Console.WriteLine("Flashing firmware");
                tr.WriteFirmware(args[1]);
                Console.WriteLine("Rebooting");
                tr.Reboot();
            }
            else if (args[0] == "userdb2017")
            {
                Console.WriteLine("Flashing csv");
                tr.WriteCSV_RT82(args[1]);
                Console.WriteLine("Rebooting");
                tr.Reboot();
            }
            else if (args[0] == "screenshot")
            {
                Console.WriteLine("Dumping frame buffers for screen shot");
                //byte[] shot = tr.ScreenShotBMP();
                //File.WriteAllBytes("screenshot.bmp", shot);
                int width  = 160;
                int height = 128;

                byte[] BMPDATA2 = tr.ScreenShotBMP();
                //File.WriteAllBytes("bmpdata.bin", BMPDATA);
                if (BMPDATA2 != null)
                {
                    Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);

                    BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);

                    IntPtr ptr = bmpData.Scan0;
                    Marshal.Copy(BMPDATA2, 0, ptr, height * width * 3);
                    bmp.UnlockBits(bmpData);
                    bmp.Save("screenshot.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
                }
            }
            else if (args[0] == "test")
            {
                Console.WriteLine("Flashing firmware");
                tr.WriteFirmwareTest(File.ReadAllBytes(args[1]));
                Console.WriteLine("Rebooting");
                tr.Reboot();

                /*if (tr.isInDFU())
                 * {
                 *  Console.WriteLine("DFU mode, rebooting to normal mode");
                 *  tr.Reboot();
                 *  Thread.Sleep(7000);
                 *  tr = new TyteraRadio(TyteraRadio.RadioModel.RM_MD380);
                 *
                 *  tr.TickleTickle();
                 *  if (!tr.checkSpiID())
                 *  {
                 *      Console.WriteLine("USB Connection Failed. Reboot radio.");
                 *      Console.ReadKey();
                 *      return;
                 *  }
                 *  if (!tr.isInDFU())
                 *  {
                 *      Console.WriteLine("Success! Radio in normal mode.");
                 *  }
                 *
                 * }
                 * else
                 * {
                 *  Console.WriteLine("Normal mode");
                 * }*/
            }
            else
            {
                Console.WriteLine("   readcp [file]");
                Console.WriteLine("   writecp [file]");
                Console.WriteLine("   userdb [file]");
                Console.WriteLine("   flash [file]");
                Console.WriteLine("   userdb2017");
            }
            Console.WriteLine("Done!");
            Console.ReadKey();
        }