Example #1
0
        private int[] intProposedCompressedSize = new int[5]; // An array to hold the compressed size of message for each proposal.

        public ProtocolB2(ProtocolInitial Parent, ref TChannelProperties stcNewChannel, ref ArrayList aryMessages)
        {
            //
            // Initialize the keepalive timer used during long file downloads to keep the remote TCP link from timing out
            //
            // tmrKeepAlive = New Timer
            // AddHandler tmrKeepAlive.Elapsed, AddressOf OnKeepAliveTimer
            // tmrKeepAlive.AutoReset = False
            // tmrKeepAlive.Interval = 120000   ' 2 minutes

            // Instantiates a B2 channel protocol handler...

            stcChannel         = stcNewChannel;
            objInitialProtocol = Parent;
            StateChange(EB2States.WaitingForNewCommand);
            Globals.blnFQSeen = false;
            if (!string.IsNullOrEmpty(stcChannel.RemoteCallsign))
            {
                var strTokens = stcChannel.RemoteCallsign.Split('-');
                strBaseConnectedCall = strTokens[0];
            }

            aryOutboundMessages = aryMessages;
            B2OutboundProposal();
        } // New
Example #2
0
        } // Abort

        public ModemTelnet(ref TChannelProperties strNewChannel)
        {
            stcChannel = strNewChannel;
            Globals.blnChannelActive = true;
            enmState = LinkStates.Initialized;
            Globals.queRateDisplay.Enqueue("Internet");
        } // New
Example #3
0
        public bool InitializeSerialPort(ref TChannelProperties stcChannel)
        {
            // Opens the serial port used to control the radio. Returns true if port opens...

            if (stcChannel.RDOControl == "Via PTCII")
            {
                blnViaPTC = true;
                if (stcChannel.TNCType == "PTC II")
                {
                    Globals.ObjScsModem.SendRadioCommand("#TRX TY K " + stcChannel.RDOControlBaud + " A");
                }
                else if (stcChannel.TTLLevel)
                {
                    Globals.ObjScsModem.SendRadioCommand("#TRX TY K " + stcChannel.RDOControlBaud + " A TTL");
                }
                else
                {
                    Globals.ObjScsModem.SendRadioCommand("#TRX TY K " + stcChannel.RDOControlBaud + " A V24");
                }

                Thread.Sleep(200);
                return(true);
            }

            try
            {
                if (objSerial is object)
                {
                    if (objSerial.IsOpen)
                    {
                        objSerial.DiscardInBuffer();
                        objSerial.DiscardOutBuffer();
                        objSerial.Close(); // Close the serial port if already open
                        Thread.Sleep(Globals.intComCloseTime);
                    }

                    objSerial.WriteTimeout           = 1000;
                    objSerial.ReceivedBytesThreshold = 1;         // Minimum of 1 bytes for interrupt
                    objSerial.BaudRate  = Convert.ToInt32(stcChannel.RDOControlBaud);
                    objSerial.DataBits  = 8;
                    objSerial.Parity    = Parity.None;
                    objSerial.StopBits  = StopBits.Two; // two stop bits for TS-440, 450, 690
                    objSerial.PortName  = stcChannel.RDOControlPort;
                    objSerial.Handshake = Handshake.None;
                    objSerial.RtsEnable = true;
                    objSerial.DtrEnable = true;
                    objSerial.NewLine   = ";";
                    objSerial.Open();
                    objSerial.DiscardInBuffer();
                    objSerial.DiscardOutBuffer();
                    return(objSerial.IsOpen);
                }
            }
            catch (Exception ex)
            {
                _log.Error("[RadioKenwood.InitializeSerialPort] " + ex.Message);
                return(false);
            }

            return(default);
        } // tmrPollClient_Tick

        public void UpdateChannelProperties(ref TChannelProperties Channel)
        {
            Channel.RemoteCallsign     = cmbCallSigns.Text.Trim().ToUpper();
            Channel.RDOCenterFrequency = cmbFrequencies.Text.Trim();
            // Channels.UpdateChannel(Channel)
            Globals.stcEditedSelectedChannel = Channel;
            blnChangesNotSaved = false;
        } // UpdateProperties
        private string strChallengePhrase = "";    // Challenge phrase as received by ;PQ: command

        public ProtocolInitial(IModem Parent, ref TChannelProperties strNewChannel)
        {
            ObjModem   = Parent;
            stcChannel = strNewChannel;
            Globals.strConnectedCallsign   = strNewChannel.RemoteCallsign; // Set the global callsign for use by Radar
            Globals.strConnectedGridSquare = "";                           // and clear the connected Grid square
            strSID = "[Paclink-" + Application.ProductVersion + "-" + SSIDTag() + "B2FIHM$]";
            ProtocolStateChange(EProtocolStates.Connected);
        } // New
