Beispiel #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();
        }
Beispiel #2
0
        /// <summary>
        /// Sends an ECU identifier request
        /// </summary>
        public IAsyncResult BeginGetEcuIdentifier(AsyncCallback callback, object state)
        {
            Trace.WriteLine("SsmInterface.BeginGetEcuIdentifier");
            this.BeginOperation();

            GetEcuIdentifierAsyncResult internalState = new GetEcuIdentifierAsyncResult(
                callback,
                state);
            SsmPacket request = SsmPacket.CreateEcuIdentifierRequest();

            this.stream.BeginWrite(
                request.Data,
                0,
                request.Data.Length,
                this.EcuIdentifierRequestWritten,
                internalState);
            return(internalState);
        }
Beispiel #3
0
        /// <summary>
        /// Returns the ECU identifier to the caller
        /// </summary>
        public void EndGetEcuIdentifier(IAsyncResult asyncResult)
        {
            Trace.WriteLine("SsmInterface.EndGetEcuIdentifier");
            GetEcuIdentifierAsyncResult internalState = (GetEcuIdentifierAsyncResult)asyncResult;

            try
            {
                this.EndOperation();

                if (internalState.Exception != null)
                {
                    throw internalState.Exception;
                }
            }
            finally
            {
                internalState.Dispose();
            }
        }
Beispiel #4
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();
            }
        }