예제 #1
0
        /// <summary>
        /// readValue
        /// </summary>
        public void readValue()
        {
            GobalSerialPort.WriteByMessage(CommonCmd._ecuAllTime, 0, CommonCmd._ecuAllTime.Length);

            String allResult = GobalSerialPort.ResultBackString;

            String[] result = allResult.Split('\r');

            this.textBox2.Text = workOut(result[1]).ToString();
        }
예제 #2
0
        /// <summary>
        /// 清除故障
        /// </summary>
        public static void Cleardtc()
        {
            GobalSerialPort.WriteByMessage(CommonCmd.ClearDtcCmd, 0, CommonCmd.ClearDtcCmd.Length);
            string backresult = GobalSerialPort.ResultBackString;

            if (backresult.Contains("54") && backresult.Contains("FF") && backresult.Contains("00"))
            {
                MainF.ShowBoxTex("清除故障成功!");
            }
        }
예제 #3
0
        /// <summary>
        /// 连接ECU 通过获取锁模式
        /// </summary>
        public void ConnectEuc()
        {
            ClearSendAndRecive();

            String backEndString = null;

            GobalSerialPort.WriteByMessage(_AT2S, 0, _AT2S.Length);
            CommonAutoRest.MEvent.WaitOne();
            backEndString = GetSerialPortBackData();
            foreach (string num in TL718NUM)
            {
                if (backEndString.Contains(num))
                {
                    GobalSerialPort.WriteByMessage(ATSP5, 0, ATSP5.Length);             ////////读取718芯片
                }
            }
            CommonAutoRest.MEvent.WaitOne();
            backEndString = GetSerialPortBackData();
            if (backEndString.Contains("OK"))
            {
                GobalSerialPort.WriteByMessage(ATST03, 0, ATST03.Length);      //22222/
            }
            CommonAutoRest.MEvent.WaitOne();
            backEndString = GetSerialPortBackData();
            if (backEndString.Contains("OK"))
            {
                GobalSerialPort.WriteByMessage(ATSW19, 0, ATSW19.Length);      //22222/           ////333333
            }
            CommonAutoRest.MEvent.WaitOne();
            backEndString = GetSerialPortBackData();
            if (backEndString.Contains("OK"))
            {
                GobalSerialPort.WriteByMessage(ATSH81_10_F1, 0, ATSH81_10_F1.Length);
            }
            CommonAutoRest.MEvent.WaitOne();
            backEndString = GetSerialPortBackData();
            if (backEndString.Contains("OK"))
            {
                GobalSerialPort.WriteByMessage(_1081, 0, _1081.Length);                              ////////////5
                //连接处可能需要特殊处理
            }
            CommonAutoRest.MEvent.WaitOne();
            backEndString = GetSerialPortBackData();
            if (backEndString.Contains("50") && backEndString.Contains("81"))
            {
                ECULINKStatus = true;
            }
            else
            {
                ECULINKStatus = false;
            }
        }
예제 #4
0
 /// <summary>
 ///   165代码读取量
 /// </summary>
 private void _0165_016B()
 {
     for (int i = 0; i < 5; i++)
     {
         string Sendstring1 = "210165";
         long   intA1       = Convert.ToInt64(Sendstring1, 16);
         intA1 = intA1 + i;
         string Sendstring2 = Convert.ToString(intA1, 16) + "\n";
         byte[] ByteSend    = StringToSendBytes.bytesToSend(Sendstring2);
         GobalSerialPort.WriteByMessage(ByteSend, 0, ByteSend.Length);
         _0165_016BS[i] = GobalSerialPort.ResultBackString;
     }
 }
예제 #5
0
        public void readValue()
        {
            GobalSerialPort.WriteByMessage(CommonCmd._allOilCost, 0, CommonCmd._allOilCost.Length);

            String allResult = GobalSerialPort.ResultBackString;

            //
            String[] result = allResult.Split('\r');

            allResult = result[1];

            this.textBox2.Text = workOut(allResult).ToString();
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();


                GobalSerialPort.WriteByMessage(CommonCmd._1081, 0, CommonCmd._1081.Length);

                GobalSerialPort.WriteByMessage(CommonCmd.ATST0F, 0, CommonCmd.ATST0F.Length);
            }
            base.Dispose(disposing);
        }