Example #6
0
        public bool InitializeSerialPort(ref TChannelProperties Channel)
        {
            // Opens the serial port used to control the radio. Returns true if port opens...

            if (Channel.RDOControl == "Via PTCII")
            {
                blnViaPTC = true;
                if (Channel.TNCType == "PTC II")
                {
                    Globals.ObjScsModem.SendRadioCommand("#TRX TY Y " + Channel.RDOControlBaud + " A");
                }
                else if (Channel.TTLLevel)
                {
                    Globals.ObjScsModem.SendRadioCommand("#TRX TY Y " + Channel.RDOControlBaud + " A TTL");
                }
                else
                {
                    Globals.ObjScsModem.SendRadioCommand("#TRX TY Y " + Channel.RDOControlBaud + " A V24");
                }

                Thread.Sleep(100);
                return(true);
            }

            try
            {
                if (objSerial.IsOpen)
                {
                    objSerial.DiscardInBuffer();
                    objSerial.DiscardOutBuffer();
                    objSerial.Close();
                    Thread.Sleep(Globals.intComCloseTime);
                }

                objSerial.WriteTimeout           = 1000;
                objSerial.ReceivedBytesThreshold = 1;
                objSerial.BaudRate  = Convert.ToInt32(Channel.RDOControlBaud);
                objSerial.DataBits  = 8;
                objSerial.Parity    = Parity.None;
                objSerial.StopBits  = StopBits.Two;
                objSerial.PortName  = Channel.RDOControlPort;
                objSerial.Handshake = Handshake.None;
                objSerial.RtsEnable = true;
                objSerial.DtrEnable = true;
                objSerial.NewLine   = ";";
                objSerial.Open();
                objSerial.DiscardInBuffer();
                objSerial.DiscardOutBuffer();
                OpenRadio(Channel.RDOModel);
                return(objSerial.IsOpen);
            }
            catch (Exception e)
            {
                _log.Error("[RadioYaesu.InitializeSerialPort] " + e.Message);
                return(false);
            }
        } // InitializeSerialPort
