Ejemplo n.º 1
0
 internal void DisableLogging()
 {
     if (_usbcandevice != null)
     {
         _usbcandevice.DisableLogging();
     }
 }
Ejemplo n.º 2
0
        // FLASH
        private void btnFLASH_Click(object sender, EventArgs e)
        {
            manageControls(programMode.active);
            if (cboxEnLog.Checked)
            {
                device.EnableLogging(Application.StartupPath);
            }
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter      = "Binary files|*.bin";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                FileInfo fi          = new FileInfo(ofd.FileName);
                bool     OkToUpgrade = true;
                switch (ECU_type)
                {
                case ECUType.T52ECU:
                    if (fi.Length != 0x20000)
                    {
                        MessageBox.Show("Not a Trionic 5.2 BIN File",
                                        "ERROR",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
                    }
                    OkToUpgrade = false;
                    break;

                case ECUType.T55ECU:
                    switch (fi.Length)
                    {
                    case 0x20000:
                        DialogResult result = MessageBox.Show("Do you want to upload a T5.2 BIN file to your T5.5 ECU",
                                                              "ECU Conversion Question",
                                                              MessageBoxButtons.YesNo,
                                                              MessageBoxIcon.Question,
                                                              MessageBoxDefaultButton.Button2);
                        OkToUpgrade = (result == DialogResult.Yes) ? true : false;
                        break;

                    case 0x40000:
                        break;

                    default:
                        MessageBox.Show("Not a Trionic 5.5 BIN File",
                                        "ERROR",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
                        OkToUpgrade = false;
                        break;
                    }
                    break;

                case ECUType.T55AST52:
                    switch (fi.Length)
                    {
                    case 0x20000:
                        break;

                    case 0x40000:
                        DialogResult result = MessageBox.Show("Do you want to upload a T5.5 BIN file to your ECU that has been used as a T5.2?",
                                                              "ECU Conversion Question",
                                                              MessageBoxButtons.YesNo,
                                                              MessageBoxIcon.Question,
                                                              MessageBoxDefaultButton.Button2);
                        OkToUpgrade = (result == DialogResult.Yes) ? true : false;
                        break;

                    default:
                        MessageBox.Show("Not a Trionic BIN File",
                                        "ERROR",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
                        OkToUpgrade = false;
                        break;
                    }
                    break;
                }

                if (OkToUpgrade)
                {
                    AddToLog("Starting FLASH update session...");
                    statusActivity.Text = "Updating FLASH";
                    T5CANLib.UpgradeResult result = t5can.UpgradeECU(ofd.FileName, ECU_type);
                    statusActivity.Text = "IDLE";
                    switch (result)
                    {
                    case T5CANLib.UpgradeResult.Success:
                        AddToLog("!!! SUCCESS !!!");
                        getECUinfo();
                        AddToLog("Your ECU is ready to use your new BIN file :-)");
                        break;

                    case T5CANLib.UpgradeResult.InvalidFile:
                        AddToLog("!!! ERROR !!! Invalid file for the selected ECU type :-o");
                        break;

                    case T5CANLib.UpgradeResult.InvalidECUType:
                        AddToLog("!!! ERROR !!! Invalid ECU type selected :-o");
                        break;

                    case T5CANLib.UpgradeResult.ProgrammingFailed:
                        AddToLog("!!! FAILURE !!! Could not program the FLASH in your ECU :-(");
                        break;

                    case T5CANLib.UpgradeResult.EraseFailed:
                        AddToLog("!!! FAILURE !!! Could not erase the FLASH in your ECU :-(");
                        break;

                    case T5CANLib.UpgradeResult.ChecksumFailed:
                        AddToLog("!!! FAILURE !!! Checksums don't match after FLASHing :-(");
                        break;

                    default:
                        AddToLog("!!! ERROR!!! There was a problem I haven't catered for ???");
                        break;
                    }
                    switch (result)
                    {
                    case T5CANLib.UpgradeResult.ProgrammingFailed:
                    case T5CANLib.UpgradeResult.EraseFailed:
                    case T5CANLib.UpgradeResult.ChecksumFailed:
                        AddToLog("There are many reasons why you saw this error message,");
                        AddToLog("e.g. a problem with your power supply voltage or you may");
                        AddToLog("be unlucky enough to have 'Bad FLASH chips' :-(");
                        AddToLog("You should retry FLASHing your BIN file but if it fails");
                        AddToLog("again your only option is to try to recover your ECU");
                        AddToLog("using a BDM interface !!!");
                        break;

                    default:
                        break;
                    }
                }
            }
            device.DisableLogging();
            manageControls(programMode.connected);
        }