private void parse() { this.start = ByteUtility.GetSubByte(this.source, 0, 4); this.body = ByteUtility.GetSubByte(this.source, 4, 25); this.end = ByteUtility.GetSubByte(this.source, 29, 3); this.parseBody(); }
private void parseBody() { packageNum = ByteUtility.GetSubByte(this.body, 0, 1); response = ByteUtility.GetSubByte(this.body, 1, 1); packageCheck = ByteUtility.GetSubByte(this.body, 2, 1); this.CheckValid(); }
private void parseBody() { packageNum = ByteUtility.GetSubByte(this.body, 0, 1); dataLength = ByteUtility.GetSubByte(this.body, 1, 2); data = ByteUtility.GetSubByte(this.body, 3, 512); packageCheck = ByteUtility.GetSubByte(this.body, 515, 1); this.CheckValid(); }
private void parseBody() { updataStatus = ByteUtility.GetSubByte(this.body, 0, 1); packageFlag = ByteUtility.GetSubByte(this.body, 1, 16); currentVersion = ByteUtility.GetSubByte(this.body, 17, 2); newVersion = ByteUtility.GetSubByte(this.body, 19, 2); updataResult = ByteUtility.GetSubByte(this.body, 21, 1); bootVersion = ByteUtility.GetSubByte(this.body, 22, 2); packageCheck = ByteUtility.GetSubByte(this.body, 24, 1); this.CheckValid(); }
private void parseBody() { fileType = ByteUtility.GetSubByte(body, 0, 1); fileLength = ByteUtility.GetSubByte(body, 1, 2); check1 = ByteUtility.GetSubByte(body, 3, 2); check2 = ByteUtility.GetSubByte(body, 5, 2); check3 = ByteUtility.GetSubByte(body, 7, 4); nPackageNum = ByteUtility.GetSubByte(body, 11, 2); newVersion = ByteUtility.GetSubByte(body, 13, 2); reserve = ByteUtility.GetSubByte(body, 15, 2); packageCheck = ByteUtility.GetSubByte(body, 17, 1); this.CheckValid(); }
/// <summary> /// 从串口文件中取到所有的有效升级数据包和响应包 /// </summary> /// <param name="file">文件路径和文件名</param> /// <param name="fileType">文件类型 0 为bin文件 1 为文本文件</param> private void GetPackageList(string file, int fileType) { byte[] fff; if (fileType == 0) { FileUtility.GetDataFromBinFile(file, out fff); } else if (fileType == 1) { FileUtility.GetDataFormTxtFile(file, out fff); } else { return; } for (int i = 0; i < fff.Length; i++) { if (fff[i] == 'S' && fff[i + 1] == 'S' && fff[i + 2] == 'W') { var ssws = new SSW_Send(ByteUtility.GetSubByte(fff, i, 25)); if (ssws.isValid) { this.sswSendList.Add(ssws); } else { var sswr = new SSW_Recv(ByteUtility.GetSubByte(fff, i, 9)); if (sswr.isValid) { this.sswRecvList.Add(sswr); } } } else if (fff[i] == 'U' && fff[i + 1] == 'S' && fff[i + 2] == 'W') { var usws = new USW_Send(ByteUtility.GetSubByte(fff, i, 523)); if (usws.isValid) { this.uswSendList.Add(usws); } else { var uswr = new USW_Recv(ByteUtility.GetSubByte(fff, i, 10)); if (uswr.isValid) { this.uswRecvList.Add(uswr); } } } else if (fff[i] == 'Q' && fff[i + 1] == 'S' && fff[i + 2] == 'W') { var qsws = new QSW_Send(ByteUtility.GetSubByte(fff, i, 8)); if (qsws.isValid) { this.qswSendList.Add(qsws); } else { var qswr = new QSW_Recv(ByteUtility.GetSubByte(fff, i, 32)); if (qswr.isValid) { this.qswRecvList.Add(qswr); } } } } }
private void parseBody() { packageCheck = ByteUtility.GetSubByte(this.body, 0, 1); this.CheckValid(); }