Exemplo n.º 1
0
        // used with private reflection by wsdl.exe and webserviceutil.exe
        void TurnOnGetAndPost()
        {
            bool needPost = (enabledProtocols & ProtocolsEnum.HttpPost) == 0;
            bool needGet  = (enabledProtocols & ProtocolsEnum.HttpGet) == 0;

            if (!needGet && !needPost)
            {
                return;
            }

            ArrayList importers  = new ArrayList(ProtocolImporterTypes);
            ArrayList reflectors = new ArrayList(ProtocolReflectorTypes);

            if (needPost)
            {
                importers.Add(typeof(HttpPostProtocolImporter));
                reflectors.Add(typeof(HttpPostProtocolReflector));
            }
            if (needGet)
            {
                importers.Add(typeof(HttpGetProtocolImporter));
                reflectors.Add(typeof(HttpGetProtocolReflector));
            }
            ProtocolImporterTypes  = (Type[])importers.ToArray(typeof(Type));
            ProtocolReflectorTypes = (Type[])reflectors.ToArray(typeof(Type));
            enabledProtocols      |= ProtocolsEnum.HttpGet | ProtocolsEnum.HttpPost;
        }
Exemplo n.º 2
0
        /// <include file='doc\ServiceDescriptionReflector.uex' path='docs/doc[@for="ServiceDescriptionReflector.ServiceDescriptionReflector"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public ServiceDescriptionReflector()
        {
            Type[] reflectorTypes = WebServicesConfiguration.Current.ProtocolReflectorTypes;
            reflectors = new ProtocolReflector[reflectorTypes.Length];
            for (int i = 0; i < reflectors.Length; i++)
            {
                ProtocolReflector reflector = (ProtocolReflector)Activator.CreateInstance(reflectorTypes[i]);
                reflector.Initialize(this);
                reflectors[i] = reflector;
            }
            ProtocolsEnum enabledProtocols = WebServicesConfiguration.Current.EnabledProtocols;

            if ((enabledProtocols & ProtocolsEnum.HttpPost) == 0 && (enabledProtocols & ProtocolsEnum.HttpPostLocalhost) != 0)
            {
                reflectorsWithPost = new ProtocolReflector[reflectors.Length + 1];
                for (int i = 0; i < reflectorsWithPost.Length - 1; i++)
                {
                    ProtocolReflector reflector = (ProtocolReflector)Activator.CreateInstance(reflectorTypes[i]);
                    reflector.Initialize(this);
                    reflectorsWithPost[i] = reflector;
                }
                ProtocolReflector reflectorWithPost = new HttpPostProtocolReflector();
                reflectorWithPost.Initialize(this);
                reflectorsWithPost[reflectorsWithPost.Length - 1] = reflectorWithPost;
            }
        }
Exemplo n.º 3
0
 internal bool IsSupported(ProtocolsEnum protocol)
 {
     return((versionsSupported & protocol) == protocol);
 }