예제 #7
0
        /// <summary>
        /// 数据写入
        /// </summary>
        public static void CmdWrite()
        {
            try
            {
                for (int i = 0; i < 2; i++)
                {
                    GobalSerialPort.WriteByMessage(C13ecuIdstring2Tobyte[i], 0, C13ecuIdstring2Tobyte[i].Length);

                    ECUstringtochangeASCII[ECUstringtochangeNum] = GobalSerialPort.ResultBackString;
                    ECUstringtochangeNum++;
                }
                for (int i = 0; i < 2; i++)
                {
                    GobalSerialPort.WriteByMessage(C13ecuIdstring3Tobyte[i], 0, C13ecuIdstring3Tobyte[i].Length);
                    ECUstringtochangeASCII[ECUstringtochangeNum] = GobalSerialPort.ResultBackString;
                    ECUstringtochangeNum++;
                }
                for (int i = 0; i < 1; i++)
                {
                    GobalSerialPort.WriteByMessage(C13ecuIdstring4Tobyte[i], 0, C13ecuIdstring4Tobyte[i].Length);

                    ECUstringtochangeASCII[ECUstringtochangeNum] = GobalSerialPort.ResultBackString;
                    ECUstringtochangeNum++;
                }
                for (int i = 0; i < 1; i++)
                {
                    GobalSerialPort.WriteByMessage(C13ecuIdstring5Tobyte[i], 0, C13ecuIdstring5Tobyte[i].Length);

                    ECUstringtochangeASCII[ECUstringtochangeNum] = GobalSerialPort.ResultBackString;
                    ECUstringtochangeNum++;
                }
                for (int i = 0; i < 6; i++)
                {
                    GobalSerialPort.WriteByMessage(C13ecuIdstring6Tobyte[i], 0, C13ecuIdstring6Tobyte[i].Length);

                    ECUstringtochangeASCII[ECUstringtochangeNum] = GobalSerialPort.ResultBackString;
                    ECUstringtochangeNum++;
                }
                for (int i = 0; i < 9; i++)
                {
                    GobalSerialPort.WriteByMessage(C13ecuIdstring7Tobyte[i], 0, C13ecuIdstring7Tobyte[i].Length);

                    ECUstringtochangeASCII[ECUstringtochangeNum] = GobalSerialPort.ResultBackString;
                    ECUstringtochangeNum++;
                }
            }
            catch
            {
            }
            ECUstringtochangeNum = 0;
        }
        /// <summary>
        /// read
        /// </summary>
        public static void readFunction(String address, int lenght)
        {
            try
            {
                CommonConstant.mode = "1092";
                Tp_KeyMethodFuntion.Con();

                GobalSerialPort.WriteByMessage(CommonCmd.ATSTFF, 0, CommonCmd.ATSTFF.Length);
                GobalSerialPort.WriteByMessage(CommonCmd.ATSW19, 0, CommonCmd.ATSW19.Length);

                // GobalSerialPort.WriteByMessage(DebugMode.startMode84, 0, DebugMode.startMode84.Length);


                GobalSerialPort.WriteByMessage(CommonCmd._109214, 0, CommonCmd._109214.Length);
                backString = GobalSerialPort.ResultBackString;
                if (backString != null)
                {
                }
                GobalSerialPort.WriteByMessage(CommonCmd._808002, 0, CommonCmd._808002.Length);
                backString = GobalSerialPort.ResultBackString;
                //
                address = "024E9E";
                // String addressO = CommonConstant.EolReadPrefix + address + CommonConstant.EolSuffix;

                byte[] addressbyte = AddressReadConvert(address, 2);
                GobalSerialPort.WriteByMessage(addressbyte, 0, addressbyte.Length);
                backString = GobalSerialPort.ResultBackString;
                //GobalSerialPort.WriteByMessage(CommonCmd.ATBD,0,CommonCmd.ATBD.Length);
                //backString = GobalSerialPort.ResultBackString;
                //36
                if (backString.Contains("FF"))
                {
                    GobalSerialPort.WriteByMessage(CommonCmd._36, 0, CommonCmd._36.Length);
                    GobalSerialPort.WriteByMessage(CommonCmd.ATBD, 0, CommonCmd.ATBD.Length);
                    backString = GobalSerialPort.ResultBackString;
                    //byte
                }
                //37
                GobalSerialPort.WriteByMessage(CommonCmd._37, 0, CommonCmd._37.Length);
                backString = GobalSerialPort.ResultBackString;

                GobalSerialPort.WriteByMessage(CommonCmd._3180, 0, CommonCmd._3180.Length);
                GobalSerialPort.WriteByMessage(CommonCmd._3380, 0, CommonCmd._3380.Length);

                GobalSerialPort.WriteByMessage(CommonCmd.ATSH81_10_F1, 0, CommonCmd.ATSH81_10_F1.Length);
                GobalSerialPort.WriteByMessage(CommonCmd._1081, 0, CommonCmd._1081.Length);
            }
            catch (Exception e) {
            }
        }
        /// <summary>
        /// 0165
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            String _0165  = preWriteValue(60);
            String cmd165 = "3b0165" + _0165;

            byte[] cmdSend165 = StringToSendBytes.bytesToSend(cmd165 + "\n");
            GobalSerialPort.WriteByMessage(cmdSend165, 0, cmdSend165.Length);
            String result = GobalSerialPort.ResultBackString;


            String _0166  = preWriteValue(40);
            String cmd166 = "3b0166" + _0166;

            byte[] cmdSend166 = StringToSendBytes.bytesToSend(cmd166 + "\n");
            GobalSerialPort.WriteByMessage(cmdSend166, 0, cmdSend166.Length);
            String result166 = GobalSerialPort.ResultBackString;

            String _0167  = preWriteValue(96);
            String cmd167 = "3b0167" + _0167;

            byte[] cmdSend167 = StringToSendBytes.bytesToSend(cmd167 + "\n");
            GobalSerialPort.WriteByMessage(cmdSend167, 0, cmdSend167.Length);
            String result167 = GobalSerialPort.ResultBackString;

            String _0168  = preWriteValue(144);
            String cmd168 = "3b0168" + _0168;

            byte[] cmdSend168 = StringToSendBytes.bytesToSend(cmd168 + "\n");
            GobalSerialPort.WriteByMessage(cmdSend168, 0, cmdSend168.Length);
            String result168 = GobalSerialPort.ResultBackString;

            String _0169  = preWriteValue(144);
            String cmd169 = "3b0169" + _0169;

            byte[] cmdSend169 = StringToSendBytes.bytesToSend(cmd169 + "\n");
            GobalSerialPort.WriteByMessage(cmdSend169, 0, cmdSend169.Length);
            String result169 = GobalSerialPort.ResultBackString;

            String _016c  = preWriteValue(40);
            String cmd16c = "3b016c" + _0169;

            byte[] cmdSend16c = StringToSendBytes.bytesToSend(cmd16c + "\n");
            GobalSerialPort.WriteByMessage(cmdSend16c, 0, cmdSend16c.Length);
            String result16c = GobalSerialPort.ResultBackString;

            if (result.Contains("7B"))
            {
                // this.textBox1.Text = "ok";
            }
        }
 /// <summary>
 /// 递归函数
 /// </summary>
 /// <returns></returns>
 public static bool readBackFunction()
 {
     GobalSerialPort.WriteByMessage(_31FE, 0, _31FE.Length);
     DbackString = GobalSerialPort.ResultBackString;
     if (!DbackString.Contains("71") && !DbackString.Contains("1B"))
     {
         readBackFunction();
         funcFlag++;
     }
     if (funcFlag > 10)
     {
         return(false);
     }
     return(true);
 }
        /// <summary>
        /// 获取ECUVersion 数据问题
        /// </summary>
        public static void GetEcuVersion()
        {
            log.Info("ecu version read ..");

            GobalSerialPort.WriteByMessage(CommonCmd.ecuVersionCmd, 0, CommonCmd.ecuVersionCmd.Length);

            String VersionString = GobalSerialPort.ResultBackString;

            _13IdFDataWork.InsertAcessF_7(VersionString);

            EcuVsion = _13IdFDataWork.WorkOutData;

            MainF.EcuVersionLabelShow(EcuVsion);

            log.Info("ecu version is :" + EcuVsion);
            //  CommonAutoRest.MainFTextThreadMessage1.Set();
        }
        /// <summary>
        /// 16个字节长度
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            String writeValue = this.textBox1.Text.Trim();
            int    count      = Convert.ToInt32(writeValue);
            String all        = Convert.ToString(count, 16).PadLeft(32, '0');
            String cmd        = "3b016E" + StringUtil.Reverse(all);

            byte[] cmdSend = StringToSendBytes.bytesToSend(cmd + "\n");
            GobalSerialPort.WriteByMessage(cmdSend, 0, cmdSend.Length);
            String result = GobalSerialPort.ResultBackString;

            if (result.Contains("7B"))
            {
                this.textBox1.Text = "ok";
                Read();
            }
        }
