public void Destroy() { lock (this) // we only get in here once { if (!Initialized) { return; } Initialized = false; } if (commPort != null) { commPort.Destroy(); commPort = null; } }
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); //, null); commPort.Create(true); // true says to create bit bang only port -- fixme needs error checking! Initialized = true; } return; }
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(); }
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);//, null); 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); }
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);//, null); 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); }