Example #7
0
        } // RemoveChannel

        public static void UpdateChannel(ref TChannelProperties stcChannel)
        {
            //
            // Updates the properties for the channel represented in stcChannel.
            //
            string strName = stcChannel.ChannelName;

            if (IsChannel(strName))
            {
                UpdateProperties(ref stcChannel);
            }
        } // UpdateChannel
        } // ClearEntries

        private void SetEntries()
        {
            stcSelectedChannel = (TChannelProperties)Channels.Entries[cmbChannelName.Text];
            {
                var withBlock = stcSelectedChannel;
                nudPriority.Value = withBlock.Priority;
                chkEnabled.Checked = withBlock.Enabled;
            }

            btnAdd.Enabled = false;
            btnRemove.Enabled = true;
            btnUpdate.Enabled = true;
        } // SetEntries
        } // SetEntries

        private void btnAdd_Click(object sender, EventArgs e)
        {
            cmbChannelName.Text = cmbChannelName.Text.Trim();
            cmbChannelName.Text = cmbChannelName.Text.Replace("|", "");
            if (!Globals.IsValidFileName(cmbChannelName.Text))
            {
                cmbChannelName.Focus();
                return;
            }

            if (string.IsNullOrEmpty(cmbChannelName.Text))
            {
                MessageBox.Show("A channel name is required...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cmbChannelName.Focus();
                return;
            }

            if (Channels.IsAccount(cmbChannelName.Text))
            {
                MessageBox.Show(cmbChannelName.Text + " is in use as an account name...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cmbChannelName.Focus();
                return;
            }

            if (Channels.IsChannel(cmbChannelName.Text))
            {
                MessageBox.Show("The channel name " + cmbChannelName.Text + " is already in use...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cmbChannelName.Focus();
            }
            else
            {
                var stcNewChannel = new TChannelProperties()
                {
                    ChannelType = ChannelMode.Telnet,
                    ChannelName = cmbChannelName.Text,
                    Priority = Convert.ToInt32(nudPriority.Value),
                    Enabled = chkEnabled.Checked,
                    EnableAutoforward = true, // Telnet Channels always enabled
                    RemoteCallsign = "WL2K"
                };

                Channels.AddChannel(ref stcNewChannel);
                Channels.FillChannelCollection();
                FillChannelList();
                ClearEntries();
                Globals.Settings.Save("Properties", "Last Telnet Channel", cmbChannelName.Text);
                Close();
            }
        } // btnAdd_Click
Example #10
0
        public bool InitializeSerialPort(ref TChannelProperties Channel)
        {
            // Opens the serial port used to control the radio. Returns true if port opens...

            strCIVAddress = Channel.CIVAddress;
            bytCIVAddress = byte.Parse(strCIVAddress, System.Globalization.NumberStyles.HexNumber);
            if (Channel.RDOControl == "Via PTCII")
            {
                blnViaPTC = true;
                Globals.ObjScsModem.SendRadioCommand("#TRX TY I " + Channel.RDOControlBaud + " $" + Channel.CIVAddress);
                Thread.Sleep(200);  // Changed to 200 by W4PHS
                return(true);
            }

            try
            {
                if (objSerial.IsOpen)
                {
                    objSerial.DiscardInBuffer();
                    objSerial.DiscardOutBuffer();
                    objSerial.Close(); // Close the serial port if it is already open
                    Thread.Sleep(Globals.intComCloseTime);
                }

                objSerial.WriteTimeout           = 1000;
                objSerial.ReceivedBytesThreshold = 1;
                objSerial.BaudRate  = Convert.ToInt32(Channel.RDOControlBaud);
                objSerial.DataBits  = 8;
                objSerial.Parity    = Parity.None;
                objSerial.StopBits  = StopBits.One;
                objSerial.PortName  = Channel.RDOControlPort;
                objSerial.Handshake = Handshake.None;
                objSerial.RtsEnable = true;
                objSerial.DtrEnable = true;
                objSerial.Open();
                objSerial.DiscardInBuffer();
                objSerial.DiscardOutBuffer();
                return(objSerial.IsOpen);
            }
            catch (Exception ex)
            {
                _log.Error("[RadioIcom.InitializeSerialPort] " + ex.Message);
                return(false);
            }
        }   // InitializeSerialPort
Example #11
0
        }   // InitializeSerialPort

        public bool SetParameters(ref TChannelProperties Channel)
        {
            bool SetParametersRet = default;

            // Function to set parameters for frequency and filters, possibly other parameters later...
            strRadioModel    = Channel.RDOModel;
            SetParametersRet = true;
            if (Channel.ChannelType == ChannelMode.PacketTNC)
            {
                SetParametersRet = SetVHFFrequency(Globals.ExtractFreq(ref Channel.RDOCenterFrequency), Channel.CIVAddress, Channel.RDOModel);
            }
            else
            {
                SetHFFrequency(Globals.ExtractFreq(ref Channel.RDOCenterFrequency), Channel.AudioToneCenter, Channel.CIVAddress, Channel.RDOModel, Channel.NarrowFilter);
            }

            return(SetParametersRet);
        } // SetParameters
Example #12
0
        } // FillChannelCollection

        public static void AddChannel(ref TChannelProperties stcChannel)
        {
            //
            // Adds the channel properties of a new channel to the registry.
            //
            string strName = stcChannel.ChannelName;

            if (!string.IsNullOrEmpty(strName))
            {
                if (!IsChannel(strName))
                {
                    string strChannelNames = Globals.Settings.Get("Properties", "Channel Names", "");
                    strChannelNames = strChannelNames + strName + "|";
                    Globals.Settings.Save("Properties", "Channel Names", strChannelNames);
                }

                UpdateProperties(ref stcChannel);
            }
        } // SaveChannel
Example #13
0
        } // SetEntries

        private void UpdateChannelProperties(ref TChannelProperties stcChannel)
        {
            stcChannel.ChannelType = ChannelMode.PacketTNC;
            stcChannel.ChannelName = cmbChannelName.Text;
            stcChannel.Priority = Convert.ToInt32(nudPriority.Value);
            stcChannel.RemoteCallsign = CleanupCallSign(cmbRemoteCallsign.Text);
            stcChannel.RDOCenterFrequency = cmbFreqs.Text;
            stcChannel.Enabled = chkEnabled.Checked;
            stcChannel.TNCTimeout = Convert.ToInt32(nudActivityTimeout.Value);
            stcChannel.TNCScript = txtScript.Text;
            stcChannel.TNCScriptTimeout = Convert.ToInt32(nudScriptTimeout.Value);
            stcChannel.TNCSerialPort = cmbTNCSerialPort.Text;
            stcChannel.TNCBaudRate = cmbTNCBaudRate.Text;
            stcChannel.TNCConfigurationFile = txtTNCConfigurationFile.Text;
            stcChannel.TNCConfigureOnFirstUseOnly = chkFirstUseOnly.Checked;
            stcChannel.TNCPort = Convert.ToInt32(nudTNCPort.Value);
            stcChannel.TNCType = cmbTNCType.Text;
            stcChannel.TNCOnAirBaud = Convert.ToInt32(cmbOnAirBaud.Text);
            stcChannel.EnableAutoforward = true; // Packet Channels always enabled
            if (!rdoManual.Checked)
            {
                stcChannel.RDOCenterFrequency = (1000 * double.Parse(txtFreqMHz.Text, System.Globalization.NumberStyles.AllowDecimalPoint)).ToString("##00000.0");
            }

            stcChannel.RDOControlBaud = cmbRadioBaud.Text;
            stcChannel.RDOControlPort = cmbRadioPort.Text;
            stcChannel.RDOModel = cmbRadioModel.Text;
            stcChannel.CIVAddress = txtRadioAdd.Text.Trim().ToUpper();
            if (rdoViaPTCII.Checked)
            {
                stcChannel.RDOControl = "Via PTCII";
            }
            else if (rdoSerial.Checked)
            {
                stcChannel.RDOControl = "Serial";
            }
            else
            {
                stcChannel.RDOControl = "Manual";
            }

            stcChannel.TTLLevel = rdoTTL.Checked;
        } // UpdateProperties
 public DialogPactorConnect(IModem objSender, ref TChannelProperties Channel)
 {
     // This call is required by the Windows Form Designer...
     _objModem  = objSender;
     stcChannel = Channel;
     blnLoading = true;
     InitializeComponent();
     _cmbCallSigns.Name    = "cmbCallSigns";
     _cmbFrequencies.Name  = "cmbFrequencies";
     _Label1.Name          = "Label1";
     _Label2.Name          = "Label2";
     _lblUSB.Name          = "lblUSB";
     _lblBusy.Name         = "lblBusy";
     _Label4.Name          = "Label4";
     _btnConnect.Name      = "btnConnect";
     _btnCancel.Name       = "btnCancel";
     _btnHelp.Name         = "btnHelp";
     _lblPMBOType.Name     = "lblPMBOType";
     _chkResumeDialog.Name = "chkResumeDialog";
 } // New
