/// <summary> /// Get the embedded software information. /// </summary> /// <param name="targetConfiguration">The target configuration information retrieved from the target.</param> /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.GetEmbeddedInformation() method /// is not CommunicationError.Success.</exception> public void GetEmbeddedInformation(out TargetConfiguration_t targetConfiguration) { // Check that the function delegate has been initialized. Debug.Assert(m_MutexCommuncationInterface != null, "CommunicationParent.GetEmbeddedInformation() - [m_MutexCommuncation != null]"); targetConfiguration = new TargetConfiguration_t(); TargetConfiguration_t localTargetConfiguration = new TargetConfiguration_t(); CommunicationError errorCode = CommunicationError.UnknownError; ProtocolPTU.GetEmbeddedInfoRes embInfo = new ProtocolPTU.GetEmbeddedInfoRes(); try { errorCode = m_WatchClockMarshal.GetEmbeddedInformation(ref embInfo); m_MutexCommuncationInterface.WaitOne(DefaultMutexWaitDurationMs, false); if (errorCode == CommunicationError.Success) { localTargetConfiguration.Version = embInfo.SoftwareVersion; localTargetConfiguration.CarIdentifier = embInfo.CarID; localTargetConfiguration.SubSystemName = embInfo.SubSystemName; localTargetConfiguration.ProjectIdentifier = embInfo.IdentifierString; localTargetConfiguration.ConversionMask = embInfo.ConfigurationMask; } } catch (Exception) { errorCode = CommunicationError.SystemException; throw new CommunicationException(Resources.EMGetTargetConfigurationFailed, errorCode); } finally { m_MutexCommuncationInterface.ReleaseMutex(); } if (DebugMode.Enabled == true) { DebugMode.GetEmbeddedInformation_t getEmbeddedInformation = new DebugMode.GetEmbeddedInformation_t(localTargetConfiguration.Version, localTargetConfiguration.CarIdentifier, localTargetConfiguration.SubSystemName, localTargetConfiguration.ProjectIdentifier, localTargetConfiguration.ConversionMask, errorCode); DebugMode.Write(getEmbeddedInformation.ToXML()); } if (errorCode != CommunicationError.Success) { throw new CommunicationException(Resources.EMGetTargetConfigurationFailed, errorCode); } targetConfiguration.Version = localTargetConfiguration.Version; targetConfiguration.CarIdentifier = localTargetConfiguration.CarIdentifier; targetConfiguration.SubSystemName = localTargetConfiguration.SubSystemName; targetConfiguration.ProjectIdentifier = localTargetConfiguration.ProjectIdentifier; targetConfiguration.ConversionMask = localTargetConfiguration.ConversionMask; }
/// <summary> /// Get the embedded software information. /// </summary> /// <param name="targetConfiguration">The target configuration information retrieved from the target.</param> /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.GetEmbeddedInformation() method /// is not CommunicationError.Success.</exception> public void GetEmbeddedInformation(out TargetConfiguration_t targetConfiguration) { // Check that the function delegate has been initialized. Debug.Assert(m_GetEmbeddedInformation != null, "CommunicationParent.GetEmbeddedInformation() - [m_GetEmbeddedInformation != null]"); Debug.Assert(m_MutexCommuncationInterface != null, "CommunicationParent.GetEmbeddedInformation() - [m_MutexCommuncation != null]"); targetConfiguration = new TargetConfiguration_t(); TargetConfiguration_t localTargetConfiguration = new TargetConfiguration_t(); CommunicationError errorCode = CommunicationError.UnknownError; try { m_MutexCommuncationInterface.WaitOne(DefaultMutexWaitDurationMs, false); errorCode = (CommunicationError)m_GetEmbeddedInformation( out localTargetConfiguration.Version, out localTargetConfiguration.CarIdentifier, out localTargetConfiguration.SubSystemName, out localTargetConfiguration.ProjectIdentifier, out localTargetConfiguration.ConversionMask); } catch (Exception) { errorCode = CommunicationError.SystemException; throw new CommunicationException(Resources.EMGetTargetConfigurationFailed, errorCode); } finally { m_MutexCommuncationInterface.ReleaseMutex(); } if (DebugMode.Enabled == true) { DebugMode.GetEmbeddedInformation_t getEmbeddedInformation = new DebugMode.GetEmbeddedInformation_t( localTargetConfiguration.Version, localTargetConfiguration.CarIdentifier, localTargetConfiguration.SubSystemName, localTargetConfiguration.ProjectIdentifier, localTargetConfiguration.ConversionMask, errorCode); DebugMode.Write(getEmbeddedInformation.ToXML()); } if (errorCode != CommunicationError.Success) { throw new CommunicationException(Resources.EMGetTargetConfigurationFailed, errorCode); } targetConfiguration.Version = localTargetConfiguration.Version.Trim(); targetConfiguration.CarIdentifier = localTargetConfiguration.CarIdentifier.Trim(); targetConfiguration.SubSystemName = localTargetConfiguration.SubSystemName.Trim(); targetConfiguration.ProjectIdentifier = localTargetConfiguration.ProjectIdentifier.Trim(); targetConfiguration.ConversionMask = localTargetConfiguration.ConversionMask; }