예제 #13
0
        private void SendExtendMes()
        {
            byte[] counter = StringToSendBytes.bytesToSend("234C09743c\n");
            GobalSerialPort.WriteByMessage(counter, 0, counter.Length);
            _0165_016BS[0] = GobalSerialPort.ResultBackString;

            byte[] _1_mapSendCmd = StringToSendBytes.bytesToSend("234C07F490\n");
            GobalSerialPort.WriteByMessage(_1_mapSendCmd, 0, _1_mapSendCmd.Length);
            _0165_016BS[2] = GobalSerialPort.ResultBackString;

            byte[] _2_mapSendCmd_1 = StringToSendBytes.bytesToSend("234C085490\n");
            GobalSerialPort.WriteByMessage(_2_mapSendCmd_1, 0, _2_mapSendCmd_1.Length);
            _0165_016BS[3] = GobalSerialPort.ResultBackString;

            byte[] _2_mapSendCmd_2 = StringToSendBytes.bytesToSend("234C08E490\n");
            GobalSerialPort.WriteByMessage(_2_mapSendCmd_2, 0, _2_mapSendCmd_2.Length);
            _0165_016BS[4] = GobalSerialPort.ResultBackString;
        }
        /// <summary>
        /// load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TripRecord_Load(object sender, EventArgs e)
        {
            try
            {
                ////165
                GobalSerialPort.WriteByMessage(CommonCmd.trip165, 0, CommonCmd.trip165.Length);
                String   allResult = GobalSerialPort.ResultBackString;
                String[] result    = allResult.Split('\r');
                textBox2.Text = result[1];

                ////166
                GobalSerialPort.WriteByMessage(CommonCmd.trip166, 0, CommonCmd.trip166.Length);
                String   allResult1 = GobalSerialPort.ResultBackString;
                String[] result1    = allResult1.Split('\r');
                textBox3.Text = result1[1];

                ////167
                GobalSerialPort.WriteByMessage(CommonCmd.trip167, 0, CommonCmd.trip167.Length);
                String   allResult167 = GobalSerialPort.ResultBackString;
                String[] result167    = allResult1.Split('\r');
                this.textBox5.Text = result1[1];

                ///168
                GobalSerialPort.WriteByMessage(CommonCmd.trip168, 0, CommonCmd.trip168.Length);
                String   allResult168 = GobalSerialPort.ResultBackString;
                String[] result168    = allResult1.Split('\r');
                this.textBox7.Text = result1[1];

                //169
                GobalSerialPort.WriteByMessage(CommonCmd.trip169, 0, CommonCmd.trip169.Length);
                String   allResult169 = GobalSerialPort.ResultBackString;
                String[] result169    = allResult1.Split('\r');
                this.textBox9.Text = result1[1];

                //16c
                GobalSerialPort.WriteByMessage(CommonCmd.trip16c, 0, CommonCmd.trip16c.Length);
                String   allResult16c = GobalSerialPort.ResultBackString;
                String[] result16c    = allResult1.Split('\r');
                this.textBox11.Text = result1[1];
            }
            catch (Exception) {
            }
        }
        private void Con()
        {
            try
            {
                #region
                //winuds.串口.serialPort1();
                string BackString;
                string ClearBuff = GobalSerialPort.ResultBackString;
                byte[] _2709Str  = StringToSendBytes.bytesToSend("2709\n");
                GobalSerialPort.WriteByMessage(_2709Str, 0, _2709Str.Length);
                BackString = GobalSerialPort.ResultBackString;  //   "2709\r67 09 76 BB DD EE \r\n\r\n>"
                if (BackString.Contains("NO"))
                {
                    byte[] _2709Str1 = StringToSendBytes.bytesToSend("2709\n");
                    GobalSerialPort.WriteByMessage(_2709Str1, 0, _2709Str1.Length);
                    BackString = GobalSerialPort.ResultBackString;
                }
                string[] Backs = BackString.Split('\r');
                string   Back1 = Backs[1].Replace(" ", "");
                Back1 = Back1.Substring(4, 8);
                UInt32 b        = UInt32.Parse(Back1, System.Globalization.NumberStyles.HexNumber); //最后得到的 b 的值是 171。
                string _270AStr = Convert.ToString(KEYMethod(b), 16).PadLeft(8, '0');
                _270AStr = "270A" + _270AStr + "\n";
                byte[] _270AByte = StringToSendBytes.bytesToSend(_270AStr);
                GobalSerialPort.WriteByMessage(_270AByte, 0, _270AByte.Length);
                string Backstring1 = GobalSerialPort.ResultBackString;

                byte[] _1086byte = StringToSendBytes.bytesToSend("1086\n");
                GobalSerialPort.WriteByMessage(_1086byte, 0, _1086byte.Length);
                string Backstring2 = GobalSerialPort.ResultBackString;
                if (Backstring2.Contains("86"))
                {
                }
                else
                {
                }
                #endregion
            }
            catch
            {
            }
        }
        /// <summary>
        /// confunction
        /// </summary>
        public void confuntion()
        {
            byte[] _2709Str = bytesToSend(CommonConstant.EcuModeSendMap[CommonConstant.mode] + "\n");
            GobalSerialPort.WriteByMessage(_2709Str, 0, _2709Str.Length);
            string BackString = GobalSerialPort.ResultBackString;     //   "2709\r67 09 76 BB DD EE \r\n\r\n>"

            string[] Backs = BackString.Split('\r');
            string   Back1 = Backs[1].Replace(" ", "");

            Back1 = Back1.Substring(4, 8);
            //如果有8位长度 00 00 00 00 表示已经正常进入
            if (Back1.Equals("00000000"))
            {
                return;
            }
            UInt32 b        = UInt32.Parse(Back1, System.Globalization.NumberStyles.HexNumber); //最后得到的 b 的值是 171。
            string _270AStr = Convert.ToString(KEYMethod(b), 16).PadLeft(8, '0');

            _270AStr = CommonConstant.EcuModeSendSecondeMap[CommonConstant.mode] + _270AStr + "\n";
            byte[] _270AByte = bytesToSend(_270AStr);
            GobalSerialPort.WriteByMessage(_270AByte, 0, _270AByte.Length);
            BackString = GobalSerialPort.ResultBackString;   //Byte to send
            int i = 10;

            //递归算法
            if (!BackString.Contains("67"))
            {
                while (i > 0)
                {
                    i--;
                    Con();
                }
            }
            else
            {
                threadFlag++;
            }
            //正常退出机制
            threadFlag++;
        }
