private static byte[] AttachCRC(byte[] command) { byte[] array = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; byte[] cRCAsByteFromByte = CRC.GetCRCAsByteFromByte(command); CommandByteArrays.nullCmd_136_length.CopyTo(array, 0); command.CopyTo(array, 0); array[0x85] = cRCAsByteFromByte[0]; array[0x86] = cRCAsByteFromByte[1]; array[0x87] = 0x7e; return(array); }
public Command ReadNVItem(int item) { string strConsoleOut = "DIAG_NV_WRITE - Item: " + item.ToString(); byte[] buffer3 = new byte[3]; byte[] buffer2 = ConversionUtils.HexStringToBytes("26" + this.ProcessNVItem(item, 6)); List <byte> list = new List <byte>(); foreach (byte num in buffer2) { list.Add(num); } while (list.Count < 0x85) { list.Add(0); } byte[] cRCAsByteFromByte = CRC.GetCRCAsByteFromByte(list.ToArray()); list.Add(cRCAsByteFromByte[0]); list.Add(cRCAsByteFromByte[1]); list.Add(0x7e); return(new Command(list.ToArray(), strConsoleOut)); }
public Command(Qcdm.Cmd QCDMCmd, byte[] data, string strConsoleOut) { this._currQCDMCmd = Qcdm.Cmd.NOT_A_COMMAND; this._currNVItem = NVItemList.NOT_AN_NV_ITEM; this._currQCDMCmd = QCDMCmd; List <byte> list = new List <byte> { byte.Parse(Conversions.ToString((int)QCDMCmd)) }; foreach (byte num in data) { list.Add(num); } this._txBytes = CRC.GetBufferWithCRC(list.ToArray()); if (!string.IsNullOrEmpty(strConsoleOut)) { this._consoleOut = strConsoleOut + " (CRC+7E)"; } else { this._consoleOut = string.Empty; } }
public Command(Qcdm.Cmd QCDMCmd, NVItemList NVItem, byte[] NVItemData, string strConsoleOut) { this._currQCDMCmd = Qcdm.Cmd.NOT_A_COMMAND; this._currNVItem = NVItemList.NOT_AN_NV_ITEM; this._currQCDMCmd = QCDMCmd; this._currNVItem = NVItem; string str = long.Parse(Conversions.ToString((long)NVItem)).ToString("X"); while (str.Length < 4) { str = "0" + str; } List <byte> list = new List <byte> { byte.Parse(Conversions.ToString((int)QCDMCmd)), Convert.ToByte(Conversions.ToString(str[2]) + Conversions.ToString(str[3]), 0x10), Convert.ToByte(Conversions.ToString(str[0]) + Conversions.ToString(str[1]), 0x10) }; foreach (byte num in NVItemData) { list.Add(num); } while (list.Count < 0x85) { list.Add(0); } this._txBytes = CRC.GetBufferWithCRC(list.ToArray()); if (!string.IsNullOrEmpty(strConsoleOut)) { this._consoleOut = strConsoleOut + " (CRC+7E)"; } else { this._consoleOut = string.Empty; } }