private void PrepareOnline() { SWDigest = 0; ReadRamRequest.Prepare(0xF3F8, 8); ExecuteRequest(ReadRamRequest); AddOperationLog("Read 0xF3F8(8): " + DataHelper.ByteArrayToStr(ReadRamRequest.value)); ReadRamRequest.Prepare(0xF6F8, 8); ExecuteRequest(ReadRamRequest); AddOperationLog("Read 0xF6F8(8): " + DataHelper.ByteArrayToStr(ReadRamRequest.value)); ReadRamRequest.Prepare(0xC0, 16); ExecuteRequest(ReadRamRequest); AddOperationLog("Read 0xC0(16): " + DataHelper.ByteArrayToStr(ReadRamRequest.value)); if (CalcEcuSn && ReadRamRequest.value != null) { ecuSn = DiagProtocolHelper.CalcEcuSn(ReadRamRequest.value); } else { ecuSn = DataHelper.StrToByteArray(EcuSn, 8); } ecuSnHashBuffer = DiagProtocolHelper.InitEcuSnHashBuffer(ecuSn, 240); AddOperationLog("ECU SN: " + DataHelper.ByteArrayToStr(ecuSn)); var index = 0; //TODO: чтение 176 байт 30h + 30h + 30h + 20h var buffer = new byte[0xB0]; for (int i = 0; i < 3; i++) { if (!ReadRamPart(buffer, 0x30, ref index)) { return; } } if (!ReadRamPart(buffer, 0x20, ref index)) { return; } //AddOperationLog("SWDigest buffer: " + DataHelper.ByteArrayToStr(buffer)); SWDigest = DataHelper.CalculateCRC(buffer, 0, buffer.Length); AddOperationLog("SWDigest: " + SWDigest.ToString("X4")); }
public OltProtocol() { Version = OltProtocolVersion.OltDiagV1; diagRequest = OltDiagV1DataRequest; ReadFreq = 0; Requests = new Queue <Request>(); readThread = new BackgroundWorker { WorkerSupportsCancellation = true }; readThread.DoWork += readThread_DoWork; serialPort = new SafeSerialPort("COM1", 10400, Parity.None, 8, StopBits.One) { WriteTimeout = 100, ReadTimeout = 100 }; ecuSn = new byte[8]; ecuSnHashBuffer = DiagProtocolHelper.InitEcuSnHashBuffer(ecuSn, 240); }