예제 #1
0
        public static bool SetSecondaryInput(string s)
        {
            if (s.ToUpper().StartsWith("COM") && s.Length > 3)
            {
                int  port  = 0;
                bool valid = int.TryParse(s.Substring(3, s.Length - 3), out port);

                if (!valid)
                {
                    return(false);
                }

                if (secondary_com_port != null)
                {
                    if (secondary_com_port.IsOpen)
                    {
                        secondary_com_port.Close();
                    }
                    secondary_com_port = null;
                }

                secondary_com_port = new SDRSerialPort(port);

                try
                {
                    secondary_com_port.Open();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }

                if (!secondary_com_port.IsOpen)
                {
                    secondary_com_port = null;
                    return(false);
                }

                secondary_com_port.UseForKeyPTT = true;
                SecondaryKeyLine = secondary_key_line;
                SecondaryPTTLine = secondary_ptt_line;
                secondary_input  = s;
                return(true);
            }

            switch (s)
            {
            case "Radio":
            case "CAT":
            case "None":
                if (secondary_com_port != null)
                {
                    if (secondary_com_port.IsOpen)
                    {
                        secondary_com_port.Close();
                    }
                    secondary_com_port = null;
                }
                primary_input = s;
                break;
            }
            return(true);
        }
예제 #2
0
        public static bool SetPrimaryInput(string s)
        {
            if (s.ToUpper().StartsWith("COM") && s.Length > 3)
            {
                int  port  = 0;
                bool valid = int.TryParse(s.Substring(3, s.Length - 3), out port);

                if (!valid)
                {
                    return(false);
                }

                if (primary_com_port != null)
                {
                    if (primary_com_port.IsOpen)
                    {
                        primary_com_port.Close();
                    }
                    primary_com_port = null;
                }

                primary_com_port = new SDRSerialPort(port);
                try
                {
                    primary_com_port.Open();
                }
                catch (Exception)
                {
                    primary_com_port = null;
                    return(false);
                }

                if (!primary_com_port.IsOpen)
                {
                    primary_com_port = null;
                    return(false);
                }

                primary_com_port.UseForPaddles = true;
                primary_input = s;
                return(true);
            }

            switch (s)
            {
            case "Radio":
            case "CAT":
            case "None":
                if (primary_com_port != null)
                {
                    if (primary_com_port.IsOpen)
                    {
                        primary_com_port.Close();
                    }
                    primary_com_port = null;
                }
                primary_input = s;
                break;
            }
            return(true);
        }