예제 #17
0
        private void SendGeneral()
        {
            byte[] _21016DStr = StringToSendBytes.bytesToSend(General1cmd + "\n");
            GobalSerialPort.WriteByMessage(_21016DStr, 0, _21016DStr.Length);
            Genera1[0] = GobalSerialPort.ResultBackString;

            byte[] _21016EStr = StringToSendBytes.bytesToSend(General2cmd + "\n");
            GobalSerialPort.WriteByMessage(_21016EStr, 0, _21016EStr.Length);
            Genera1[1] = GobalSerialPort.ResultBackString;

            byte[] _21016FStr = StringToSendBytes.bytesToSend(General3cmd + "\n");
            GobalSerialPort.WriteByMessage(_21016FStr, 0, _21016FStr.Length);
            Genera1[2] = GobalSerialPort.ResultBackString;

            byte[] _210170Str = StringToSendBytes.bytesToSend(General4cmd + "\n");
            GobalSerialPort.WriteByMessage(_210170Str, 0, _210170Str.Length);
            Genera1[3] = GobalSerialPort.ResultBackString;

            byte[] _210171Str = StringToSendBytes.bytesToSend(General5cmd + "\n");
            GobalSerialPort.WriteByMessage(_210171Str, 0, _210171Str.Length);
            Genera1[4] = GobalSerialPort.ResultBackString;
        }
