public override object Decode() { using (MemoryStream stream = new MemoryStream(this.BytesRX)) { using (BinaryReader reader = new BinaryReader(stream)) { if (stream.Length <= 3L) { return(new DIAG_VERNO_F_CLS("-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1")); } reader.BaseStream.Position = 1L; this.compileDate = ConversionUtils.GetASCIIString(reader.ReadBytes(11)); this.compileTime = ConversionUtils.GetASCIIString(reader.ReadBytes(8)); this.releaseDate = ConversionUtils.GetASCIIString(reader.ReadBytes(11)); this.releaseTime = ConversionUtils.GetASCIIString(reader.ReadBytes(8)); this.verDir = ConversionUtils.GetASCIIString(reader.ReadBytes(8)); this.stationClassMark = Conversions.ToString(reader.ReadByte()); if (File.Exists(this.fileMobCAIRev)) { this.mobCAIRev = HelperUtils.GetEnumValue(reader.ReadByte(), this.fileMobCAIRev, EnumFileParser.ParseType.Dec); } else { this.mobCAIRev = Conversions.ToString(reader.ReadByte()); } if (File.Exists(this.fileMobModel)) { this.mobModel = HelperUtils.GetEnumValue(reader.ReadByte(), this.fileMobModel, EnumFileParser.ParseType.Dec); } else { this.mobModel = Conversions.ToString(reader.ReadByte()); } this.mobFWRev = Conversions.ToString((int)reader.ReadInt16()); this.slotCycleIndex = reader.ReadByte().ToString(); if (File.Exists(this.fileMSMRev)) { this.msmRev = HelperUtils.GetEnumValue(ConversionUtils.BytesToHexString(reader.ReadBytes(2).Reverse <byte>().ToArray <byte>()), this.fileMSMRev, EnumFileParser.ParseType.Hex); } else { this.msmRev = "0x" + ConversionUtils.BytesToHexString(reader.ReadBytes(2).Reverse <byte>().ToArray <byte>()); } return(new DIAG_VERNO_F_CLS(this.compileDate, this.compileTime, this.releaseDate, this.releaseTime, this.verDir, this.stationClassMark, this.mobCAIRev, this.mobModel, this.mobFWRev, this.slotCycleIndex, this.msmRev)); } } }
public override object Decode() { using (MemoryStream stream = new MemoryStream(this.BytesRX)) { using (BinaryReader reader = new BinaryReader(stream)) { if (stream.Length <= 3L) { return(new DIAG_EXT_BUILD_ID_F_CLS("-1", "-1", "-1")); } reader.BaseStream.Position = 1L; byte[] byteInput = reader.ReadBytes(3).Reverse <byte>().ToArray <byte>(); this.reserved = "0x00" + ConversionUtils.BytesToHexString(byteInput); byteInput = BitConverter.GetBytes(reader.ReadInt32()).Reverse <byte>().ToArray <byte>(); if (File.Exists(this.fileMSMHWRev)) { this.msmHWRev = HelperUtils.GetEnumValue(ConversionUtils.BytesToHexString(byteInput), this.fileMSMHWRev, EnumFileParser.ParseType.Hex); } else { this.msmHWRev = "0x" + ConversionUtils.BytesToHexString(byteInput); } if (File.Exists(this.fileMobModelID)) { this.mobModelID = HelperUtils.GetEnumValue(reader.ReadInt32(), this.fileMobModelID, EnumFileParser.ParseType.Dec); } else { this.mobModelID = Conversions.ToString(reader.ReadInt32()); } List <byte> list = new List <byte>(); while (reader.BaseStream.Position < (reader.BaseStream.Length - 1L)) { byte num = reader.ReadByte(); if (Convert.ToChar(num) == '\0') { break; } list.Add(num); } this.mobSWRev = ConversionUtils.GetASCIIString(list.ToArray()); return(new DIAG_EXT_BUILD_ID_F_CLS(this.msmHWRev, this.mobModelID, this.mobSWRev)); } } }
private void ProcessCommandQueue(AsyncOperation asyncOp) { this._isBusy = true; this._commandOutput = new ArrayList(); long count = this.GetCount(); long num2 = 0L; long position = 0L; string consoleTX = string.Empty; string consoleRX = string.Empty; string consoleRXASCII = string.Empty; Exception exc = null; try { object syncRoot = this.cmdQueue.SyncRoot; ObjectFlowControl.CheckForSyncLockOnValueType(syncRoot); lock (syncRoot) { while (this.cmdQueue.Count != 0) { if (this.Cancelled()) { this.CompletionMethod(null, true, asyncOp); return; } Command command = (Command)this.cmdQueue.Dequeue(); this._qcdmCmd.Add(command.CurrentQCDMCommand); this._nvCmd.Add(command.CurrentNVItem); if (!command.TransmitTX(this._instance, asyncOp)) { throw new Exception("Phone connection has been lost!"); } object objectValue = RuntimeHelpers.GetObjectValue(command.Decode()); if (command.BytesRX.Length == 0x88) { this._errorResponse.Add((Qcdm.NV_Response)command.BytesRX[0x83]); } else if (command.BytesRX.Length == 0x89) { this._errorResponse.Add((Qcdm.NV_Response)command.BytesRX[0x84]); } else if (command.BytesRX.Length < 0x88) { this._errorResponse.Add((Qcdm.NV_Response)command.BytesRX[0]); } if (objectValue == null) { throw new Exception("Error decoding command output!"); } this._commandOutput.Add(RuntimeHelpers.GetObjectValue(objectValue)); if (!this._disableLogging && !string.IsNullOrEmpty(command.ConsoleOutput)) { consoleTX = ConversionUtils.FormatHexStr(ConversionUtils.BytesToHexString(command.BytesTX)); consoleRX = ConversionUtils.FormatHexStr(ConversionUtils.BytesToHexString(command.BytesRX)); consoleRXASCII = ConversionUtils.GetASCIIString(command.BytesRX); } position += 1L; CommandQueueProgressChangedEventArgs arg = new CommandQueueProgressChangedEventArgs(command.ConsoleOutput, consoleTX, consoleRX, consoleRXASCII, (int)command.CurrentNVItem, (int)position, (int)count, (int)Math.Round((double)((((float)position) / ((float)count)) * 100f)), RuntimeHelpers.GetObjectValue(asyncOp.UserSuppliedState)); asyncOp.Post(this.onProgressReportDelegate, arg); } } if (this._chkNVItems) { position = 0L; long badParamNVItems = 0L; long badSecNVItems = 0L; long inactiveNVItems = 0L; long okayNVItems = 0L; object expression = this.cmdNVQueue.SyncRoot; ObjectFlowControl.CheckForSyncLockOnValueType(expression); lock (expression) { IEnumerator enumerator; try { enumerator = this.cmdNVQueue.GetEnumerator(); while (enumerator.MoveNext()) { byte num6; Command current = (Command)enumerator.Current; if (this.Cancelled()) { this.CompletionMethod(null, true, asyncOp); return; } if (current.BytesRX.Length == 0x88) { num6 = current.BytesRX[0x83]; } else if (current.BytesRX.Length == 0x89) { num6 = current.BytesRX[0x84]; } else if (current.BytesRX.Length < 0x88) { num6 = current.BytesRX[0]; } if (((num6 == 20) | (num6 == 5)) | (num6 == 6)) { current.ErrorResponse = (Qcdm.NV_Response)num6; num2 += 1L; } } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } } object obj5 = this.cmdNVQueue.SyncRoot; ObjectFlowControl.CheckForSyncLockOnValueType(obj5); lock (obj5) { IEnumerator enumerator2; if (string.IsNullOrEmpty(this._fileName)) { throw new FileNotFoundException(); } StreamWriter writer = new StreamWriter(this.FileName, false); writer.Write("[NV items]\r\n"); writer.Write(("[Complete items - " + ((count - num2)).ToString() + ", Items size - 128]") + "\r\n\r\n"); try { enumerator2 = this.cmdNVQueue.GetEnumerator(); while (enumerator2.MoveNext()) { string str6; Command command3 = (Command)enumerator2.Current; List <string> list = new List <string>(); if (command3.BytesRX[0] == 20) { str6 = ConversionUtils.BytesToHexString(command3.BytesTX).Substring(2, 4); } else { str6 = ConversionUtils.BytesToHexString(command3.BytesRX).Substring(2, 4); } string s = ConversionUtils.ReverseHex(str6).Replace(" ", ""); long num9 = long.Parse(s, NumberStyles.HexNumber); if (command3.ErrorResponse == Qcdm.NV_Response.NV_ERR_BAD_PARAM) { writer.Write((num9.ToString("d5") + " (0x" + s + ") - Parameter bad") + "\r\n\r\n"); badParamNVItems += 1L; } else if (command3.ErrorResponse == Qcdm.NV_Response.NV_ERR_BAD_SECURITY_MODE) { writer.Write((num9.ToString("d5") + " (0x" + s + ") - Access denied") + "\r\n\r\n"); badSecNVItems += 1L; } else if (command3.ErrorResponse == Qcdm.NV_Response.NV_ERR_INACTIVE_NV_ITEM) { writer.Write((num9.ToString("d5") + " (0x" + s + ") - Inactive item") + "\r\n\r\n"); inactiveNVItems += 1L; } else { string str11 = ConversionUtils.BytesToHexString(command3.BytesRX).Substring(6, 0x100); writer.Write((num9.ToString("d5") + " (0x" + s + ") - OK") + "\r\n"); writer.Write(ConversionUtils.FormatHexStr(str11.Substring(0, 0x20)) + "\r\n"); writer.Write(ConversionUtils.FormatHexStr(str11.Substring(0x20, 0x20)) + "\r\n"); writer.Write(ConversionUtils.FormatHexStr(str11.Substring(0x40, 0x20)) + "\r\n"); writer.Write(ConversionUtils.FormatHexStr(str11.Substring(0x60, 0x20)) + "\r\n"); writer.Write(ConversionUtils.FormatHexStr(str11.Substring(0x40, 0x20)) + "\r\n"); writer.Write(ConversionUtils.FormatHexStr(str11.Substring(80, 0x20)) + "\r\n"); writer.Write(ConversionUtils.FormatHexStr(str11.Substring(0x60, 0x20)) + "\r\n"); writer.Write(ConversionUtils.FormatHexStr(str11.Substring(0x80, 0x20)) + "\r\n\r\n"); okayNVItems += 1L; } position += 1L; NVItemsStatusEventArgs args2 = new NVItemsStatusEventArgs(position, badParamNVItems, badSecNVItems, inactiveNVItems, okayNVItems, count, (long)Math.Round((double)((((float)position) / ((float)count)) * 100f))); asyncOp.Post(this.onNVItemsStatusDelegate, args2); } } finally { if (enumerator2 is IDisposable) { (enumerator2 as IDisposable).Dispose(); } } writer.Close(); } } } catch (Exception exception1) { ProjectData.SetProjectError(exception1); exc = exception1; ProjectData.ClearProjectError(); } this.CompletionMethod(exc, this.Cancelled(), asyncOp); }