private byte DoeventsComStr(string str, int chaotim) { byte[] array = new byte[1000]; PosLaction posLaction = default(PosLaction); int num = 0; byte result; while (chaotim > 0) { while (this.com1.BytesToRead > 0) { array[num] = (byte)this.com1.ReadByte(); num++; if (num > 999) { break; } } if (num > 0) { posLaction.star = 0; posLaction.end = (ushort)(num - 1); } if (Strmake.Strmake_StrSubstring(ref array, ref posLaction, str, 1) != 65535) { result = 1; return(result); } chaotim -= 10; this.Doyanshi(10); } result = 0; return(result); }
public int Getcomstr() { int num = 0; byte[] array = new byte[500]; PosLaction posLaction = default(PosLaction); PosLaction[] array2 = new PosLaction[30]; int result; try { while (this.com1.BytesToRead > 0) { array[num] = (byte)this.com1.ReadByte(); num++; if (num > 499) { break; } } num -= 4; if (num < 1) { result = 0; return(result); } posLaction.star = 0; posLaction.end = (ushort)num; int num2 = (int)Strmake.Strmake_StrSubstring(ref array, ref posLaction, "comok ", 1); this.FlashSize = 0; if (num2 != 65535) { posLaction.star = (ushort)(num2 + 1); if (Strmake.Strmake_StrGetcanshu(ref array, ref posLaction, ref array2, 7) == 1) { this.touch = array2[0].PosByteGetstring(array).Getint(); this.Lcdid = array2[1].PosByteGetstring(array).Getint(); this.xinghao = array2[2].PosByteGetstring(array); this.gujianver = (ushort)((byte)array2[3].PosByteGetstring(array).Getint()); this.cpuchip = (ushort)array2[4].PosByteGetstring(array).Getint(); this.FlashIDstring = array2[5].PosByteGetstring(array); this.FlashSize = array2[6].PosByteGetstring(array).Getint(); string text = this.xinghao.Trim(); modelxinxi modelxinxi; if (text.Length > 1) { string a = text.Substring(text.Length - 1, 1); if (a == "R" || a == "N" || a == "C") { text = text.Substring(0, text.Length - 1); } else { this.xilie = 0; modelxinxi = datasize.Getmodelxinxi("123", this.xilie); if (this.islaodmessage) { MessageOpen.Show("非法型号".Language() + this.xinghao); result = 3; return(result); } result = 1; return(result); } } this.xilie = 0; modelxinxi = datasize.Getmodelxinxi(text, this.xilie); if (modelxinxi.Modelstring == "") { this.xilie = 1; modelxinxi = datasize.Getmodelxinxi(text, this.xilie); } if (!(modelxinxi.Modelstring == "")) { result = 1; return(result); } if (this.islaodmessage) { MessageOpen.Show("非法型号".Language() + this.xinghao); result = 3; return(result); } result = 1; return(result); } else if (Strmake.Strmake_StrGetcanshu(ref array, ref posLaction, ref array2, 6) == 1) { this.touch = array2[0].PosByteGetstring(array).Getint(); this.Lcdid = array2[1].PosByteGetstring(array).Getint(); this.xinghao = array2[2].PosByteGetstring(array); this.gujianver = (ushort)((byte)array2[4].PosByteGetstring(array).Getint()); this.gujianver *= 256; this.gujianver += (ushort)((byte)array2[3].PosByteGetstring(array).Getint()); this.FlashIDstring = array2[5].PosByteGetstring(array); string text = this.xinghao.Trim(); modelxinxi modelxinxi; if (text.Length > 1) { string a = text.Substring(text.Length - 1, 1); if (a == "R" || a == "N" || a == "C") { text = text.Substring(0, text.Length - 1); } else { this.xilie = 0; modelxinxi = datasize.Getmodelxinxi("123", this.xilie); if (this.islaodmessage) { MessageOpen.Show("非法型号".Language() + this.xinghao); result = 3; return(result); } result = 1; return(result); } } this.xilie = 0; modelxinxi = datasize.Getmodelxinxi(text, this.xilie); if (modelxinxi.Modelstring == "") { this.xilie = 1; modelxinxi = datasize.Getmodelxinxi(text, this.xilie); } if (!(modelxinxi.Modelstring == "")) { result = 1; return(result); } if (this.islaodmessage) { MessageOpen.Show("非法型号".Language() + this.xinghao); result = 3; return(result); } result = 1; return(result); } } else { num2 = (int)Strmake.Strmake_StrSubstring(ref array, ref posLaction, "downbin", 1); if (num2 != 65535) { result = 2; return(result); } } } catch (Exception ex) { MessageOpen.Show(ex.Message); result = 0; return(result); } result = 0; return(result); }