예제 #18
0
        private void send_Click(object sender, EventArgs e)
        {
            String sendText = this.skinChatRichTextBox2.Text.Trim();

            Byte[] sendCmd = StringToSendBytes.bytesToSend(sendText + "\n");

            GobalSerialPort.WriteByMessage(sendCmd, 0, sendCmd.Length);

            String backString = GobalSerialPort.ResultBackString;

            //if (backString.Contains("10") && backString.Contains("78"))
            //{
            //    GobalSerialPort.WriteByMessage(CommonCmd.ATSTD6, 0, CommonCmd.ATSTD6.Length);

            //    GobalSerialPort.WriteByMessage(CommonCmd._830300D610140A, 0, CommonCmd._830300D610140A.Length);

            //    GobalSerialPort.WriteByMessage(CommonCmd.ATSW00, 0, CommonCmd.ATSW00.Length);
            //}
            //  backString = GobalSerialPort.ResultBackString;
            //释放
            this.richTextBox1.Invoke(maifText, backString);

            // this.skinChatRichTextBox1.Text = GobalSerialPort.ResultBackString;
        }
        /// <summary>
        /// write
        /// </summary>
        public static void writeFunction(String address, int lenght, String value)
        {
            try
            {
                CommonConstant.mode = "1092";
                Tp_KeyMethodFuntion.Con();

                byte[] ATSTFE = StringToSendBytes.bytesToSend("ATSTFE\n");
                GobalSerialPort.WriteByMessage(ATSTFE, 0, ATSTFE.Length);
                GobalSerialPort.WriteByMessage(CommonCmd.ATSW30, 0, CommonCmd.ATSW30.Length);
                //GobalSerialPort.WriteByMessage(DebugMode.startMode84, 0, DebugMode.startMode84.Length);
                GobalSerialPort.WriteByMessage(CommonCmd._830300D600140A, 0, CommonCmd._830300D600140A.Length);
                //1092模式
                GobalSerialPort.WriteByMessage(CommonCmd._109214, 0, CommonCmd._109214.Length);
                backString = GobalSerialPort.ResultBackString;
                //日期模式
                byte[] databyte = StringToSendBytes.bytesToSend("80 81 02 31 32 33 34 35 36 17 03 E2\n");
                GobalSerialPort.WriteByMessage(databyte, 0, databyte.Length);
                backString = GobalSerialPort.ResultBackString;
                //34 模式
                address = "024E9E";
                byte[] addressbyte = AddressWriteConvert(address, 2);
                GobalSerialPort.WriteByMessage(addressbyte, 0, addressbyte.Length);
                backString = GobalSerialPort.ResultBackString;
                //36 写入数据
                String valueWrite = "36" + value;
                valueWrite = "362222" + "\n";

                byte[] byteValueWrite = StringToSendBytes.bytesToSend(valueWrite);
                GobalSerialPort.WriteByMessage(byteValueWrite, 0, byteValueWrite.Length);
                backString = GobalSerialPort.ResultBackString;
                GobalSerialPort.WriteByMessage(CommonCmd.ATBD, 0, CommonCmd.ATBD.Length);
                backString = GobalSerialPort.ResultBackString;
                //commoncmd
                if (!backString.Contains("76"))
                {
                    GobalSerialPort.WriteByMessage(byteValueWrite, 0, byteValueWrite.Length);
                    GobalSerialPort.WriteByMessage(CommonCmd.ATBD, 0, CommonCmd.ATBD.Length);
                    backString = GobalSerialPort.ResultBackString;
                }
                if (!backString.Contains("76"))
                {
                    GobalSerialPort.WriteByMessage(byteValueWrite, 0, byteValueWrite.Length);
                    GobalSerialPort.WriteByMessage(CommonCmd.ATBD, 0, CommonCmd.ATBD.Length);
                    backString = GobalSerialPort.ResultBackString;
                }
                if (!backString.Contains("76"))
                {
                    GobalSerialPort.WriteByMessage(byteValueWrite, 0, byteValueWrite.Length);
                    GobalSerialPort.WriteByMessage(CommonCmd.ATBD, 0, CommonCmd.ATBD.Length);
                    backString = GobalSerialPort.ResultBackString;
                }
                //76
                if (backString.Contains("76"))
                {
                    GobalSerialPort.WriteByMessage(CommonCmd._37, 0, CommonCmd._37.Length);

                    GobalSerialPort.WriteByMessage(CommonCmd._3180, 0, CommonCmd._3180.Length);

                    GobalSerialPort.WriteByMessage(CommonCmd._3380, 0, CommonCmd._3380.Length);
                }

                EcuEnd();
            }
            catch {
            }
        }
 /// <summary>
 /// ecudend write
 /// </summary>
 public static void EcuEnd()
 {
     GobalSerialPort.WriteByMessage(CommonCmd._1101, 0, CommonCmd._1101.Length);
 }
