Beispiel #1
0
 public void ReadPowerDown()
 {
     if (mReadOpen)
     {
         OBDSerial.GetSingleton().SerialClose();
     }
 }
Beispiel #2
0
 public void ReadPowerUp()
 {
     if (mReadOpen)
     {
         OBDSerial.GetSingleton().SerialOpen(GetPort(), GetBaud());
         SwitchMode(eMode.MODE_INIT);
     }
 }
Beispiel #3
0
 public void ReadOpen()
 {
     if (mReadOpen)
     {
         ReadClose();
     }
     mReadOpen = true;
     OBDSerial.GetSingleton().SerialOpen(GetPort(), GetBaud());
     SwitchMode(eMode.MODE_INIT);
 }
Beispiel #4
0
 private void OBDGauge_Load(object sender, System.EventArgs e)
 {
     OBDSerial.CreateSingleton();
     OBDRead.CreateSingleton();
     OBDSensor.CreateSingleton();
     OBDPrefs.LoadPrefs(mPrefs);
     OBDRead.GetSingleton().Prefs   = mPrefs;
     OBDSensor.GetSingleton().Prefs = mPrefs;
     OBDSensor.GetSingleton().Init();
 }
Beispiel #5
0
        private void SendObdElm(byte[] message, int length)
        {
            StringBuilder sb = new StringBuilder();
            int           i;

            for (i = 0; i < length; i++)
            {
                sb.Append(message[i].ToString("X2"));
            }
            sb.Append('\r');
            OBDSerial.GetSingleton().SerialWrite(sb.ToString());
        }
Beispiel #6
0
        private void SendObdMultiplex(byte[] message, int length, bool multi)
        {
            byte[] command = new byte[15];
            int    i, cs;

            command[0] = mPrefs.Address;
            switch (mPrefs.Protocol)
            {
            case eProtocol.PROTOCOL_ISO:
                command[1] = (byte)(mNeedInit ? 0x01 : (multi ? 0x10 : 0x81));
                command[3] = 0x68;
                command[4] = 0x6a;
                break;

            case eProtocol.PROTOCOL_VPW:
                command[1] = (byte)(multi ? 0x02 : 0x82);
                command[3] = 0x68;
                command[4] = 0x6a;
                break;

            case eProtocol.PROTOCOL_PWM:
                command[1] = (byte)(multi ? 0x04 : 0x84);
                command[3] = 0x61;
                command[4] = 0x6a;
                break;

            case eProtocol.PROTOCOL_KWP:
                command[1] = (byte)(mNeedInit? 0x85 : (multi ? 0x88 : 0x89));
                command[3] = 0xc7;
                command[4] = 0x33;
                break;

            default:
                return;
            }
            command[2] = (byte)(length + 3);
            command[5] = 0xf1;
            for (i = 0; i < 8; i++)
            {
                command[i + 6] = i < length ? message[i] : (byte)0;
            }
            cs = 0;
            for (i = 1; i < 14; i++)
            {
                cs += command[i];
            }
            command[14] = (byte)(cs & 0xff);
            OBDSerial.GetSingleton().SerialWrite(command, 15);
        }
Beispiel #7
0
        public void ReadSerial()
        {
            while (OBDSerial.GetSingleton().SerialCheck() > 0)
            {
                byte[] data = OBDSerial.GetSingleton().SerialRead();
                switch (mPrefs.Interface)
                {
                case eInterface.INTERFACE_ELM:
                    ReadSerialElm(data);
                    break;

                case eInterface.INTERFACE_MULTIPLEX:
                    ReadSerialMultiplex(data);
                    break;
                }
            }
        }
Beispiel #8
0
 public void ReadClose()
 {
     mReadOpen = false;
     SwitchMode(eMode.MODE_NULL);
     OBDSerial.GetSingleton().SerialClose();
 }
Beispiel #9
0
 private void SendAsciiElm(String message)
 {
     OBDSerial.GetSingleton().SerialWrite(message);
 }
Beispiel #10
0
 public static void DestroySingleton()
 {
     mOBDSerial = null;
 }
Beispiel #11
0
 public static void CreateSingleton()
 {
     mOBDSerial = new OBDSerial();
 }
Beispiel #12
0
 private void OBDGauge_Closed(object sender, System.EventArgs e)
 {
     OBDSensor.DestroySingleton();
     OBDRead.DestroySingleton();
     OBDSerial.DestroySingleton();
 }
Beispiel #13
0
 static public void DestroySingleton()
 {
     mOBDSerial = null;
 }
Beispiel #14
0
 static public void CreateSingleton()
 {
     mOBDSerial = new OBDSerial();
 }