示例#1
0
        /// <summary>
        /// Invoked after the ECU identifier response has been received
        /// </summary>
        private void EcuIdentifierResponseRead(IAsyncResult asyncResult)
        {
            Trace.WriteLine("SsmInterface.EcuIdentifierResponseRead");
            GetEcuIdentifierAsyncResult internalState = (GetEcuIdentifierAsyncResult)asyncResult.AsyncState;

            try
            {
                SsmPacket response = internalState.Parser.EndReadFromStream(asyncResult);
                this.ecuIdentifier    = response.EcuIdentifier;
                this.compatibilityMap = response.CompatibilityMap;
            }
            catch (IOException ex)
            {
                internalState.Exception = ex;
            }
            catch (SecurityException ex)
            {
                internalState.Exception = ex;
            }

            Exception localException = internalState.Exception;

            if (localException == null)
            {
                Trace.WriteLine("SsmInterface.EcuIdentifierResponseRead: " + this.ecuIdentifier);
            }
            else
            {
                Trace.WriteLine("SsmInterface.EcuIdentifierResponseRead: " + localException.ToString());
            }
            internalState.Completed();
        }
示例#2
0
        /// <summary>
        /// Invoked after the ECU identifier request has been written - begins reading the response
        /// </summary>
        private void EcuIdentifierRequestWritten(IAsyncResult asyncResult)
        {
            Trace.WriteLine("SsmInterface.EcuIdentifierRequestWritten");
            GetEcuIdentifierAsyncResult internalState = (GetEcuIdentifierAsyncResult)asyncResult.AsyncState;

            try
            {
                this.stream.EndWrite(asyncResult);
                internalState.Parser.BeginReadFromStream(this.stream, EcuIdentifierResponseRead, internalState);
            }
            catch (IOException ex)
            {
                internalState.Exception = ex;
                internalState.Completed();
            }
            catch (SecurityException ex)
            {
                internalState.Exception = ex;
                internalState.Completed();
            }
        }