Beispiel #1
0
        public static int Comparison(PTFirmwareInfo x, PTFirmwareInfo y)
        {
            if (x == null && y == null)
            {
                return(0);
            }
            if (x == null && y != null)
            {
                return(-1);
            }
            if (x != null && y == null)
            {
                return(1);
            }

            int retModel = x.ModelVersion.CompareTo(y.ModelVersion);

            if (retModel != 0)
            {
                return(retModel);
            }

            int retCode = x.CodeVersion.CompareTo(y.CodeVersion);

            if (retCode != 0)
            {
                return(retCode);
            }

            int retRev = x.Revision.CompareTo(y.Revision);

            return(retRev);
        }
Beispiel #2
0
        /// <summary>Tests the specified serial port to see if there is a PTU controller attached. This method is blocking, but throws if the unit is unresponsive (2000ms timeout).</summary>
        public static PTFirmwareInfo GetFirmwareInfo(String portName)
        {
            PTFirmwareInfo ret;

            using (PTConnection c = new PTConnection(portName)) {
                try {
                    c.ResetParser();

                    c.SetTimeout(500);
                    String firmware = c.GetLine(PTCommand.GetFirmwareVersion);
                    ret = PTFirmwareInfo.FromString(firmware);
                    c.SetTimeout(_defaultTimeout);
                } catch (TimeoutException) {
                    return(null);
                }
            }

            return(ret);
        }