Example #1
0
        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);
        }