Exemplo n.º 1
0
        private bool CheckFlashStatus()
        {
            AddToCanTrace("Start CheckFlashStatus");
            T7.Flasher.T7Flasher.FlashStatus stat = flash.getStatus();
            AddToCanTrace("Status retrieved");
            switch (stat)
            {
            case T7.Flasher.T7Flasher.FlashStatus.Completed:
                AddToCanTrace("Status = T7.Flasher.T7Flasher.FlashStatus.Completed");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.DoinNuthin:
                AddToCanTrace("Status = T7.Flasher.T7Flasher.FlashStatus.DoinNuthin");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.EraseError:
                AddToCanTrace("Status = T7.Flasher.T7Flasher.FlashStatus.EraseError");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.Eraseing:
                AddToCanTrace("Status = T7.Flasher.T7Flasher.FlashStatus.Eraseing");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.NoSequrityAccess:
                AddToCanTrace("Status = T7.Flasher.T7Flasher.FlashStatus.NoSequrityAccess");
                flash.stopFlasher();
                break;

            case T7.Flasher.T7Flasher.FlashStatus.NoSuchFile:
                AddToCanTrace("Status = T7.Flasher.T7Flasher.FlashStatus.NoSuchFile");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.ReadError:
                AddToCanTrace("Status = T7.Flasher.T7Flasher.FlashStatus.ReadError");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.Reading:
                AddToCanTrace("Status = T7.Flasher.T7Flasher.FlashStatus.Reading");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.WriteError:
                AddToCanTrace("Status = T7.Flasher.T7Flasher.FlashStatus.WriteError");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.Writing:
                AddToCanTrace("Status = T7.Flasher.T7Flasher.FlashStatus.Writing");
                break;

            default:
                AddToCanTrace("Status = " + stat.ToString());
                break;
            }
            bool retval = true;

            if (stat == T7.Flasher.T7Flasher.FlashStatus.Eraseing || stat == T7.Flasher.T7Flasher.FlashStatus.Reading || stat == T7.Flasher.T7Flasher.FlashStatus.Writing)
            {
                retval = false;
            }
            return(retval);
        }
Exemplo n.º 2
0
        private void tmrWriteProcessChecker_Tick(object sender, EventArgs e)
        {
            float numberkb = (float)flash.getNrOfBytesRead() / 1024F;

            label1.Text = "Flashed " + numberkb.ToString("F1") + " of 512 kB";
            int percentage = ((int)numberkb * 100) / 512;

            //frmFlasherProgress.SetProgressPercentage(percentage);
            progressBar1.Value = percentage;
            //AddToCanTrace("Flashed " + numberkb.ToString("F1") + " of 512 kB");
            T7.Flasher.T7Flasher.FlashStatus stat = flash.getStatus();
            switch (stat)
            {
            case T7.Flasher.T7Flasher.FlashStatus.Completed:
                AddToCanTrace("tmrWriteProcessChecker_Tick: Completed flashing procedure");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.DoinNuthin:
                AddToCanTrace("tmrWriteProcessChecker_Tick: DoinNuthin");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.EraseError:
                AddToCanTrace("tmrWriteProcessChecker_Tick: EraseError");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.Eraseing:
                AddToCanTrace("tmrWriteProcessChecker_Tick: Eraseing");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.NoSequrityAccess:
                AddToCanTrace("tmrWriteProcessChecker_Tick: NoSequrityAccess");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.NoSuchFile:
                AddToCanTrace("tmrWriteProcessChecker_Tick: NoSuchFile");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.ReadError:
                AddToCanTrace("tmrWriteProcessChecker_Tick: ReadError");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.Reading:
                //AddToCanTrace("tmrWriteProcessChecker_Tick: Reading");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.WriteError:
                AddToCanTrace("tmrWriteProcessChecker_Tick: WriteError");
                break;

            case T7.Flasher.T7Flasher.FlashStatus.Writing:
                //AddToCanTrace("tmrWriteProcessChecker_Tick: Writing");
                break;
            }

            if (stat == T7.Flasher.T7Flasher.FlashStatus.Completed)
            {
                flash.stopFlasher();
                tmrWriteProcessChecker.Enabled = false;
                //EnableCANInteractionButtons();
                //MessageBox.Show("Done downloading binary file!");
                AddToLog("Finished flash session");
                //KWPHandler.getInstance().ResetECU();
                //AddToLog("ECU is reset");
                if (autoWrite)
                {
                    Thread.Sleep(100);
                    this.Close();
                }
            }
            else if (stat == T7.Flasher.T7Flasher.FlashStatus.NoSequrityAccess)
            {
                flash.stopFlasher();
                tmrWriteProcessChecker.Enabled = false;
                AddToLog("No security access granted");
                if (autoWrite)
                {
                    this.Close();
                }
            }
            else if (stat == T7.Flasher.T7Flasher.FlashStatus.EraseError)
            {
                flash.stopFlasher();
                tmrWriteProcessChecker.Enabled = false;
                AddToLog("An erase error occured");
                if (autoWrite)
                {
                    this.Close();
                }
            }
            else if (stat == T7.Flasher.T7Flasher.FlashStatus.NoSuchFile)
            {
                flash.stopFlasher();
                tmrWriteProcessChecker.Enabled = false;
                AddToLog("File not found");
                if (autoWrite)
                {
                    this.Close();
                }
            }
            else if (stat == T7.Flasher.T7Flasher.FlashStatus.WriteError)
            {
                flash.stopFlasher();
                tmrWriteProcessChecker.Enabled = false;
                AddToLog("A write error occured, please retry to flash without cutting power to the ECU");
            }
        }