Exemple #1
0
 void frmfaults_onClearCurrentDTC(object sender, frmFaultcodes.ClearDTCEventArgs e)
 {
     // clear the currently selected DTC code from the ECU
     if (e.DTCCode.StartsWith("P"))
     {
         m_prohibitReading = true;
         try
         {
             int DTCCode = Convert.ToInt32(e.DTCCode.Substring(1, e.DTCCode.Length - 1), 16);
             if (CheckCANConnectivity())
             {
                 trionic7.ClearDTCCode(DTCCode);
             }
             if (sender is frmFaultcodes)
             {
                 frmFaultcodes frmfaults = (frmFaultcodes)sender;
                 bool _success = false;
                 frmfaults.ClearCodes();
                 int symbolnumber = GetSymbolNumber(m_symbols, "obdFaults");
                 if (symbolnumber == 0)
                 {
                     // not connected to ECU
                     frmInfoBox info = new frmInfoBox("Cannot find symbolnumber for symbol obdFaults, ECU binary must be loaded");
                 }
                 byte[] buffer = ReadSymbolFromSRAM((uint)symbolnumber, "obdFaults", (uint)GetSymbolAddressSRAM(m_symbols, "obdFaults"), GetSymbolLength(m_symbols, "obdFaults"), out _success);
                 if (_success)
                 {
                     for (int t = 0; t < buffer.Length; t += 2)
                     {
                         if (buffer[t] == 0x00 && buffer[t + 1] == 0x00)
                         {
                             break;
                         }
                         else
                         {
                             //faultCodes += "P" + buffer[t].ToString("X2") + buffer[t + 1].ToString("X2") + Environment.NewLine;
                             frmfaults.addFault("P" + buffer[t].ToString("X2") + buffer[t + 1].ToString("X2"));
                         }
                     }
                 }
             }
         }
         catch (Exception E)
         {
             logger.Debug(E.Message);
         }
         m_prohibitReading = false;
     }
 }
Exemple #2
0
        void frmfaults_onClearCurrentDTC(object sender, frmFaultcodes.ClearDTCEventArgs e)
        {
            // clear the currently selected DTC code from the ECU
            if (e.DTCCode.StartsWith("P"))
            {
                try
                {
                    int DTCCode = Convert.ToInt32(e.DTCCode.Substring(1, e.DTCCode.Length - 1), 16);

                    //TODO ClearDTCCodes() must be added to the api
                    //t8can.ClearDTCCodes(DTCCode);

                    if (sender is frmFaultcodes)
                    {
                        frmFaultcodes frmfaults = (frmFaultcodes)sender;
                        frmfaults.ClearCodes();

                        string[] faults = t8can.ReadDTC();
                        foreach (string fault in faults)
                        {
                            frmfaults.addFault(fault.Substring(5, 5));
                        }
                        frmfaults.Show();
                    }
                }
                catch (Exception E)
                {
                    logger.Debug(E.Message);
                }
            }
        }
Exemple #3
0
        private void btnReadFaultCodes_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (CheckCANConnectivity())
            {
                // 16 25 16 22 00 00 00 00 00 00 00 00
                frmFaultcodes frmfaults = new frmFaultcodes();
                frmfaults.onClearCurrentDTC += new frmFaultcodes.onClearDTC(frmfaults_onClearCurrentDTC);
                m_prohibitReading = true;
                bool _success = false;
                string faultCodes = string.Empty;
                int symbolnumber = GetSymbolNumber(m_symbols, "obdFaults");
                if (symbolnumber == 0)
                {
                    // not connected to ECU
                    frmInfoBox info = new frmInfoBox("Cannot find symbolnumber for symbol obdFaults, ECU binary must be loaded");
                }
                byte[] buffer = ReadSymbolFromSRAM((uint)symbolnumber, "obdFaults", (uint)GetSymbolAddressSRAM(m_symbols, "obdFaults"), GetSymbolLength(m_symbols, "obdFaults"), out _success);
                if (_success)
                {
                    for (int t = 0; t < buffer.Length; t += 2)
                    {
                        if (buffer[t] == 0x00 && buffer[t + 1] == 0x00)
                        {
                            break;
                        }
                        else
                        {
                            //faultCodes += "P" + buffer[t].ToString("X2") + buffer[t + 1].ToString("X2") + Environment.NewLine;
                            frmfaults.addFault("P" + buffer[t].ToString("X2") + buffer[t + 1].ToString("X2"));
                        }
                    }
                }

                frmfaults.Show();
                m_prohibitReading = false;

            }
            else
            {
                // not connected to ECU
                frmInfoBox info = new frmInfoBox("An active CAN bus connection is needed to read faultcodes");
            }
        }
Exemple #4
0
        private void btnReadFaultCodes_ItemClick(object sender, ItemClickEventArgs e)
        {
            // Connect at accesslevel01, need to close connection if already open
            if (m_connectedToECU)
            {
                t8can.Cleanup();
                m_connectedToECU = false;
            }
            SetCanAdapter();
            t8can.SecurityLevel = AccessLevel.AccessLevel01;
            t8can.openDevice(false);

            frmFaultcodes frmfaults = new frmFaultcodes();
            frmfaults.onClearCurrentDTC += new frmFaultcodes.onClearDTC(frmfaults_onClearCurrentDTC);
            frmfaults.onCloseFrm += new frmFaultcodes.frmClose(frmfaults_onClose);

            string[] faults = t8can.ReadDTC();
            foreach (string fault in faults)
            {
                frmfaults.addFault(fault.Substring(5,5));
            }
            frmfaults.Show();
        }