Example #15
0
        } // ClearEntries

        private void SetEntries()
        {
            stcSelectedChannel = (TChannelProperties)Channels.Entries[cmbChannelName.Text];
            {
                var withBlock = stcSelectedChannel;
                nudPriority.Value = withBlock.Priority;
                cmbAGWPort.Text = withBlock.AGWPort;
                txtRemoteCallsign.Text = withBlock.RemoteCallsign;
                nudActivityTimeout.Value = withBlock.AGWTimeout;
                nudPacketLength.Value = withBlock.AGWPacketLength;
                nudMaxOutstanding.Value = Math.Max(1, withBlock.AGWMaxFrames); // temp fix to fix channels with old values of 0
                nudScriptTimeout.Value = withBlock.AGWScriptTimeout;
                txtScript.Text = withBlock.AGWScript;
                chkEnabled.Checked = withBlock.Enabled;
            }

            btnAdd.Enabled = false;
            btnRemove.Enabled = true;
            btnUpdate.Enabled = true;
        } // SetEntries
Example #16
0
        public bool SetParameters(ref TChannelProperties stcTNC)
        {
            bool SetParametersRet = default;

            // Function to set parameters for frequency and filters, possibly other parameters later...
            SetParametersRet = true;
            try
            {
                string strKilohertz = Globals.StripMode(stcTNC.RDOCenterFrequency); // Strip off any mode designator
                int    intHertz     = Globals.KHzToHz(strKilohertz) - Convert.ToInt32(stcTNC.AudioToneCenter);
                if (!SetFrequency(intHertz))
                {
                    SetParametersRet = false;
                }
            }
            catch
            {
                SetParametersRet = false;
            }

            return(SetParametersRet);
        } // SetParameters
Example #17
0
        public bool SetParameters(ref TChannelProperties Channel)
        {
            // Function to set parameters for frequency and filters, possibly other parameters later...
            try
            {
                if (Channel.ChannelType == ChannelMode.PacketTNC)
                {
                    SetVHFFrequency(Globals.ExtractFreq(ref Channel.RDOCenterFrequency), Channel.RDOModel);
                }
                else
                {
                    SetHFFrequency(Globals.ExtractFreq(ref Channel.RDOCenterFrequency), Channel.AudioToneCenter, Channel.RDOModel);
                    SetFilter(Channel.NarrowFilter, Globals.ExtractFreq(ref Channel.RDOCenterFrequency), Channel.RDOModel, Channel.AudioToneCenter);
                }

                return(true);
            }
            catch (Exception e)
            {
                _log.Error("[RadioYaesu.SetParameters] " + e.Message);
                return(false);
            }
        } // SetParameters
