示例#1
0
        /// <summary>
        /// Invoked after the read response has been received from the ECU
        /// </summary>
        private void MultipleReadResponseReceived(IAsyncResult asyncResult)
        {
            MultipleReadAsyncResult internalState = (MultipleReadAsyncResult)asyncResult.AsyncState;

            try
            {
                SsmPacket response = internalState.Parser.EndReadFromStream(asyncResult);

                // Uncomment for easier debugging:
                //byte[] data = response.Data;
                //SsmCommand command = response.Command;
                //int payloadLength = response.PayloadLength;
                //IList<byte> values = response.Values;

                foreach (byte value in response.Values)
                {
                    internalState.ValueList.Add(value);
                }
            }
            catch (IOException ex)
            {
                internalState.Exception = ex;
            }
            catch (SecurityException ex)
            {
                internalState.Exception = ex;
            }
            internalState.Completed();
        }
示例#2
0
        /// <summary>
        /// Invoked after the read request has been written to the ECU - begins waiting for the response
        /// </summary>
        private void MultipleReadRequestWritten(IAsyncResult asyncResult)
        {
            MultipleReadAsyncResult internalState = (MultipleReadAsyncResult)asyncResult.AsyncState;

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