public void ReadPowerDown() { if (mReadOpen) { OBDSerial.GetSingleton().SerialClose(); } }
public void ReadPowerUp() { if (mReadOpen) { OBDSerial.GetSingleton().SerialOpen(GetPort(), GetBaud()); SwitchMode(eMode.MODE_INIT); } }
public void ReadOpen() { if (mReadOpen) { ReadClose(); } mReadOpen = true; OBDSerial.GetSingleton().SerialOpen(GetPort(), GetBaud()); SwitchMode(eMode.MODE_INIT); }
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(); }
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()); }
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); }
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; } } }
public void ReadClose() { mReadOpen = false; SwitchMode(eMode.MODE_NULL); OBDSerial.GetSingleton().SerialClose(); }
private void SendAsciiElm(String message) { OBDSerial.GetSingleton().SerialWrite(message); }
public static void DestroySingleton() { mOBDSerial = null; }
public static void CreateSingleton() { mOBDSerial = new OBDSerial(); }
private void OBDGauge_Closed(object sender, System.EventArgs e) { OBDSensor.DestroySingleton(); OBDRead.DestroySingleton(); OBDSerial.DestroySingleton(); }
static public void DestroySingleton() { mOBDSerial = null; }
static public void CreateSingleton() { mOBDSerial = new OBDSerial(); }