public OBDParameter(int iService, int iParameter, int iSubParameter) { OBDRequest = OBD2.Int2HexString(iService) + OBD2.Int2HexString(iParameter); Service = iService; Parameter = iParameter; SubParameter = iSubParameter; }
public bool InitializeInterface() { if (m_settings.AutoDetect) { string str2 = OBD2.Int2HexString(50); if (getResponse(new OBD2Request("ATST" + str2)) != null) { if (ChipInfo.IndexOf("ELM327") >= 0) { getResponse(new OBD2Request("ATSP0")); if (getResponse(new OBD2Request("0101")).Response.IndexOf("4101") >= 0) { return(true); } int num = 1; do { getResponse(new OBD2Request("ATSP" + num.ToString())); if (getResponse(new OBD2Request("0101")).Response.IndexOf("4101") >= 0) { return(true); } num++; }while (num < 10); } else if (getResponse(new OBD2Request("0101")).Response.IndexOf("4101") >= 0) { return(true); } } return(false); } string strRequest = "ATST" + m_strElmTimeout; if (getResponse(new OBD2Request(strRequest)) == null) { return(false); } if (m_settings.HardwareIndex == 1) { if (!m_settings.DoInitialization && (getResponse(new OBD2Request("ATBI")) == null)) { return(false); } int protocolIndex = m_settings.ProtocolIndex; if (getResponse(new OBD2Request("ATSP" + protocolIndex.ToString())) == null) { return(false); } if (m_settings.ProtocolIndex == 0) { getResponse(new OBD2Request("0100")); } } return(true); }
public OBD2Interface() { m_obd2Comm = new OBD2Comm(); m_commLog = new CommLog(); m_obd2Comm.OnReceived += new OBD2Comm.__Delegate_OnReceived(On_OBD2_Received); m_userpreferences = LoadUserPreferences(); m_settings = LoadCommSettings(); m_listVehicleProfiles = LoadVehicleProfiles(); m_strElmTimeout = OBD2.Int2HexString(GetActiveProfile().ElmTimeout / 4); m_arrayListPID = new ArrayList(); m_arrayListDTC = new ArrayList(); bool[] flagArray1 = new bool[256]; flagArray1.Initialize(); m_bService01PIDSupport = flagArray1; int index1 = 0; do { m_bService01PIDSupport[index1] = false; ++index1; }while (index1 < 256); bool[] flagArray2 = new bool[256]; flagArray2.Initialize(); m_bService02PIDSupport = flagArray2; int index2 = 0; do { m_bService02PIDSupport[index2] = false; ++index2; }while (index2 < 256); bool[] flagArray3 = new bool[8]; flagArray3.Initialize(); m_bO2Locations = flagArray3; int index3 = 0; do { m_bO2Locations[index3] = false; ++index3; }while (index3 < 8); }
public static string getRequest(int iService, int iPID) { return(OBD2.Int2HexString(iService) + OBD2.Int2HexString(iPID)); }
public bool buildPIDSupportStatusList(int iService) { bool[] flagArray; if (iService != 1) { if (iService != 2) { return(false); } flagArray = m_bService02PIDSupport; } else { flagArray = m_bService01PIDSupport; } int index = 0; do { flagArray[index] = false; index++; }while (index < 256); int iPID = 0; do { Debug.WriteLine("BuildPIDSupportStatusList"); OBD2Response response = getResponse(new OBD2Request(iService, iPID)); Debug.Write(response.Response); if (response == null) { return(false); } if (response.ResponseType != OBD2Response.ResponseTypes.HexData) { return(false); } Debug.WriteLine("Hex Data"); Debug.WriteLine(response.PID); Debug.WriteLine(OBD2.Int2HexString(iPID)); if (string.Compare(response.PID, OBD2.Int2HexString(iPID)) != 0) { return(false); } Debug.WriteLine("Correct PID"); int iECU = 0; if (0 < response.getECUResponseCount()) { do { int iByte = 0; int num4 = 0; do { int num2 = 7; do { if ((response.getDataByte(iECU, iByte) & ((int)Math.Pow(2.0, (double)num2))) != 0) { flagArray[(iPID + (num4 - num2)) + 8] = true; } num2--; }while (num2 >= 0); iByte++; num4 += 8; }while (num4 <= 0x18); iECU++; }while (iECU < response.getECUResponseCount()); } Debug.Write("PID SUPPORT FLAGS: "); int num3 = 0; do { if (flagArray[num3]) { Debug.Write("T"); } else { Debug.Write("F"); } num3++; }while (num3 < 33); iPID = iPID + 32; if (!flagArray[iPID]) { break; } }while (iPID < 0x100); return(true); }
public OBD2Request(int iService, int iPID) { strRequest = OBD2.Int2HexString(iService) + OBD2.Int2HexString(iPID); }