Exemplo n.º 1
0
 /// <summary>
 /// 读取行程记录仪
 /// </summary>
 public void ReadFtrip()
 {
     try
     {
         CommonCmd.SendATE1();
         // EcuVersionF.EcuVsion = "P1287770";
         if (EcuVersionF.EcuVsion == null)
         {
             MainF.ShowBoxTex("未能读取ECU版本号");
             return;
         }
         GetCmdFormDb(EcuVersionF.EcuVsion);
         SendData();
         Work_OutoneStep();
         WorkOut_TimerAndCounter();
         _1Dimensional_Maps();
         _2Dimensional_Maps();
         ShowTripRecord();//先清除数据,然后重新填充
         SaveFileFunction.Tp_SaveExcel();
         MainF.ShowBoxTex("读完数据");
     }
     catch (Exception e)
     {
         log.Info("tp read this is exception" + e.Message);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        //  运行开始方法
        /// </summary>
        public static void workRun()
        {
            CommonCmd.SendATE1();

            //GobalSerialPort.GobalSerialPortEnventChange();

            ToSendEcu13IdF();

            CmdWrite();

            WorkOutToDb();

            MainF.ShowBoxTex("读取ID完毕");

            DbDataToExcel();
        }
Exemplo n.º 3
0
 /// <summary>
 /// read dtc code
 /// </summary>
 public static void ReadECU13DTC()
 {
     CommonCmd.SendATE1();
     GobalSerialPort.ClearSendAndRecive();
     try
     {
         byte[] stringToalldtccodeA = StringToSendBytes.bytesToSend("1800FF00\n");       //发送命令的一个转化
         GobalSerialPort.WriteByMessage(stringToalldtccodeA, 0, stringToalldtccodeA.Length);
         StringOfGets = GobalSerialPort.ResultBackString;
         string[] splitstring = StringOfGets.Split('\r');
         if (splitstring[1] != null && (!splitstring[1].Contains("NO")))
         {
             string result = splitstring[1];
             string ss     = result;
             ss = result.Replace(" ", "");                                    //这里是将空格改为空的字符串,但是还有其他的方法
             string   sub         = ss.Substring(2, 2);
             string   subtostr    = sub.ToString();
             int      subtoint    = Convert.ToInt32(subtostr, 16); //subint 是表示有多少个故障代码
             string[] strsubtring = new string[subtoint];          //strsubtring  表示要开辟多少个字符串数组
             ECU13DTC = new string[subtoint];
             int[] strsubtint = new int[subtoint];
             Console.WriteLine(subtoint);
             byte[][] C13DTwrite = new byte[subtoint][];
             Save13BackDTC    = new string[subtoint];
             C13BackTDNumCode = new string[subtoint];
             for (int i = 0; i < subtoint; i++)
             {
                 C13DTwrite[i] = new byte[8];
             }
             //初始化数据
             SingleDtcFunction singleDtcFunction = new SingleDtcFunction();
             MyMeans.DropDTC();   //清除原先数据
             MyMeans.AccessLink();
             int x = 4;
             for (int i = 0; i < subtoint; i++)
             {
                 strsubtring[i] = ss.Substring(x, 6);
                 x = x + 6;
                 strsubtring[i]      = strsubtring[i].Substring(0, 4);
                 C13BackTDNumCode[i] = strsubtring[i];
                 int    TheoneString    = Convert.ToInt32(strsubtring[i].Substring(0, 1), 16);
                 int    _16TheoneString = int.Parse(TheoneString.ToString("X"), System.Globalization.NumberStyles.HexNumber);
                 string ThethreeString  = strsubtring[i].Substring(1, 3);
                 //将前面的一个数据去掉前面的两位
                 string SUBba   = Convert.ToString(_16TheoneString, 2).PadLeft(4, '0');
                 string C       = SUBba.Substring(2, 2);
                 string D       = "00" + C;
                 string Fianba  = (Convert.ToInt32("00" + C)).ToString("X");
                 string Fianba1 = Convert.ToInt32(D, 2).ToString();
                 strsubtring[i] = Fianba1 + ThethreeString;
                 ECU13DTC[i]    = strsubtring[i];
                 ECU13DTCSingle = strsubtring[i];
                 strsubtring[i] = "17" + strsubtring[i];
                 C13DTwrite[i]  = StringToSendBytes.bytesToSend(strsubtring[i] + "\n");
                 try
                 {
                     GobalSerialPort.WriteByMessage(C13DTwrite[i], 0, C13DTwrite[0].Length);
                     StringOfGets        = GobalSerialPort.ResultBackString;
                     Save13BackDTC[i]    = StringOfGets;
                     Save13BackDTCSingle = StringOfGets;
                     //Date
                     int count = i + 1;
                     singleDtcFunction.ShowDtcCodeF(count);
                 }
                 catch (Exception e)
                 {
                     log.Info("the  error fo message is :" + e.Message);
                     continue;
                 }
             }
             MainF.ShowBoxTex("读取故障完毕");
             MyMeans.AccessBreak();
             SaveFileFunction.Dtc_SaveExcel();
         }
     }
     catch (Exception e) {
         SaveFileFunction.Dtc_SaveExcel();
         log.Info("Dtc final  error :" + e.Message);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 连接ECU 通过获取锁模式
        /// </summary>
        public void ConnectEucByWait()
        {
            if (GobalSerialPort.SerialPort.IsOpen == false)
            {
                return;
            }

            ClearSendAndRecive();

            String backEndString = null;

            CommonCmd.SendATE1();
            // GobalSerialPort.GobalSerialPortEnventChange();
            //718 code
            GobalSerialPort.WriteByMessage(_AT2S, 0, _AT2S.Length);
            backEndString            = GetSerialPortBackData();
            CommonConstant.TL718CODE = backEndString;

            //foreach (string num in TL718NUM)
            //{
            //    if (backEndString.Contains(num))
            //    {
            //        GobalSerialPort.WriteByMessage(ATSP5, 0, ATSP5.Length);    ////////读取718芯片
            //    }
            //}

            GobalSerialPort.WriteByMessage(ATSP5, 0, ATSP5.Length);             ////////读取718芯片


            backEndString = GetSerialPortBackData();
            if (backEndString.Contains("OK"))
            {
                GobalSerialPort.WriteByMessage(CommonCmd.ATST0F, 0, CommonCmd.ATST0F.Length); //2
            }

            backEndString = GetSerialPortBackData();
            if (backEndString.Contains("OK"))
            {
                GobalSerialPort.WriteByMessage(ATSW19, 0, ATSW19.Length);      //22222/           ////333333
            }
            backEndString = GetSerialPortBackData();
            if (backEndString.Contains("OK"))
            {
                GobalSerialPort.WriteByMessage(ATSH81_10_F1, 0, ATSH81_10_F1.Length);
            }
            backEndString = GetSerialPortBackData();
            if (backEndString.Contains("OK"))
            {
                GobalSerialPort.WriteByMessage(_1081, 0, _1081.Length);                              ////////////5
                //连接处可能需要特殊处理
            }

            backEndString = GetSerialPortBackData();

            EcuVersionF.GetEcuVersion();

            if (backEndString.Contains("50") && backEndString.Contains("81"))
            {
                ECULINKStatus = true;

                MainF.ShowBoxTex("串口连接成功!");
            }
            else
            {
                ECULINKStatus = false;
                MainF.ShowBoxTex("串口未成功!");
            }
            MainF.EcuIsLinked = EcuConnectionF.ECULINKStatus1;

            //MethodInvoker MethInvk = new MethodInvoker(ShowForm5);
            //BeginInvoke(MethInvk);
            //
        }