Esempio n. 1
0
 private void DtcMenuItem_Click(object sender, System.EventArgs e)
 {
     OBDCodes.CreateSingleton();
     OBDRead.GetSingleton().ReadReadCodes();
     OBDCodes.GetSingleton().ShowDialog();
     OBDCodes.DestroySingleton();
     OBDRead.GetSingleton().ReadRestart();
 }
Esempio n. 2
0
        private void ObdReplyComplete()
        {
            switch (mMode)
            {
            case eMode.MODE_NULL:
                // do nothing
                break;

            case eMode.MODE_INIT:
                if (mPrefs.Interface == eInterface.INTERFACE_ELM)
                {
                    SwitchMode(eMode.MODE_ECHO_OFF);
                }
                break;

            case eMode.MODE_ECHO_OFF:
                SwitchMode(eMode.MODE_LINEFEED_OFF);
                break;

            case eMode.MODE_LINEFEED_OFF:
                SwitchMode(eMode.MODE_SET_TIMEOUT);
                break;

            case eMode.MODE_SET_TIMEOUT:
                SwitchMode(eMode.MODE_READ_PIDS);
                break;

            case eMode.MODE_READ_PIDS:
                break;

            case eMode.MODE_READ_SENSORS:
                mNeedInit = false;
                if (mReadCodes)
                {
                    mReadCodes = false;
                    SendMILQuery();
                    SwitchMode(eMode.MODE_READ_MIL);
                }
                else
                {
                    SendSensorQuery();
                }
                break;

            case eMode.MODE_READ_MIL:
                SwitchMode(eMode.MODE_READ_ACTIVE_CODES);
                break;

            case eMode.MODE_READ_ACTIVE_CODES:
                SwitchMode(eMode.MODE_READ_PENDING_CODES);
                break;

            case eMode.MODE_READ_PENDING_CODES:
                SwitchMode(eMode.MODE_NULL);
                if (OBDCodes.GetSingleton() != null)
                {
                    OBDCodes.GetSingleton().CodesReadComplete();
                }
                break;

            case eMode.MODE_CLEAR_CODES:
                SwitchMode(eMode.MODE_INIT);
                ReadReadCodes();
                break;
            }
        }
Esempio n. 3
0
        private void ReadObd(byte[] message, int start, int length)
        {
            if (length == 0)
            {
                return;
            }
            switch (message[start])
            {
            case 0x41:             // sensor report
                if (length < 3)
                {
                    return;
                }
                switch (message[start + 1])
                {
                case 0x00:                 // supported PIDs
                    if (length < 6)
                    {
                        return;
                    }
                    mSupportedPids = BytesToUInt32(message, start + 2);
                    mActivePids    = 0;
                    OBDSensor.GetSingleton().SensorInit(mSupportedPids);
                    SwitchMode(eMode.MODE_READ_SENSORS);
                    break;

                case 0x01:                 // trouble codes count
                    if (length < 3)
                    {
                        return;
                    }
                    if (OBDCodes.GetSingleton() != null)
                    {
                        OBDCodes.GetSingleton().CodesSetMIL((message[start + 2] & 0x80) != 0);
                    }
                    break;

                default:
                    mTicks = DateTime.Now;
                    OBDSensor.GetSingleton().SensorReceiveElmObd(message, start, length);
                    break;
                }
                break;

            case 0x43:             // active trouble codes
                if (OBDCodes.GetSingleton() != null)
                {
                    OBDCodes.GetSingleton().CodesReceiveElmObd(message, length);
                }
                break;

            case 0x47:             // pending trouble codes
                if (OBDCodes.GetSingleton() != null)
                {
                    OBDCodes.GetSingleton().CodesReceiveElmObd(message, length);
                }
                break;

            case 0x44:             // clear trouble codes
                if (OBDCodes.GetSingleton() != null)
                {
                    OBDCodes.GetSingleton().CodesSetClearCodes();
                }
                break;
            }
        }
Esempio n. 4
0
 static public void DestroySingleton()
 {
     mOBDCodes = null;
 }
Esempio n. 5
0
 static public void CreateSingleton()
 {
     mOBDCodes = new OBDCodes();
 }
Esempio n. 6
0
 public static void DestroySingleton()
 {
     mOBDCodes = null;
 }
Esempio n. 7
0
 public static void CreateSingleton()
 {
     mOBDCodes = new OBDCodes();
 }