예제 #21
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);
     }
 }
예제 #22
0
 /// <summary>
 /// 静态函数
 /// </summary>
 static _13dtcRead()
 {
     GobalSerialPort.WriteByMessage(CommonCmd.ATE1, 0, CommonCmd.ATE1.Length);
 }
예제 #23
0
 private void mode81_Click(object sender, EventArgs e)
 {
     GobalSerialPort.WriteByMessage(DebugMode.startMode84, 0, DebugMode.startMode84.Length);      //22222/
 }
예제 #24
0
 /// <summary>
 /// send ATE1  init
 /// </summary>
 public static void SendATE1ByThread()
 {
     GobalSerialPort.WriteByMessage(CommonCmd.ATE1, 0, CommonCmd.ATE1.Length);
 }
예제 #25
0
        /// <summary>
        ///
        /// </summary>
        public void isConnet()
        {
            while (true)
            {
                if (EcuConnectionF.ECULINKStatus == true)
                {
                    break;
                }
            }
            try
            {
                byte[] _210213 = StringToSendBytes.bytesToSend("210213\n");
                GobalSerialPort.WriteByMessage(_210213, 0, _210213.Length);
                String   result213 = GobalSerialPort.ResultBackString;
                String[] resultA   = result213.Split('\r');
                result213 = resultA[1].Replace(" ", "");

                byte[] _210214 = StringToSendBytes.bytesToSend("210214\n");
                GobalSerialPort.WriteByMessage(_210214, 0, _210214.Length);
                String   result214 = GobalSerialPort.ResultBackString;
                String[] result14A = result214.Split('\r');
                result214 = result14A[1].Replace(" ", "");

                byte[] _210215 = StringToSendBytes.bytesToSend("210215\n");
                GobalSerialPort.WriteByMessage(_210215, 0, _210215.Length);
                String   result215 = GobalSerialPort.ResultBackString;
                String[] result15A = result215.Split('\r');
                result215 = result15A[1].Replace(" ", "");

                byte[] _210241 = StringToSendBytes.bytesToSend("210241\n");
                GobalSerialPort.WriteByMessage(_210241, 0, _210241.Length);
                String   result210241  = GobalSerialPort.ResultBackString;
                String[] result210241A = result210241.Split('\r');
                result210241 = result210241A[1].Replace(" ", "");

                byte[] _210240 = StringToSendBytes.bytesToSend("210240\n");
                GobalSerialPort.WriteByMessage(_210240, 0, _210240.Length);
                String   result210240  = GobalSerialPort.ResultBackString;
                String[] result210240A = result210240.Split('\r');
                result210240 = result210240A[1].Replace(" ", "");

                //展示数据格式
                show(result213, result214, result215, result210241, result210240);

                //mode 1086
                //log.Info("ECUMODE  1086 " + " ");
                //CommonConstant.mode = "1086";
                //Tp_KeyMethodFuntion.Con();
                //GobalSerialPort.WriteByMessage(CommonCmd._1086, 0, CommonCmd._1086.Length);
                //String backString = GobalSerialPort.ResultBackString;
                //if (!backString.Contains("86"))
                //{
                //    GobalSerialPort.WriteByMessage(CommonCmd._1086, 0, CommonCmd._1086.Length);
                //    backString = GobalSerialPort.ResultBackString;
                //}
                //else
                //{
                //    GobalSerialPort.WriteByMessage(CommonCmd.ATST00, 0, CommonCmd.ATST00.Length);
                //    //write
                //    String tl718code = result214.Substring(8 + 89 * 2, 12);
                //    String time = result214.Substring(8 + 96 * 2, 8);
                //    result214.Replace(tl718code, "0000" + CommonConstant.TL718CODE);
                //    result214.Replace(time, DateUtil.getDate());
                //    String address = "3b0214" + result214.Substring(8, 200);
                //    byte[] cmdSend = StringToSendBytes.bytesToSend(address + "\n");
                //    GobalSerialPort.WriteByMessage(cmdSend, 0, cmdSend.Length);
                //    String result = GobalSerialPort.ResultBackString;
                //    //if () {
                //    //}
                //    GobalSerialPort.WriteByMessage(CommonCmd.ATST0F, 0, CommonCmd.ATST0F.Length);
                //    GobalSerialPort.WriteByMessage(CommonCmd._1081,0,CommonCmd._1081.Length);
                //}
            }
            catch (IndexOutOfRangeException)
            {
                byte[] _210213 = StringToSendBytes.bytesToSend("210213\n");
                GobalSerialPort.WriteByMessage(_210213, 0, _210213.Length);
                String   result213 = GobalSerialPort.ResultBackString;
                String[] resultA   = result213.Split('\r');
                result213 = resultA[1].Replace(" ", "");

                byte[] _210214 = StringToSendBytes.bytesToSend("210214\n");
                GobalSerialPort.WriteByMessage(_210214, 0, _210214.Length);
                String   result214 = GobalSerialPort.ResultBackString;
                String[] result14A = result214.Split('\r');
                result214 = result14A[1].Replace(" ", "");

                byte[] _210215 = StringToSendBytes.bytesToSend("210215\n");
                GobalSerialPort.WriteByMessage(_210215, 0, _210215.Length);
                String   result215 = GobalSerialPort.ResultBackString;
                String[] result15A = result215.Split('\r');
                result215 = result15A[1].Replace(" ", "");

                byte[] _210241 = StringToSendBytes.bytesToSend("210241\n");
                GobalSerialPort.WriteByMessage(_210241, 0, _210241.Length);
                String   result210241  = GobalSerialPort.ResultBackString;
                String[] result210241A = result210241.Split('\r');
                result210241 = result210241A[1].Replace(" ", "");

                byte[] _210240 = StringToSendBytes.bytesToSend("210240\n");
                GobalSerialPort.WriteByMessage(_210240, 0, _210240.Length);
                String   result210240  = GobalSerialPort.ResultBackString;
                String[] result210240A = result210240.Split('\r');
                result210240 = result210240A[1].Replace(" ", "");

                show(result213, result214, result215, result210241, result210240);
            }
            catch (Exception) {
            }
            finally
            {
                // return null;
            }
        }
예제 #26
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);
            //
        }
예제 #27
0
 /// <summary>
 /// 获取行程记录
 /// </summary>
 static TpRecord()
 {
     GobalSerialPort.WriteByMessage(CommonCmd.ATE1, 0, CommonCmd.ATE1.Length);
 }