/// <summary>Connect to ECU</summary> /// <param name="language">Language: 0=german, 1=english, 2=french, 3=italian</param> /// <returns>0 on success, else see ReturnValue</returns> public override ReturnValue Connect(LanguageId language) { mEcu.pVersion = ProtocolVersion; ReturnValue ret = mEcu.Connect(); if (ret == ReturnValue.NoError) { // Read digital info block mInfo = new DigitalInfoBlock(); byte[] ReadBuffer = new byte[MAX_READ_BUFFER_SIZE]; ret = mEcu.Read(Comm.OrderByte.ReadInfoBlock, out ReadBuffer); if (ret == ReturnValue.NoError) { mInfo.Parse(ref ReadBuffer); // todo: so ok? mFirmware.SoftwareRevision = mInfo.SoftwareVersion.Revision; // Read Language data UInt16 LanguageValue = 0; switch (language) { case LanguageId.German: LanguageValue = 0; break; case LanguageId.English: LanguageValue = 1; break; case LanguageId.French: LanguageValue = 2; break; case LanguageId.Italian: LanguageValue = 3; break; default: LanguageValue = 1; break; } ReadBuffer = new byte[4096]; ret = mEcu.Read(Comm.OrderByte.ReadLanguage, LanguageValue, out ReadBuffer); if (ret == ReturnValue.NoError) { switch (language) { case ProtocolBase.LanguageId.German: mLanguage = new LanguageBlock(Block.BlockId.IdLngDE); break; case ProtocolBase.LanguageId.English: mLanguage = new LanguageBlock(Block.BlockId.IdLngEN); break; case ProtocolBase.LanguageId.French: mLanguage = new LanguageBlock(Block.BlockId.IdLngFR); break; case ProtocolBase.LanguageId.Italian: mLanguage = new LanguageBlock(Block.BlockId.IdLngIT); break; default: mLanguage = new LanguageBlock(Block.BlockId.IdLngEN); break; } ReturnValue BlockRet = ReturnValue.NoError; // achtung kompatibilitaet 14 15 ! BlockRet = mLanguage.ReadPlain(ref ReadBuffer); if (BlockRet == ReturnValue.NoError) { BlockRet = mLanguage.Parse(); } if (BlockRet != ReturnValue.NoError) { ret = ReturnValue.LanguageNotValid; } } } } return(ret); }
/// <summary> /// Connect to ECU /// </summary> /// <param name="language">Language: 0=german, 1=english, 2=french, 3=italian</param> /// <returns>0 on success, else see ReturnValue</returns> public override ReturnValue Connect(LanguageId language) { mEcu.pVersion = ProtocolVersion; ReturnValue ret = mEcu.Connect(); if (ret == ReturnValue.NoError) { // Read digital info block mInfo = new DigitalInfoBlock(); byte[] ReadBuffer = new byte[MAX_READ_BUFFER_SIZE]; ret = mEcu.Read(Comm.OrderByte.ReadInfoBlock, out ReadBuffer); if (ret == ReturnValue.Retry) { ret = mEcu.Read(Comm.OrderByte.ReadInfoBlock, out ReadBuffer); } if (ret == ReturnValue.NoError) { ReturnValue RetB; RetB = mInfo.Parse(ref ReadBuffer); mFirmware.SoftwareRevision = mInfo.SoftwareVersion.Revision; mRtcData.SoftwareRevision = mInfo.SoftwareVersion.Revision; mEmpData.Version = mInfo.EmpiricalVersion; // Read Language data Block.BlockId LanguageBlockId = GetLanguageBlockId(language); ReadBuffer = new byte[4096]; ret = mEcu.Read(Comm.OrderByte.ReadLanguage, (UInt16)LanguageBlockId, out ReadBuffer); if (ret == ReturnValue.Retry) { // One retry ret = mEcu.Read(Comm.OrderByte.ReadLanguage, (UInt16)LanguageBlockId, out ReadBuffer); } if (ret == ReturnValue.NoError) { mLanguage = new LanguageBlock(LanguageBlockId); ReturnValue BlockRet = ReturnValue.NoError; BlockRet = mLanguage.ReadRaw(ref ReadBuffer, false); if (BlockRet == ReturnValue.NoError) { BlockRet = mLanguage.Parse(); } if (BlockRet != ReturnValue.NoError) { ret = ReturnValue.LanguageNotValid; } } else { // Language not available, so load english ret = mEcu.Read(Comm.OrderByte.ReadLanguage, (UInt16)Block.BlockId.IdLngEN, out ReadBuffer); if (ret == ReturnValue.Retry) { // One retry ret = mEcu.Read(Comm.OrderByte.ReadLanguage, (UInt16)Block.BlockId.IdLngEN, out ReadBuffer); } if (ret == ReturnValue.NoError) { mLanguage = new LanguageBlock(Block.BlockId.IdLngEN); ReturnValue BlockRet = ReturnValue.NoError; BlockRet = mLanguage.ReadRaw(ref ReadBuffer, false); if (BlockRet == ReturnValue.NoError) { BlockRet = mLanguage.Parse(); } if (BlockRet != ReturnValue.NoError) { ret = ReturnValue.LanguageNotValid; } } else { if (mInfo.ConfigurationVersion.Hauptversion == 0) { // Emergency configuration: language not available mLanguage = new LanguageBlock(Block.BlockId.IdLngEN); ret = ReturnValue.NoError; } } } } } else { mEcu.Disconnect(); } return(ret); }