public void enableROTOR() 
		{
            if (console.ROTORPort == 0) return;

            
			lock ( this ) 
			{
				if ( rotor_enabled ) return; // nothing to do already enabled 
				rotor_enabled = true; 
			}

          
            int port_num = console.ROTORPort;

            Debug.WriteLine("==============ROTOR PORT OPEN: " +port_num);

            SIO = new SDRSerialPort(port_num);
		/*	SIO.setCommParms(console.CATBaudRate, 
							console.CATParity, 
							console.CATDataBits, 
							console.CATStopBits,
                            console.CATHandshake);
                            */

            SIO.setCommParms(9600,                            // ant rotor port is always 9600
                                console.CATParity,
                                console.CATDataBits,
                                console.CATStopBits,
                                console.CATHandshake);

            Initialize();	
		}
 public void Destroy()
 {
     lock (this)                // we only get in here once
     {
         if (!Initialized)
         {
             return;
         }
         Initialized = false;
     }
     if (commPort != null)
     {
         commPort.Destroy();
         commPort = null;
     }
 }
Exemple #3
0
		public void enableCAT() 
		{
			lock ( this ) 
			{
				if ( cat_enabled ) return; // nothing to do already enabled 
				cat_enabled = true; 
			}
			int port_num = console.CATPort; 
			SIO = new SDRSerialPort(port_num);
			SIO.setCommParms(console.CATBaudRate, 
							console.CATParity, 
							console.CATDataBits, 
							console.CATStopBits,
                            console.CATHandshake); 
		
			Initialize();	
		}
 public void Init()
 {
     lock (this)                // do this only once -- keep the lock until we're ready to go less we hose up the poll ptt thread
     {
         if (Initialized)
         {
             return;
         }
         if (portNum == 0)
         {
             return;                                 // bail out
         }
         commPort = new SDRSerialPort(portNum);
         commPort.Create(true);                 // true says to create bit bang only port  -- fixme needs error checking!
         Initialized = true;
     }
     return;
 }
//		private void SIOMonitor_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
//		{
//			if(!console.MOX)
//			{
//				SIOMonitorCount++;			// increments the counter when in receive
//				Debug.WriteLine("SIOMonitorCount: "+SIOMonitorCount.ToString());
//				if(SIOMonitorCount < 12)	// if the counter is less than 12 (60 seconds),reinitialize the serial port
//				{
//					Debug.WriteLine("The SIO Timer has elapsed");
//					if(!SIO.PortIsOpen)
//					{
//						Debug.WriteLine("The port is closed");
//						SIO.OpenPort = true;
//						StreamWriter sw = new StreamWriter("SIOTestLog.txt", true);
//						sw.WriteLine("The serial port was forced open");
//						sw.WriteLine("Time: "+DateTime.Now.ToString());
//						sw.Flush();
//						sw.Close();
//						SIOMonitor.Enabled = true;
//						SIOMonitorCount = 0;
//						Fpass = true;
//						disableCAT();
//						enableCAT();
//					}
//					//Initialize();
//				}
//				else						// consider the remote program on the serial port as being shut down
//				{
//					if(SIO.PortIsOpen)
//					{
//						port_status = "open";
//					}
//					else
//					{
//
//						port_status = "closed";
//					}
//
//
//					SIOMonitorCount = 0;
//					disableCAT();
//					enableCAT();
//	//				SIOMonitor.Stop();
//				}
//			}
//			else
//				SIOMonitorCount = 0;
//		}

        public void enableCAT()
        {
            lock (this)
            {
                if (cat_enabled)
                {
                    return;                                // nothing to do already enabled
                }
                cat_enabled = true;
            }
            int port_num = console.CATPort;

            SIO = new SDRSerialPort(port_num);
            SIO.setCommParms(console.CATBaudRate,
                             console.CATParity,
                             console.CATDataBits,
                             console.CATStopBits);

            Initialize();
        }
//		private void SIOMonitor_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
//		{
//			if(!console.MOX)
//			{
//				SIOMonitorCount++;			// increments the counter when in receive
//				Debug.WriteLine("SIOMonitorCount: "+SIOMonitorCount.ToString());
//				if(SIOMonitorCount < 12)	// if the counter is less than 12 (60 seconds),reinitialize the serial port
//				{
//					Debug.WriteLine("The SIO Timer has elapsed");
//					if(!SIO.PortIsOpen)
//					{
//						Debug.WriteLine("The port is closed");
//						SIO.OpenPort = true;
//						StreamWriter sw = new StreamWriter("SIOTestLog.txt", true);
//						sw.WriteLine("The serial port was forced open");
//						sw.WriteLine("Time: "+DateTime.Now.ToString());
//						sw.Flush();
//						sw.Close();
//						SIOMonitor.Enabled = true;
//						SIOMonitorCount = 0;
//						Fpass = true;
//						disableCAT();
//						enableCAT();
//					}
//					//Initialize();
//				}
//				else						// consider the remote program on the serial port as being shut down
//				{
//					if(SIO.PortIsOpen)
//					{
//						port_status = "open";
//					}
//					else
//					{
//
//						port_status = "closed";
//					}
//
//
//					SIOMonitorCount = 0;
//					disableCAT();
//					enableCAT();
//	//				SIOMonitor.Stop();
//				}
//			}
//			else
//				SIOMonitorCount = 0;
//		}

        public void enableCAT()
        {
            lock (this)
            {
                if (cat_enabled)
                {
                    return;                                // nothing to do already enabled
                }
                cat_enabled = true;
            }
            Debug.WriteLine("==============CAT PORT OPEN");

            int port_num = console.CATPort;

            SIO = new SDRSerialPort(port_num);
            SIO.setCommParms(console.CATBaudRate,
                             console.CATParity,
                             console.CATDataBits,
                             console.CATStopBits,
                             console.CATHandshake);

            Initialize();
        }
Exemple #7
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);
        }
Exemple #8
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);
        }
Exemple #9
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;
        }
Exemple #10
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;
        }