Exemplo n.º 4
0
        internal SoapServerType(Type type, ProtocolsEnum versionsSupported) : base(type)
        {
            this.versionsSupported = versionsSupported;
            bool soap11 = (versionsSupported & ProtocolsEnum.HttpSoap) != 0;
            bool soap12 = (versionsSupported & ProtocolsEnum.HttpSoap12) != 0;

            LogicalMethodInfo[] methodInfos      = WebMethodReflector.GetMethods(type);
            ArrayList           mappings         = new ArrayList();
            WebServiceAttribute serviceAttribute = WebServiceReflector.GetAttribute(type);
            object soapServiceAttribute          = SoapReflector.GetSoapServiceAttribute(type);

            routingOnSoapAction     = SoapReflector.GetSoapServiceRoutingStyle(soapServiceAttribute) == SoapServiceRoutingStyle.SoapAction;
            serviceNamespace        = serviceAttribute.Namespace;
            serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(type);
            SoapReflectionImporter soapImporter = SoapReflector.CreateSoapImporter(serviceNamespace, serviceDefaultIsEncoded);
            XmlReflectionImporter  xmlImporter  = SoapReflector.CreateXmlImporter(serviceNamespace, serviceDefaultIsEncoded);

            SoapReflector.IncludeTypes(methodInfos, soapImporter);
            WebMethodReflector.IncludeTypes(methodInfos, xmlImporter);
            SoapReflectedMethod[] soapMethods = new SoapReflectedMethod[methodInfos.Length];

            SoapExtensionType[] extensionTypes = WebServicesConfiguration.Current.SoapExtensionTypes;
            ArrayList           highPri        = new ArrayList();
            ArrayList           lowPri         = new ArrayList();

            for (int i = 0; i < extensionTypes.Length; i++)
            {
                SoapReflectedExtension extension = new SoapReflectedExtension(extensionTypes[i].Type, null, extensionTypes[i].Priority);
                if (extensionTypes[i].Group == SoapExtensionType.PriorityGroup.High)
                {
                    highPri.Add(extension);
                }
                else
                {
                    lowPri.Add(extension);
                }
            }
            HighPriExtensions = (SoapReflectedExtension[])highPri.ToArray(typeof(SoapReflectedExtension));
            LowPriExtensions  = (SoapReflectedExtension[])lowPri.ToArray(typeof(SoapReflectedExtension));
            Array.Sort(HighPriExtensions);
            Array.Sort(LowPriExtensions);
            HighPriExtensionInitializers = SoapReflectedExtension.GetInitializers(type, HighPriExtensions);
            LowPriExtensionInitializers  = SoapReflectedExtension.GetInitializers(type, LowPriExtensions);

            for (int i = 0; i < methodInfos.Length; i++)
            {
                LogicalMethodInfo   methodInfo = methodInfos[i];
                SoapReflectedMethod soapMethod = SoapReflector.ReflectMethod(methodInfo, false, xmlImporter, soapImporter, serviceAttribute.Namespace);
                mappings.Add(soapMethod.requestMappings);
                if (soapMethod.responseMappings != null)
                {
                    mappings.Add(soapMethod.responseMappings);
                }
                mappings.Add(soapMethod.inHeaderMappings);
                if (soapMethod.outHeaderMappings != null)
                {
                    mappings.Add(soapMethod.outHeaderMappings);
                }
                soapMethods[i] = soapMethod;
            }

            XmlSerializer[] serializers = XmlSerializer.FromMappings((XmlMapping[])mappings.ToArray(typeof(XmlMapping)));
            int             count       = 0;

            for (int i = 0; i < soapMethods.Length; i++)
            {
                SoapServerMethod    serverMethod = new SoapServerMethod();
                SoapReflectedMethod soapMethod   = soapMethods[i];
                serverMethod.parameterSerializer = serializers[count++];
                if (soapMethod.responseMappings != null)
                {
                    serverMethod.returnSerializer = serializers[count++];
                }
                serverMethod.inHeaderSerializer = serializers[count++];
                if (soapMethod.outHeaderMappings != null)
                {
                    serverMethod.outHeaderSerializer = serializers[count++];
                }
                serverMethod.methodInfo            = soapMethod.methodInfo;
                serverMethod.action                = soapMethod.action;
                serverMethod.extensions            = soapMethod.extensions;
                serverMethod.extensionInitializers = SoapReflectedExtension.GetInitializers(serverMethod.methodInfo, soapMethod.extensions);
                serverMethod.oneWay                = soapMethod.oneWay;
                serverMethod.rpc        = soapMethod.rpc;
                serverMethod.use        = soapMethod.use;
                serverMethod.paramStyle = soapMethod.paramStyle;
                ArrayList inHeaders  = new ArrayList();
                ArrayList outHeaders = new ArrayList();
                for (int j = 0; j < soapMethod.headers.Length; j++)
                {
                    SoapHeaderMapping   mapping    = new SoapHeaderMapping();
                    SoapReflectedHeader soapHeader = soapMethod.headers[j];
                    mapping.memberInfo = soapHeader.memberInfo;
                    mapping.repeats    = soapHeader.repeats;
                    mapping.custom     = soapHeader.custom;
                    mapping.direction  = soapHeader.direction;
                    mapping.headerType = soapHeader.headerType;
                    if (mapping.direction == SoapHeaderDirection.In)
                    {
                        inHeaders.Add(mapping);
                    }
                    else if (mapping.direction == SoapHeaderDirection.Out)
                    {
                        outHeaders.Add(mapping);
                    }
                    else
                    {
                        inHeaders.Add(mapping);
                        outHeaders.Add(mapping);
                    }
                }
                serverMethod.inHeaderMappings = (SoapHeaderMapping[])inHeaders.ToArray(typeof(SoapHeaderMapping));
                if (serverMethod.outHeaderSerializer != null)
                {
                    serverMethod.outHeaderMappings = (SoapHeaderMapping[])outHeaders.ToArray(typeof(SoapHeaderMapping));
                }

                // check feasibility of routing on request element for soap 1.1
                if (soap11 && !routingOnSoapAction && soapMethod.requestElementName.IsEmpty)
                {
                    throw new SoapException(Res.GetString(Res.TheMethodDoesNotHaveARequestElementEither1, serverMethod.methodInfo.Name), new XmlQualifiedName(Soap.ClientCode, Soap.Namespace));
                }

                // we can lookup methods by action or request element
                if (methods[soapMethod.action] == null)
                {
                    methods[soapMethod.action] = serverMethod;
                }
                else
                {
                    // duplicate soap actions not allowed in soap 1.1 if we're routing on soap action
                    if (soap11 && routingOnSoapAction)
                    {
                        SoapServerMethod duplicateMethod = (SoapServerMethod)methods[soapMethod.action];
                        throw new SoapException(Res.GetString(Res.TheMethodsAndUseTheSameSoapActionWhenTheService3, serverMethod.methodInfo.Name, duplicateMethod.methodInfo.Name, soapMethod.action), new XmlQualifiedName(Soap.ClientCode, Soap.Namespace));
                    }
                    duplicateMethods[soapMethod.action] = serverMethod;
                }

                if (methods[soapMethod.requestElementName] == null)
                {
                    methods[soapMethod.requestElementName] = serverMethod;
                }
                else
                {
                    // duplicate request elements not allowed in soap 1.1 if we're routing on request element
                    if (soap11 && !routingOnSoapAction)
                    {
                        SoapServerMethod duplicateMethod = (SoapServerMethod)methods[soapMethod.requestElementName];
                        throw new SoapException(Res.GetString(Res.TheMethodsAndUseTheSameRequestElementXmlns4, serverMethod.methodInfo.Name, duplicateMethod.methodInfo.Name, soapMethod.requestElementName.Name, soapMethod.requestElementName.Namespace), new XmlQualifiedName(Soap.ClientCode, Soap.Namespace));
                    }
                    duplicateMethods[soapMethod.requestElementName] = serverMethod;
                }
            }
        }