Example #18
0
        } // UpdateChannel

        private static void UpdateProperties(ref TChannelProperties stcChannel)
        {
            //
            // Updates the registry as required for the properties carried in strChannel.
            //
            string strName = stcChannel.ChannelName;

            Globals.Settings.Save(strName, "Channel Type", stcChannel.ChannelType.ToString());
            Globals.Settings.Save(strName, "Channel Name", stcChannel.ChannelName);
            Globals.Settings.Save(strName, "Priority", stcChannel.Priority);
            Globals.Settings.Save(strName, "Remote Callsign", stcChannel.RemoteCallsign);
            // objPropertiesFile.WriteInteger(strName, "Frequencies Scanned", .FrequenciesScanned)
            Globals.Settings.Save(strName, "Enabled", stcChannel.Enabled);
            if (stcChannel.ChannelType == ChannelMode.Telnet)
            {
                // Telnet only properties...
                Globals.Settings.Save(strName, "Enable Autoforward", stcChannel.EnableAutoforward);
            }
            // objPropertiesFile.WriteString(strName, "LocalIP Address Index", .LocalIPAddressIndex.ToString)
            else if (stcChannel.ChannelType == ChannelMode.PacketAGW)
            {
                // Packet AGW only properties...
                Globals.Settings.Save(strName, "AGW Port", stcChannel.AGWPort);
                Globals.Settings.Save(strName, "AGW Timeout", stcChannel.AGWTimeout);
                Globals.Settings.Save(strName, "AGW Packet Length", stcChannel.AGWPacketLength);
                Globals.Settings.Save(strName, "AGW Max Frames", stcChannel.AGWMaxFrames);
                Globals.Settings.Save(strName, "AGW Script Timeout", stcChannel.AGWScriptTimeout);
                Globals.Settings.Save(strName, "AGW Allow Inbound", stcChannel.AGWAllowInbound);
                Globals.Settings.Save(strName, "Enable Autoforward", stcChannel.EnableAutoforward);
                SaveScript(strName, stcChannel.AGWScript);
            }
            else if (stcChannel.ChannelType == ChannelMode.PacketTNC)
            {
                // Packet TNC only properties...
                Globals.Settings.Save(strName, "TNC Type", stcChannel.TNCType);
                Globals.Settings.Save(strName, "TNC Port", stcChannel.TNCPort);
                Globals.Settings.Save(strName, "TNC Timeout", stcChannel.TNCTimeout);
                Globals.Settings.Save(strName, "TNC Serial Port", stcChannel.TNCSerialPort);
                Globals.Settings.Save(strName, "TNC Baud Rate", stcChannel.TNCBaudRate);
                Globals.Settings.Save(strName, "TNC Configuration File", stcChannel.TNCConfigurationFile);
                Globals.Settings.Save(strName, "TNC Configuration On First Use Only", stcChannel.TNCConfigureOnFirstUseOnly);
                Globals.Settings.Save(strName, "TNC Script Timeout", stcChannel.TNCScriptTimeout);
                // objPropertiesFile.WriteBoolean(strName, "TNC Allow Inbound", .TNCAllowInbound)
                Globals.Settings.Save(strName, "Enable Autoforward", stcChannel.EnableAutoforward);
                Globals.Settings.Save(strName, "Radio Control", stcChannel.RDOControl);
                Globals.Settings.Save(strName, "Radio Control Port", stcChannel.RDOControlPort);
                Globals.Settings.Save(strName, "Radio Control Baud", stcChannel.RDOControlBaud);
                Globals.Settings.Save(strName, "Radio Model", stcChannel.RDOModel);
                Globals.Settings.Save(strName, "Center Frequency", stcChannel.RDOCenterFrequency);
                Globals.Settings.Save(strName, "Audio Tone Center", stcChannel.AudioToneCenter);
                Globals.Settings.Save(strName, "CIV Address", stcChannel.CIVAddress);
                Globals.Settings.Save(strName, "PTC II TTL Level", stcChannel.TTLLevel);
                Globals.Settings.Save(strName, "Use NMEA Commands", stcChannel.NMEA);
                Globals.Settings.Save(strName, "TNC On-Air Baud", stcChannel.TNCOnAirBaud);
                SaveScript(strName, stcChannel.TNCScript);
            }
            else if (stcChannel.ChannelType == ChannelMode.PactorTNC)
            {
                // Pactor TNC only properties...
                Globals.Settings.Save(strName, "TNC Type", stcChannel.TNCType);
                Globals.Settings.Save(strName, "TNC Port", stcChannel.TNCPort);
                Globals.Settings.Save(strName, "TNC Timeout", stcChannel.TNCTimeout);
                Globals.Settings.Save(strName, "TNC Serial Port", stcChannel.TNCSerialPort);
                Globals.Settings.Save(strName, "TNC Baud Rate", stcChannel.TNCBaudRate);
                Globals.Settings.Save(strName, "TNC Configuration File", stcChannel.TNCConfigurationFile);
                Globals.Settings.Save(strName, "TNC Configuration On First Use Only", stcChannel.TNCConfigureOnFirstUseOnly);
                Globals.Settings.Save(strName, "TNC Busy Hold", stcChannel.TNCBusyHold);
                Globals.Settings.Save(strName, "Enable Autoforward", stcChannel.EnableAutoforward);
                Globals.Settings.Save(strName, "Radio Control", stcChannel.RDOControl);
                Globals.Settings.Save(strName, "Radio Control Port", stcChannel.RDOControlPort);
                Globals.Settings.Save(strName, "Radio Control Baud", stcChannel.RDOControlBaud);
                Globals.Settings.Save(strName, "Radio Model", stcChannel.RDOModel);
                Globals.Settings.Save(strName, "Center Frequency", stcChannel.RDOCenterFrequency);
                Globals.Settings.Save(strName, "Audio Tone Center", stcChannel.AudioToneCenter);
                Globals.Settings.Save(strName, "CIV Address", stcChannel.CIVAddress);
                Globals.Settings.Save(strName, "Narrow Filter", stcChannel.NarrowFilter);
                Globals.Settings.Save(strName, "TNC PSK Level", stcChannel.TNCPSKLevel);
                Globals.Settings.Save(strName, "TNC FSK Level", stcChannel.TNCFSKLevel);
                Globals.Settings.Save(strName, "Pactor 1 ID", stcChannel.PactorId);
                Globals.Settings.Save(strName, "PTC II TTL Level", stcChannel.TTLLevel);
                Globals.Settings.Save(strName, "Use NMEA Commands", stcChannel.NMEA);
            }
            else if (stcChannel.ChannelType == ChannelMode.Winmor)
            {
                Globals.Settings.Save(strName, "TNC Busy Hold", stcChannel.TNCBusyHold);
                Globals.Settings.Save(strName, "Enable Autoforward", stcChannel.EnableAutoforward);
                Globals.Settings.Save(strName, "Radio Control", stcChannel.RDOControl);
                Globals.Settings.Save(strName, "Radio Control Port", stcChannel.RDOControlPort);
                Globals.Settings.Save(strName, "Radio Control Baud", stcChannel.RDOControlBaud);
                Globals.Settings.Save(strName, "Radio Model", stcChannel.RDOModel);
                Globals.Settings.Save(strName, "Center Frequency", stcChannel.RDOCenterFrequency);
                Globals.Settings.Save(strName, "Audio Tone Center", stcChannel.AudioToneCenter);
                Globals.Settings.Save(strName, "CIV Address", stcChannel.CIVAddress);
                Globals.Settings.Save(strName, "Narrow Filter", stcChannel.NarrowFilter);
                Globals.Settings.Save(strName, "Use NMEA Commands", stcChannel.NMEA);
                Globals.Settings.Save(strName, "WINMOR BW", stcChannel.WMBandwidth);
                Globals.Settings.Save(strName, "WM CaptureDevice", stcChannel.WMCaptureDevice);
                Globals.Settings.Save(strName, "WM PlaybackDevice", stcChannel.WMPlaybackDevice);
                Globals.Settings.Save(strName, "WM PTT Control", stcChannel.WMPTTControl);
                Globals.Settings.Save(strName, "WM Serial Ctrl Signals", stcChannel.WMSerialCtrlSignals);
                Globals.Settings.Save(strName, "WM Xmit Level", stcChannel.WMXmitLevel);
                Globals.Settings.Save(strName, "WM CW ID", stcChannel.WMcwID);
                Globals.Settings.Save(strName, "WM DebugLog", stcChannel.WMDebugLog);
            }
        } // UpdateProperties
