public bool InitializeOBD2() { OBD2Response response = getResponse(new OBD2Request("ATDPN")); if (response == null) { return(false); } m_iProtocol = OBD2.Hex2Int(response.Response.Replace("A", "")); if (!buildPIDSupportStatusList(1)) { return(false); } buildO2Locations(); return(true); }
public static int HexString2Int(string strHex) { int num1 = 0; int num2 = strHex.Length - 1; int startIndex = num2; if (num2 >= 0) { int num3 = 0; do { string strDigit = strHex.Substring(startIndex, 1).ToUpper(); num1 = (int)Math.Pow(16.0, (double)num3) * OBD2.Hex2Int(strDigit) + num1; --startIndex; ++num3; }while (startIndex >= 0); } return(num1); }