/// <summary> /// 3318数据返回 /// </summary> public void readValuefe() { try { GobalSerialPort.WriteByMessage(CommonCmd._331b, 0, CommonCmd._331b.Length); String bakcString = GobalSerialPort.ResultBackString; if (bakcString.Contains("7F")) { this.richTextBox5.Text = bakcString; MessageBox.Show("测试终止"); return; } if (bakcString.Contains("73") && bakcString.Contains("1B") && bakcString.Contains("02")) { String[] result = bakcString.Split('\r'); this.richTextBox5.Text = "测试完成"; comCount = 0; MessageBox.Show("测试完成"); return; } readValuefe(); } catch { } }
/// <summary> /// byte 数据类型 /// </summary> public static void CleardtcByByte() { Byte[] byte4 = new Byte[8]; byte4[0] = 0x31; byte4[1] = 0x34; byte4[2] = 0x66; byte4[3] = 0x66; byte4[4] = 0x30; byte4[5] = 0x30; byte4[6] = 0x0D; byte4[7] = 0x0A; GobalSerialPort.WriteByMessage(CommonCmd.ATST00, 0, CommonCmd.ATST00.Length); Thread.Sleep(400); GobalSerialPort.WriteByMessage(byte4, 0, byte4.Length); Thread.Sleep(400); string backresult = GobalSerialPort.ResultBackString; if (backresult.Contains("54") && backresult.Contains("FF") && backresult.Contains("00")) { MainF.ShowBoxTex("清除故障成功!"); // return; } MainF.ShowBoxTex("清除故障成功!"); GobalSerialPort.WriteByMessage(CommonCmd.ATST0F, 0, CommonCmd.ATST0F.Length); }
/// <summary> /// 写数据 /// </summary> public bool WriteVale(byte[] cmd) { try { comCount++; GobalSerialPort.WriteByMessage(cmd, 0, cmd.Length); String backString = GobalSerialPort.ResultBackString; if (comCount > 10) { this.richTextBox1.Text = "测试失败 请重试"; comCount = 0; //throw new Exception(); return(false); } if (backString.Contains("71") && backString.Contains("16")) { MessageBox.Show("开始测试"); return(true); } else { WriteVale(cmd); } } catch { } return(false); }
/// <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(); } base.Dispose(disposing); if (EcuConnectionF.ECULINKStatus == false) { return; } try { GobalSerialPort.WriteByMessage(CommonCmd._1081, 0, CommonCmd._1081.Length); GobalSerialPort.WriteByMessage(CommonCmd.ATST0F, 0, CommonCmd.ATST0F.Length); //GobalSerialPort.WriteByMessage(CommonCmd._1101, 0, CommonCmd._1101.Length); //Thread.Sleep(1000); //MainF.ShowBoxTex("串口已断开"); //EcuConnectionF.ECULINKStatus1 = false; //EcuConnectionF connectecu = new EcuConnectionF(); //Thread tWorkingThread = new Thread((connectecu.ConnectEucByWait)); //tWorkingThread.Start(); } catch { } }
/// <summary> /// /// load 初始化86模式 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DiagnosticTest_Load(object sender, EventArgs e) { if (EcuConnectionF.ECULINKStatus == true) { try { //mode log.Info("engine test 1086 mode" + " "); 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); } } catch { } } else { } }
public EEPROMWrite() { InitializeComponent(); this.IsMdiContainer = true; if (EcuConnectionF.ECULINKStatus == true) { try { //mode 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); } } catch { } } else { } }
/// <summary> /// 写数据 /// </summary> public bool WriteVale() { try { comCount++; GobalSerialPort.WriteByMessage(CommonCmd._HighPressureTest, 0, CommonCmd._HighPressureTest.Length); String backString = GobalSerialPort.ResultBackString; if (comCount > 10) { this.richTextBox1.Text = "测试失败 请重试"; comCount = 0; return(false); } if (backString.Contains("71") && backString.Contains("14")) { MessageBox.Show("开始测试"); return(true); } else { WriteVale(); } } catch { } return(false); }
/// <summary> /// 写数据 /// </summary> public bool WriteValefe() { try { comCount++; GobalSerialPort.WriteByMessage(CommonCmd._331bfe, 0, CommonCmd._331bfe.Length); String backString = GobalSerialPort.ResultBackString; if (comCount > 10) { this.richTextBox1.Text = "测试失败 请重试"; comCount = 0; //throw new Exception(); return(false); } if ((backString.Contains("71") && backString.Contains("1B"))) { MessageBox.Show("开始测试"); return(true); } else { WriteValefe(); } } catch { // throw new Exception(); } return(false); }
/// <summary> /// readValue /// </summary> public void readValue() { GobalSerialPort.WriteByMessage(CommonCmd._ecuRevolutions, 0, CommonCmd._ecuRevolutions.Length); String allResult = GobalSerialPort.ResultBackString; String[] result = allResult.Split('\r'); this.textBox2.Text = workOut(result[1]).ToString(); }
/// <summary> /// 读取数据类型 /// </summary> public void Read() { GobalSerialPort.WriteByMessage(CommonCmd._allEngineTime, 0, CommonCmd._allEngineTime.Length); String allResult = GobalSerialPort.ResultBackString; String[] result = allResult.Split('\r'); this.textBox2.Text = workOut(result[1]).ToString(); }
private void Max_MinValue() { byte[] _21016CStr = StringToSendBytes.bytesToSend("234C09C828\n"); GobalSerialPort.WriteByMessage(_21016CStr, 0, _21016CStr.Length); MaxValue_minValue = GobalSerialPort.ResultBackString; //计算最大值最小值 WorkOut_Max_Min(); }
/// <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("清除故障成功!"); } }
/// <summary> /// 监测 /// </summary> private void LinsenAutoSetCount() { while (true) { if (CommonAutoRest.AutoResetCount >= 3) { GobalSerialPort.ClearSendAndRecive(); CommonAutoRest.MEvent.Set(); } } }
/// <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; } }
/// <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); }
/// <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; } }
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> /// 数据写入 /// </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> /// 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> public void readValue() { GobalSerialPort.WriteByMessage(CommonCmd.hiByte, 0, CommonCmd.hiByte.Length); String allResult = GobalSerialPort.ResultBackString; String[] result = allResult.Split('\r'); this.textBox2.Text = workOut(result[1]).ToString(); GobalSerialPort.WriteByMessage(CommonCmd.hiOneByte, 0, CommonCmd.hiOneByte.Length); String allResult1 = GobalSerialPort.ResultBackString; String[] result1 = allResult1.Split('\r'); this.textBox3.Text = workOut(result1[1]).ToString(); }
/// <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> /// 递归函数 /// </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> /// 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(); } }
/// <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(); }
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++; }
/// <summary> /// 连接ECU 通过获取锁模式 /// </summary> public void ConnectEuc() { ClearSendAndRecive(); String backEndString = null; // // GobalSerialPort.WriteByMessage(CommonCmd.ATR, 0, CommonCmd.ATR.Length); // backEndString = GetSerialPortBackData(); GobalSerialPort.WriteByThreadWait(CommonCmd.ATE1, 0, CommonCmd.ATE1.Length); // GobalSerialPort.WriteByThreadWait(_AT2S, 0, _AT2S.Length); // backEndString = GetSerialPortBackData(); // GobalSerialPort.WriteByThreadWait(ATSP5, 0, ATSP5.Length); ////////读取718芯片 // backEndString = GetSerialPortBackData(); //if (backEndString.Contains("OK")) //{ // GobalSerialPort.WriteByThreadWait(CommonCmd.ATST00, 0, CommonCmd.ATST00.Length); //22222/ //} //backEndString = GetSerialPortBackData(); //if (backEndString.Contains("OK")) //{ // GobalSerialPort.WriteByThreadWait(ATSW19, 0, ATSW19.Length); //22222/ ////333333 //} //backEndString = GetSerialPortBackData(); //if (backEndString.Contains("OK")) //{ GobalSerialPort.WriteByThreadWait(ATSH81_10_F1, 0, ATSH81_10_F1.Length); // } backEndString = GetSerialPortBackData(); if (backEndString.Contains("OK")) { GobalSerialPort.WriteByThreadWait(_1081, 0, _1081.Length); ////////////5 //连接处可能需要特殊处理 } backEndString = GetSerialPortBackData(); }
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; }