Exemplo n.º 5
0
 internal SoapServerProtocol(ProtocolsEnum versionsSupported)
 {
     this.versionsSupported = versionsSupported;
 }
Exemplo n.º 6
0
        // Set our hard-coded defaults. In some cases we need to merge in
        // our hard-coded defaults with those already loaded from the config system.
        void SetInternalDefaults()
        {
            for (int i = 0; i < Protocols.Length; i++)
            {
                enabledProtocols |= GetProtocol(Protocols[i]);
            }

            // SOAP12: disable soap 1.2 by removing it from the enum
            enabledProtocols &= (~ProtocolsEnum.HttpSoap12);

            ArrayList serverProtocolFactoryList = new ArrayList();

            // These are order sensitive. We want SOAP to go first for perf
            // and Discovery (?wsdl and ?disco) should go before Documentation
            // both soap versions are handled by the same factory
            if ((enabledProtocols & ProtocolsEnum.AnyHttpSoap) != 0)
            {
                serverProtocolFactoryList.Add(new SoapServerProtocolFactory());
            }
            if ((enabledProtocols & ProtocolsEnum.HttpPost) != 0)
            {
                serverProtocolFactoryList.Add(new HttpPostServerProtocolFactory());
            }
            if ((enabledProtocols & ProtocolsEnum.HttpPostLocalhost) != 0)
            {
                serverProtocolFactoryList.Add(new HttpPostLocalhostServerProtocolFactory());
            }
            if ((enabledProtocols & ProtocolsEnum.HttpGet) != 0)
            {
                serverProtocolFactoryList.Add(new HttpGetServerProtocolFactory());
            }
            if ((enabledProtocols & ProtocolsEnum.Documentation) != 0)
            {
                serverProtocolFactoryList.Add(new DiscoveryServerProtocolFactory());
                serverProtocolFactoryList.Add(new DocumentationServerProtocolFactory());
            }
            serverProtocolFactories = (ServerProtocolFactory[])serverProtocolFactoryList.ToArray(typeof(ServerProtocolFactory));

            ArrayList protocolReflectorList = new ArrayList();
            ArrayList protocolImporterList  = new ArrayList();

            // order is important for soap: 1.2 must come after 1.1
            if ((enabledProtocols & ProtocolsEnum.HttpSoap) != 0)
            {
                protocolReflectorList.Add(typeof(SoapProtocolReflector));
                protocolImporterList.Add(typeof(SoapProtocolImporter));
            }
            if ((enabledProtocols & ProtocolsEnum.HttpSoap12) != 0)
            {
                protocolReflectorList.Add(typeof(Soap12ProtocolReflector));
                protocolImporterList.Add(typeof(Soap12ProtocolImporter));
            }
            if ((enabledProtocols & ProtocolsEnum.HttpGet) != 0)
            {
                protocolReflectorList.Add(typeof(HttpGetProtocolReflector));
                protocolImporterList.Add(typeof(HttpGetProtocolImporter));
            }
            if ((enabledProtocols & ProtocolsEnum.HttpPost) != 0)
            {
                protocolReflectorList.Add(typeof(HttpPostProtocolReflector));
                protocolImporterList.Add(typeof(HttpPostProtocolImporter));
            }

            ProtocolReflectorTypes = (Type[])protocolReflectorList.ToArray(typeof(Type));
            ProtocolImporterTypes  = (Type[])protocolImporterList.ToArray(typeof(Type));

            // Initialize static data
            if (defaultFormatTypes == null)
            {
                lock (typeof(WebServicesConfiguration)){
                    if (defaultFormatTypes == null)
                    {
                        ReturnWriterTypes          = new Type[] { typeof(XmlReturnWriter) };
                        ParameterReaderTypes       = new Type[] { typeof(UrlParameterReader), typeof(HtmlFormParameterReader) };
                        MimeReflectorTypes         = new Type[] { typeof(MimeXmlReflector), typeof(MimeFormReflector) };
                        MimeImporterTypes          = new Type[] { typeof(MimeXmlImporter), typeof(MimeFormImporter), typeof(MimeTextImporter) };
                        SoapTransportImporterTypes = new Type[] { typeof(SoapHttpTransportImporter) };
                        discoveryReferenceTypes    = new Type[] { typeof(DiscoveryDocumentReference), typeof(ContractReference), typeof(SchemaReference), typeof(System.Web.Services.Discovery.SoapBinding) };
                        defaultFormatTypes         = new Type[] {
                            typeof(HttpAddressBinding),
                            typeof(HttpBinding),
                            typeof(HttpOperationBinding),
                            typeof(HttpUrlEncodedBinding),
                            typeof(HttpUrlReplacementBinding),
                            typeof(MimeContentBinding),
                            typeof(MimeXmlBinding),
                            typeof(MimeMultipartRelatedBinding),
                            typeof(MimeTextBinding),
                            typeof(System.Web.Services.Description.SoapBinding),
                            typeof(SoapOperationBinding),
                            typeof(SoapBodyBinding),
                            typeof(SoapFaultBinding),
                            typeof(SoapHeaderBinding),
                            typeof(SoapAddressBinding),
                            // SOAP12: WSDL soap12 binding disabled

                            /*typeof(Soap12Binding),
                             * typeof(Soap12OperationBinding),
                             * typeof(Soap12BodyBinding),
                             * typeof(Soap12FaultBinding),
                             * typeof(Soap12HeaderBinding),
                             * typeof(Soap12AddressBinding),*/
                        };
                    }
                }
            }

            // Merge hard-coded ServiceDescriptionFormatTypes with custom ones from config
            if (serviceDescriptionFormatExtensionTypes.Length == 0)
            {
                ServiceDescriptionFormatExtensionTypes = defaultFormatTypes;
            }
            else
            {
                Type[] formatTypes = new Type[defaultFormatTypes.Length + serviceDescriptionFormatExtensionTypes.Length];
                Array.Copy(defaultFormatTypes, formatTypes, defaultFormatTypes.Length);
                Array.Copy(serviceDescriptionFormatExtensionTypes, 0, formatTypes, defaultFormatTypes.Length, serviceDescriptionFormatExtensionTypes.Length);
                ServiceDescriptionFormatExtensionTypes = formatTypes;
            }

            internalDefaultsInitialized = true;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Prepares the ELM327 device for operation by setting various parameters to control formatting of requests/responses and optimize
        /// communications between the device and this application.
        /// </summary>
        private bool PrepareELM327()
        {
            // Variables
            StringBuilder sb = new StringBuilder(10);
            short protocolNumber = 0;

            // Ensure the connection is valid
            if(_connection != null && _connection.IsOpen)
            {
                // Prepare the port
                _connection.BaudRate = _connectionSettings.BaudRate;
                _connection.DataBits = _connectionSettings.DataBits;
                _connection.Parity = _connectionSettings.Parity;
                _connection.StopBits = _connectionSettings.StopBits;
                _connection.NewLine = "\r";
                _connection.ReadTimeout = 100;
                _connection.WriteTimeout = 50;

                /*
                 * Customize settings for speed and function
                 */
                // Turn response spaces off
                sb.Append(ExecuteATCommand(@"S0"));
                if (!(sb.ToString().Equals(@"OK")))
                {
                    log.Error("Attempt at RESPONSE SPACES OFF [AT S0] failed. Value returned: " + sb.ToString());
                    return false;
                }
                sb.Clear();

                // Turn linefeeds off
                //sb.Append(this.ExecuteATCommand(@"L0"));
                //if (!(sb.ToString().Equals(@"OK")))
                //{
                //    log.Error("Attempt at LINEFEEDS OFF [AT L0] failed. Value returned: " + sb.ToString());
                //    return false;
                //}
                //sb.Clear();

                // Echo Off
                sb.Append(ExecuteATCommand(@"E0"));
                if (!(sb.ToString().Equals(@"OK")))
                {
                    log.Error("Attempt at ECHO OFF [AT E0] failed. Value returned: " + sb.ToString());
                    return false;
                }
                sb.Clear();

                // Get Device Description
                sb.Append(ExecuteATCommand(@" @1"));
                if (!(sb.ToString().Equals(_connectionSettings.DeviceDescription)))
                {
                    log.Error("Attempt at DEVICE DESCRIPTION [AT @1] failed. Value returned: " + sb.ToString());
                    return false;
                }
                sb.Clear();

                // Get Version
                sb.Append(ExecuteATCommand(@"I"));
                if (sb.Length < 11)
                {
                    log.Error("Attempt at IDENTIFY YOURSELF [AT I] failed. Value returned: " + sb.ToString());
                    return false;
                }
                sb.Clear();

                // Set Headers on
                sb.Append(ExecuteATCommand(@"H1"));
                if (!(sb.ToString().Equals(@"OK")))
                {
                    log.Error("Attempt at HEADERS ON [AT H1] failed. Value returned: " + sb.ToString());
                    return false;
                }
                sb.Clear();

                /*
                // Set Data Length bytes on
                sb.Append(this.ExecuteATCommand(@"D1"));
                if (!(sb.ToString().Equals(@"OK")))
                {
                    log.Error("Attempt at DATA LENGTH BYTES ON [AT D1] failed. Value returned: " + sb.ToString());
                    return false;
                }
                sb.Clear();
                */

                // Determine the protocol used by the vehicle
                sb.Append(ExecuteATCommand(@"DPN"));
                if (sb.Length < 1 || sb.Length > 2)
                {
                    log.Error("Attempt at DETERMINE PROTOCOL NUMBER [AT DPN] failed. Value returned: " + sb.ToString());
                    return false;
                }
                else
                {
                    // If the device is in auto mode, it prefixes the protocol number with an 'A'
                    if (sb[0] == 'A')
                    {
                        protocolNumber = 1;
                    }
                    
                    // Is the character in the range 0 - 9 or A - C
                    if ((sb[protocolNumber] > 47 && sb[protocolNumber] < 58) || (sb[protocolNumber] > 64 && sb[protocolNumber] < 68))
                    {
                        _vehicleProtocol = (ProtocolsEnum)Convert.ToInt32(sb[protocolNumber].ToString(), 16);
                    }
                    else
                    {
                        log.Error("Attempt at DETERMINE PROTOCOL NUMBER [AT DPN] failed. Value returned: " + sb.ToString());
                        return false;
                    }
                }
                sb.Clear();

                // We're done!
                return true;
            }

            // Connection is either null or not open
            return false;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Prepares the ELM327 device for operation by setting various parameters to control formatting of requests/responses and optimize
        /// communications between the device and this application.
        /// </summary>
        private bool PrepareELM327()
        {
            // Variables
            StringBuilder sb             = new StringBuilder(10);
            short         protocolNumber = 0;

            // Ensure the connection is valid
            if (_connection != null && _connection.IsOpen)
            {
                // Prepare the port
                _connection.BaudRate     = _connectionSettings.BaudRate;
                _connection.DataBits     = _connectionSettings.DataBits;
                _connection.Parity       = _connectionSettings.Parity;
                _connection.StopBits     = _connectionSettings.StopBits;
                _connection.NewLine      = "\r";
                _connection.ReadTimeout  = 100;
                _connection.WriteTimeout = 50;

                /*
                 * Customize settings for speed and function
                 */
                // Turn response spaces off
                sb.Append(ExecuteATCommand(@"S0"));
                if (!(sb.ToString().Equals(@"OK")))
                {
                    log.Error("Attempt at RESPONSE SPACES OFF [AT S0] failed. Value returned: " + sb.ToString());
                    return(false);
                }
                sb.Clear();

                // Turn linefeeds off
                //sb.Append(this.ExecuteATCommand(@"L0"));
                //if (!(sb.ToString().Equals(@"OK")))
                //{
                //    log.Error("Attempt at LINEFEEDS OFF [AT L0] failed. Value returned: " + sb.ToString());
                //    return false;
                //}
                //sb.Clear();

                // Echo Off
                sb.Append(ExecuteATCommand(@"E0"));
                if (!(sb.ToString().Equals(@"OK")))
                {
                    log.Error("Attempt at ECHO OFF [AT E0] failed. Value returned: " + sb.ToString());
                    return(false);
                }
                sb.Clear();

                // Get Device Description
                sb.Append(ExecuteATCommand(@" @1"));
                if (!(sb.ToString().Equals(_connectionSettings.DeviceDescription)))
                {
                    log.Error("Attempt at DEVICE DESCRIPTION [AT @1] failed. Value returned: " + sb.ToString());
                    return(false);
                }
                sb.Clear();

                // Get Version
                sb.Append(ExecuteATCommand(@"I"));
                if (sb.Length < 11)
                {
                    log.Error("Attempt at IDENTIFY YOURSELF [AT I] failed. Value returned: " + sb.ToString());
                    return(false);
                }
                sb.Clear();

                // Set Headers on
                sb.Append(ExecuteATCommand(@"H1"));
                if (!(sb.ToString().Equals(@"OK")))
                {
                    log.Error("Attempt at HEADERS ON [AT H1] failed. Value returned: " + sb.ToString());
                    return(false);
                }
                sb.Clear();

                /*
                 * // Set Data Length bytes on
                 * sb.Append(this.ExecuteATCommand(@"D1"));
                 * if (!(sb.ToString().Equals(@"OK")))
                 * {
                 *  log.Error("Attempt at DATA LENGTH BYTES ON [AT D1] failed. Value returned: " + sb.ToString());
                 *  return false;
                 * }
                 * sb.Clear();
                 */

                // Determine the protocol used by the vehicle
                sb.Append(ExecuteATCommand(@"DPN"));
                if (sb.Length < 1 || sb.Length > 2)
                {
                    log.Error("Attempt at DETERMINE PROTOCOL NUMBER [AT DPN] failed. Value returned: " + sb.ToString());
                    return(false);
                }
                else
                {
                    // If the device is in auto mode, it prefixes the protocol number with an 'A'
                    if (sb[0] == 'A')
                    {
                        protocolNumber = 1;
                    }

                    // Is the character in the range 0 - 9 or A - C
                    if ((sb[protocolNumber] > 47 && sb[protocolNumber] < 58) || (sb[protocolNumber] > 64 && sb[protocolNumber] < 68))
                    {
                        _vehicleProtocol = (ProtocolsEnum)Convert.ToInt32(sb[protocolNumber].ToString(), 16);
                    }
                    else
                    {
                        log.Error("Attempt at DETERMINE PROTOCOL NUMBER [AT DPN] failed. Value returned: " + sb.ToString());
                        return(false);
                    }
                }
                sb.Clear();

                // We're done!
                return(true);
            }

            // Connection is either null or not open
            return(false);
        }