Example #19
0
        } // ClearEntries

        private void SetEntries()
        {
            stcSelectedChannel = (TChannelProperties)Channels.Entries[cmbChannelName.Text];
            // chkFirstUseOnly.Enabled = False
            chkFirstUseOnly.Checked = true;
            {
                var withBlock = stcSelectedChannel;
                nudPriority.Value         = withBlock.Priority;
                nudActivityTimeout.Value  = withBlock.TNCTimeout;
                chkChannelEnabled.Checked = withBlock.Enabled;
                if (Globals.IsAutoforwardEnabled())
                {
                    chkAutoforwardEnabled.Checked = withBlock.EnableAutoforward;
                }
                else
                {
                    chkAutoforwardEnabled.Checked = false;
                }

                if (stcSelectedChannel.TNCType.StartsWith("PTC"))
                {
                    chkBusyHold.Visible = true;
                }
                else
                {
                    chkBusyHold.Visible = false;
                    chkBusyHold.Checked = false;
                }

                cmbTNCSerialPort.Text = withBlock.TNCSerialPort;
                cmbTNCBaudRate.Text   = withBlock.TNCBaudRate;
                cmbTNCType.Text       = withBlock.TNCType;

                // If (cmbTNCType.Text = "PK-232") Or (cmbTNCType.Text = "PK-900") Then txtAudioCenter.Enabled = False
                if (cmbTNCType.Text == "PK-232" | cmbTNCType.Text == "DSP-232")
                {
                    txtAudioCenter.Enabled = false;
                }
                txtTNCConfigurationFile.Text = withBlock.TNCConfigurationFile;
                chkFirstUseOnly.Checked      = withBlock.TNCConfigureOnFirstUseOnly;
                txtAudioCenter.Text          = withBlock.AudioToneCenter;
                cmbRadioModel.Text           = withBlock.RDOModel;
                txtRadioAddress.Text         = withBlock.CIVAddress;
                chkNarrowFilter.Checked      = withBlock.NarrowFilter;
                cmbRadioBaud.Text            = withBlock.RDOControlBaud;
                cmbRadioPort.Text            = withBlock.RDOControlPort;
                rdoManual.Checked            = withBlock.RDOControl == "Manual";
                rdoSerial.Checked            = withBlock.RDOControl == "Serial";
                rdoViaPTCII.Checked          = withBlock.RDOControl == "Via PTCII";
                nudFSKLevel.Value            = withBlock.TNCFSKLevel;
                nudPSKLevel.Value            = withBlock.TNCPSKLevel;
                chkIDEnabled.Checked         = withBlock.PactorId;
                chkBusyHold.Checked          = withBlock.TNCBusyHold;
                rdoTTL.Checked  = withBlock.TTLLevel;
                rdoV24.Checked  = !withBlock.TTLLevel;
                chkNMEA.Checked = withBlock.NMEA;
                if (cmbRadioModel.Text.IndexOf("Icom") != -1)
                {
                    chkNMEA.Enabled         = true;
                    lblRadioAddress.Enabled = true;
                    txtRadioAddress.Enabled = true;
                }
                else
                {
                    chkNMEA.Enabled         = false;
                    chkNMEA.Checked         = false;
                    lblRadioAddress.Enabled = false;
                    txtRadioAddress.Enabled = false;
                    txtRadioAddress.Text    = "";
                }

                // Remote Call signs...
                cmbCallSigns.Text = withBlock.RemoteCallsign;

                // Frequencies...
                cmbFreqs.Text = withBlock.RDOCenterFrequency;
                cmbTNCBaudRate.Items.Clear();
                if (cmbTNCType.Text.StartsWith("PTC II") | cmbTNCType.Text == "PTC DR-7800")
                {
                    cmbTNCBaudRate.Items.Add("38400");
                    cmbTNCBaudRate.Items.Add("57600");
                    cmbTNCBaudRate.Items.Add("115200");
                    if (Convert.ToInt32(withBlock.TNCBaudRate) < 38400)
                    {
                        withBlock.TNCBaudRate = "38400";
                    }
                }
                else
                {
                    cmbTNCBaudRate.Items.Add("4800");
                    cmbTNCBaudRate.Items.Add("9600");
                    cmbTNCBaudRate.Items.Add("19200");
                    cmbTNCBaudRate.Items.Add("38400");
                    cmbTNCBaudRate.Items.Add("57600");
                    cmbTNCBaudRate.Items.Add("115200");
                }

                cmbTNCBaudRate.Text  = withBlock.TNCBaudRate;
                btnAdd.Enabled       = false;
                btnRemove.Enabled    = true;
                btnUpdate.Enabled    = true;
                cmbFreqs.Enabled     = true;
                cmbCallSigns.Enabled = true;
            }
        } // SetEntries
