예제 #1
0
파일: Loader.cs 프로젝트: Lorain-Li/SelTest
 /// <summary>
 /// 显示进度
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CopyThread_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     TxtInfo.AppendText(e.UserState.ToString());
     if (e.ProgressPercentage == 10)
     {
         BarPross.Value++;
     }
 }
예제 #2
0
 private void AddInfo(string info)
 {
     TxtInfo.AppendText(info + Environment.NewLine);
 }
예제 #3
0
파일: mainform.cs 프로젝트: junimp/TL866
        public void UsbDeviceChanged()
        {
            if (usbdevice.DevicesCount == 0 && reset_flag)
            {
                return;
            }
            reset_flag = false;
            Assembly        assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo version  = FileVersionInfo.GetVersionInfo(assembly.Location);

            Text = string.Format("TL866 firmware updater  V{0}   ({1} {2} connected)", version.FileVersion,
                                 usbdevice.DevicesCount,
                                 usbdevice.DevicesCount == 1 ? "device" : "devices");
            if (usbdevice.DevicesCount > 0 && usbdevice.OpenDevice(usbdevice.Get_Devices()[0]))
            {
                TL866_Report tl866_report = new TL866_Report();
                Get_Report(tl866_report);
                TxtInfo.Clear();
                switch (tl866_report.Device_Version)
                {
                case 1:
                    TxtInfo.AppendText("Device version: TL866A\n");
                    devtype = (int)Firmware.PROGRAMMER_TYPE.TL866A;
                    break;

                case 2:
                    TxtInfo.AppendText("Device version: TL866CS\n");
                    devtype = (int)Firmware.PROGRAMMER_TYPE.TL866CS;
                    break;

                default:
                    TxtInfo.AppendText("Device version: Unknown\n");
                    break;
                }
                switch ((Firmware.DEVICE_STATUS)tl866_report.Device_Status)
                {
                case Firmware.DEVICE_STATUS.NORMAL_MODE:
                    TxtInfo.AppendText("Device status: Normal working mode.\n");
                    LedNorm.BackColor = LightGreen;
                    LedBoot.BackColor = DarkGreen;
                    break;

                case Firmware.DEVICE_STATUS.BOOTLOADER_MODE:
                    TxtInfo.AppendText("Device status: Bootloader mode <waiting for update.>\n");
                    LedNorm.BackColor = DarkGreen;
                    LedBoot.BackColor = LightGreen;
                    break;

                default:
                    TxtInfo.AppendText("Device status: Unknown\n");
                    LedNorm.BackColor = DarkGreen;
                    LedBoot.BackColor = DarkGreen;
                    break;
                }


                bool isDumperActive = IsDumperActive();

                if (isDumperActive)
                {
                    usbdevice.Write(new[] { Firmware.DUMPER_INFO });
                    Dumper_Report dumper_report = new Dumper_Report();
                    if (usbdevice.Read(dumper_report.buffer) > 0)
                    {
                        devcode = dumper_report.DeviceCode;
                        serial  = dumper_report.SerialCode;
                    }
                    else
                    {
                        devcode = string.Empty;
                        serial  = string.Empty;
                    }
                }
                else
                {
                    devcode = tl866_report.DeviceCode;
                    serial  = tl866_report.SerialCode;
                }


                if (AdvancedWindow != null && !AdvancedWindow.IsDisposed)
                {
                    GetInfo();
                }
                TxtInfo.AppendText(string.Format("Device code: {0}{1}\n", devcode,
                                                 Firmware.Calc_CRC(devcode, serial) ? "(Bad device code)" : string.Empty));
                TxtInfo.AppendText(string.Format("Serial number: {0}{1}\n", serial,
                                                 Firmware.Calc_CRC(devcode, serial) ? "(Bad serial code)" : string.Empty));
                TxtInfo.AppendText(string.Format("Firmware version: {0}\n",
                                                 isDumperActive
                        ? "Firmware dumper"
                        : tl866_report.Device_Status == (byte)Firmware.DEVICE_STATUS.NORMAL_MODE
                            ? string.Format("{0}.{1}.{2}", tl866_report.hardware_version,
                                            tl866_report.firmware_version_major,
                                            tl866_report.firmware_version_minor)
                            : "Bootloader\n"));
                BtnDump.Enabled     = isDumperActive;
                BtnAdvanced.Enabled = isDumperActive;
                byte cs = 0;
                for (int i = 5; i < 8; i++)
                {
                    cs += (byte)tl866_report.DeviceCode[i];
                }
                for (int i = 0; i < 24; i++)
                {
                    cs += (byte)tl866_report.SerialCode[i];
                }
                cs += tl866_report.b0;
                cs += tl866_report.b1;
                if (tl866_report.firmware_version_minor > 82 && cs != tl866_report.checksum && tl866_report.bad_serial == 0)
                {
                    TxtInfo.AppendText("Bad serial checksum.");
                }

                if (tl866_report.firmware_version_minor > 82 && tl866_report.bad_serial != 0)
                {
                    TxtInfo.AppendText("Bad serial.");
                }
            }
            else
            {
                BtnDump.Enabled     = false;
                BtnAdvanced.Enabled = false;
                Leds_Off();
                TxtInfo.Clear();
                devcode = string.Empty;
                serial  = string.Empty;
                if (AdvancedWindow != null && !AdvancedWindow.IsDisposed)
                {
                    GetInfo();
                }
            }
        }