Example #1
0
        public static string ReadAdapterProtocolVersion(BaseDevice device)
        {
            string version = string.Empty;

            if (device.TwiKfdtoolDevice.ComPort == string.Empty)
            {
                throw new ArgumentException("No device selected");
            }

            AdapterProtocol ap = null;

            try
            {
                ap = new AdapterProtocol(device.TwiKfdtoolDevice.ComPort);

                ap.Open();

                ap.Clear();

                byte[] ver = ap.ReadAdapterProtocolVersion();

                version = string.Format("{0}.{1}.{2}", ver[0], ver[1], ver[2]);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                try
                {
                    if (ap != null)
                    {
                        ap.Close();
                    }
                }
                catch (System.IO.IOException ex)
                {
                    Logger.Warn("could not close serial port: {0}", ex.Message);
                }
            }

            return(version);
        }