Example #20
0
        } // SetEntries

        private void UpdateChannelProperties(ref TChannelProperties stcChannel)
        {
            stcChannel.ChannelType                = ChannelMode.PactorTNC; // TODO: Needs error checking for some parameters
            stcChannel.ChannelName                = cmbChannelName.Text;
            stcChannel.Priority                   = Convert.ToInt32(nudPriority.Value);
            stcChannel.Enabled                    = chkChannelEnabled.Checked;
            stcChannel.TNCTimeout                 = Convert.ToInt32(nudActivityTimeout.Value);
            stcChannel.TNCSerialPort              = cmbTNCSerialPort.Text;
            stcChannel.TNCBaudRate                = cmbTNCBaudRate.Text;
            stcChannel.TNCConfigurationFile       = txtTNCConfigurationFile.Text;
            stcChannel.TNCConfigureOnFirstUseOnly = chkFirstUseOnly.Checked;
            stcChannel.TNCType                    = cmbTNCType.Text;
            var switchExpr = cmbTNCType.Text;

            switch (switchExpr)
            {
            case "KAM/+":
            case "KAMXL":
            {
                stcChannel.TNCPort = 2;
                break;
            }

            case "KAM98":
            case "PK-232":              // , "PK-900"
            {
                stcChannel.TNCPort = 1; // TODO: needs verification, not sure of correct port for XL  and 98
                break;
            }

            case "PTC II":
            case "PTC IIe":
            case "PTC IIex":
            case "PTC IIpro":
            case "PTC IIusb":
            case "PTC DR-7800":
            {
                stcChannel.TNCPort = 31;         // port 31 for SCS Pactor
                break;
            }
            }

            stcChannel.EnableAutoforward = chkAutoforwardEnabled.Checked;
            stcChannel.AudioToneCenter   = txtAudioCenter.Text.Trim();
            stcChannel.RDOControlBaud    = cmbRadioBaud.Text;
            stcChannel.RDOControlPort    = cmbRadioPort.Text;
            stcChannel.RDOModel          = cmbRadioModel.Text;
            stcChannel.CIVAddress        = txtRadioAddress.Text.Trim().ToUpper();
            stcChannel.NarrowFilter      = chkNarrowFilter.Checked;
            if (rdoViaPTCII.Checked)
            {
                stcChannel.RDOControl = "Via PTCII";
            }
            else if (rdoSerial.Checked)
            {
                stcChannel.RDOControl = "Serial";
            }
            else
            {
                stcChannel.RDOControl = "Manual";
            }

            stcChannel.TNCFSKLevel    = Convert.ToInt32(nudFSKLevel.Value);
            stcChannel.TNCPSKLevel    = Convert.ToInt32(nudPSKLevel.Value);
            stcChannel.TNCBusyHold    = chkBusyHold.Checked;
            stcChannel.PactorId       = chkIDEnabled.Checked;
            stcChannel.RemoteCallsign = GetCallSign();
            // .FrequenciesScanned = cmbFreqs.Items.Count
            stcChannel.RDOCenterFrequency = cmbFreqs.Text;
            stcChannel.TTLLevel           = rdoTTL.Checked;
            stcChannel.NMEA = chkNMEA.Checked;
        } // UpdateProperties
