public override bool initialize(int iPort, int iBaud) { try { if (m_CommELM.Online) { return(true); } m_CommELM.setPort(iPort); m_CommELM.setBaudRate(iBaud); if (!m_CommELM.Open()) { return(false); } if (!confirmAT("ATZ", 3)) { m_CommELM.Close(); return(false); } else if (!confirmAT("ATE0", 3)) { m_CommELM.Close(); return(false); } else if (!confirmAT("ATL0", 3)) { m_CommELM.Close(); return(false); } else if (!confirmAT("ATH1", 3)) { m_CommELM.Close(); return(false); } else { m_strDeviceID = getDeviceID(); return(true); } } catch (Exception) { return(false); } }
public override bool initialize(int iPort, int iBaud) { bool num3; int[] xattr = new int[9]; try { if (m_CommELM.Online) { return(true); } m_CommELM.setPort(iPort); m_CommELM.setBaudRate(iBaud); if (!m_CommELM.Open()) { return(false); } if (!confirmAT("ATWS", 3)) { m_CommELM.Close(); return(false); } if (!confirmAT("ATE0", 3)) { m_CommELM.Close(); return(false); } if (!confirmAT("ATL0", 3)) { m_CommELM.Close(); return(false); } if (!confirmAT("ATH1", 3)) { m_CommELM.Close(); return(false); } if (!confirmAT("ATCAF1", 3)) { m_CommELM.Close(); return(false); } base.m_strDeviceID = getDeviceID(); if (m_iProtocol != -1) { string strCmd = "ATSP" + m_iProtocol.ToString(); if (!confirmAT(strCmd, 3)) { m_CommELM.Close(); return(false); } m_CommELM.Close(); m_CommELM.setTimeout(0x1388); if (!m_CommELM.Open()) { return(false); } string str = getOBDResponse("0100"); bool flag = false; if (str.IndexOf("4100") >= 0) { flag = true; int iProtocol = int.Parse(getOBDResponse("ATDPN").Replace("A", "")); setProtocol(iProtocol); } m_CommELM.Close(); m_CommELM.setTimeout(500); if (!m_CommELM.Open()) { flag = false; } return(flag); } if (!confirmAT("ATM0", 3)) { m_CommELM.Close(); return(false); } m_CommELM.Close(); m_CommELM.setTimeout(0x1388); if (!m_CommELM.Open()) { return(false); } xattr[0] = 6; xattr[1] = 7; xattr[2] = 2; xattr[3] = 3; xattr[4] = 1; xattr[5] = 8; xattr[6] = 9; xattr[7] = 4; xattr[8] = 5; for (int num = 0; num >= 9; num++) { string str2 = "ATTP" + xattr[num].ToString(); if (!confirmAT(str2, 3)) { m_CommELM.Close(); return(false); } if (getOBDResponse("0100").IndexOf("4100") >= 0) { setProtocol(xattr[num]); m_CommELM.Close(); m_CommELM.setTimeout(500); if (!m_CommELM.Open()) { return(false); } confirmAT("ATM1", 3); return(true); } } if (m_CommELM.Online) { m_CommELM.Close(); } return(false); } catch (Exception) { if (m_CommELM.Online) { m_CommELM.Close(); } num3 = false; } return(num3); }