Example #21
0
        // **********************************************************************************************************
        // Open serial port and establish communications with the radio. Do initial radio setup.
        //
        // Return true on success of false on failure
        // **********************************************************************************************************
        public bool InitializeSerialPort(ref TChannelProperties stcTNC)
        {
            int retc;

            try
            {
                if (MICOMOpenPort(ref stcTNC.RDOControlPort, Convert.ToInt32(stcTNC.RDOControlBaud)) != 0) // Com port open worked
                {
                    // *****************************************************************
                    // * Perform initial radio setup.
                    // 1 set the radio into frequency mode vs channel mode
                    // 2 check to make sure it is in USB mode and report an error if not
                    // 3 turn off clarifier to prevent hard to find problems
                    // *****************************************************************

                    // Put the radio into frequency mode...
                    byte argMode = 2;
                    retc = MICOMSetMode(ref argMode);
                    if (retc == 0)           // had a problem with the command
                    {
                        if (Timer2Popped == true)
                        {
                            _log.Error("[RadioMicom.InitializeSerialPort] " + "Radio response timeout. Check radio power and connection");
                        }
                        else
                        {
                            _log.Error("[RadioMicom.InitializeSerialPort] " + "MICOM Set MOde Command failed");
                        }

                        return(false);
                    }
                    else
                    {
                        retc = MICOMRptSSBState();
                        if (retc != 2)
                        {
                            MessageBox.Show("Radio must be in USB mode...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            _log.Error("[RadioMicom.InitializeSerialPort] " + "MICOM not in USB mode");
                            return(false);
                        }
                        else
                        {
                            byte argClarifierState = 0;
                            retc = MICOMSetClarifier(ref argClarifierState);
                            if (retc == 0)
                            {
                                _log.Error("[RadioMicom.InitializeSerialPort] " + "Set Clarifier off failed");
                                return(false);
                            }
                            else
                            {
                                return(true);
                            }
                        }
                    }
                }
                else
                {
                    _log.Error("[RadioMicom.InitializeSerialPort] " + "Serial port open failed: " + stcTNC.RDOControlPort);
                    return(false);
                }
            }
            catch (Exception e)
            {
                _log.Error("[RadioMicom.InitializeSerialPort] " + e.Message);
                return(false);
            }
        }   // InitializeSerialPort
Example #22
0
        } // ClearEntries

        private void SetEntries()
        {
            stcSelectedChannel = (TChannelProperties)Channels.Entries[cmbChannelName.Text];
            {
                var withBlock = stcSelectedChannel;
                string strPhsFreq = withBlock.RDOCenterFrequency;
                cmbFreqs.Text = withBlock.RDOCenterFrequency;
                nudPriority.Value = withBlock.Priority;
                // cmbRemoteCallsign.Text = .RemoteCallsign
                nudActivityTimeout.Value = Math.Max(10, withBlock.TNCTimeout);
                nudScriptTimeout.Value = withBlock.TNCScriptTimeout;
                txtScript.Text = withBlock.TNCScript;
                chkEnabled.Checked = withBlock.Enabled;
                cmbTNCSerialPort.Text = withBlock.TNCSerialPort;
                cmbTNCType.Text = withBlock.TNCType;
                nudTNCPort.Value = withBlock.TNCPort;
                txtTNCConfigurationFile.Text = withBlock.TNCConfigurationFile;
                chkFirstUseOnly.Checked = withBlock.TNCConfigureOnFirstUseOnly;

                // Radio Type
                cmbRadioBaud.Text = stcSelectedChannel.RDOControlBaud;
                cmbRadioPort.Text = stcSelectedChannel.RDOControlPort;
                cmbRadioModel.Text = stcSelectedChannel.RDOModel;
                cmbOnAirBaud.Text = stcSelectedChannel.TNCOnAirBaud.ToString();
                txtRadioAdd.Text = stcSelectedChannel.CIVAddress;
                rdoSerial.Checked = stcSelectedChannel.RDOControl == "Serial";
                rdoViaPTCII.Checked = stcSelectedChannel.RDOControl == "Via PTCII";
                rdoManual.Checked = stcSelectedChannel.RDOControl == "Manual";
                rdoTTL.Checked = stcSelectedChannel.TTLLevel;
                rdoV24.Checked = !stcSelectedChannel.TTLLevel;
                try
                {
                    txtFreqMHz.Text = (0.001 * double.Parse(stcSelectedChannel.RDOCenterFrequency, System.Globalization.NumberStyles.AllowDecimalPoint)).ToString("##00.000");
                }
                catch
                {
                }

                cmbTNCBaudRate.Items.Clear();
                if (cmbTNCType.Text.StartsWith("PTC II") | cmbTNCType.Text.IndexOf("DR-7800") != -1)
                {
                    cmbTNCBaudRate.Items.Add("38400");
                    cmbTNCBaudRate.Items.Add("57600");
                    cmbTNCBaudRate.Items.Add("115200");
                    if (Convert.ToInt32(withBlock.TNCBaudRate) < 38400)
                        withBlock.TNCBaudRate = "38400";
                }
                else
                {
                    cmbTNCBaudRate.Items.Add("4800");
                    cmbTNCBaudRate.Items.Add("9600");
                    cmbTNCBaudRate.Items.Add("19200");
                    cmbTNCBaudRate.Items.Add("38400");
                    cmbTNCBaudRate.Items.Add("57600");
                    cmbTNCBaudRate.Items.Add("115200");
                }

                cmbTNCBaudRate.Text = withBlock.TNCBaudRate;
            }

            btnAdd.Enabled = false;
            btnRemove.Enabled = true;
            btnUpdate.Enabled = true;
            cmbFreqs.Enabled = true;
        } // SetEntries