static bool g_bHighSpeed              = true;  //True if 500kbps and false ig 2400bps, used in RPi PinOut
        //Note: g_bCountActive and g_bTimeActive can not be true at the same time

        static void Main(string[] args)
        {
            //start application by displaying some help on screen
            TextWriterTraceListener objConsole = new ReportTraceListener(Console.Out);

            Trace.Listeners.Add(objConsole);
            PrintHelp(args.Length == 0);
            if (args.Length == 0)
            {
                return; //no parameters, nothing to do, just finish here
            }
            //Create and initialize a RFECommunicator object to proxy a RF Explorer device (of any kind)
            g_objRFE = new RFECommunicator(true, IsIOT(args)); //Initialize a new Spectrum Analyzer object
            g_objRFE.ReportInfoAddedEvent           += new EventHandler(OnRFE_ReportLog);
            g_objRFE.ReceivedConfigurationDataEvent += new EventHandler(OnRFE_ReceivedConfigData);
            g_objRFE.UpdateDataEvent += new EventHandler(OnRFE_UpdateData);
            g_objRFE.AutoConfigure    = false;
            g_objRFE.AutoClose        = true;

            UpdateBaudrate(args);

            //Connect to specified serial port
            if (!ConnectPort(args))
            {
                ClosePort();
                return; //if cannot connect to serial port, we cannot do anything else
            }


            //Request analyzer to send current configuration and enable sweep data dump
            if (UpdateFrequencyRange(args))
            {
                g_objRFE.SendCommand_RequestConfigData();
                UpdateNumberOfCsv(args);
                UpdateSweepTime(args);

                if (g_bTimeActive && g_bCountActive)
                {
                    Trace.WriteLine("ERROR: Incompatibility of parameters /time and /count");
                }
                else
                {
                    WaitAndProcess(2, false);
                    DeviceInputStage(args);
                    //Set working frequency range from command line parameters
                    if (SetFrequencyRange(args))
                    {
                        UpdateFileNames(args);
                        //If correct, process responses and display output for some seconds
                        WaitAndProcess(g_nTotalSeconds, true, g_bCountActive);
                    }
                }
            }
            //Close port and finish
            ClosePort();
        }
Exemple #2
0
    public void DoConnect2()
    {
        String strPort;
        int    idx;

        idx = m_dropDownPort.value;

        strPort = m_dropDownPort.options[idx].text;

        m_objRFE = new RFECommunicator(true);
        m_objRFE.PortClosedEvent                += new EventHandler(OnRFE_PortClosed);
        m_objRFE.ReportInfoAddedEvent           += new EventHandler(OnRFE_ReportLog);
        m_objRFE.ReceivedConfigurationDataEvent += new EventHandler(OnRFE_ReceivedConfigData);
        m_objRFE.UpdateDataEvent                += new EventHandler(OnRFE_UpdateData);

        m_objRFE.ConnectPort(strPort, 500000);

        if (!m_objRFE.PortConnected)
        {
            return;
        }

        m_panelConnect.SetActive(false);

        m_objRFE.SendCommand_RequestConfigData();

        Thread.Sleep(500);


        // Set calc mode to "average"
        m_objRFE.SendCommand("C+\x02");

        if (DSP_MODE_FAST == m_iDSPMode)
        {
            // Set DSP mode to "fast"
            m_objRFE.SendCommand("Cp\x02");
        }
        else
        {
            // Set DSP mode to "filter"
            m_objRFE.SendCommand("Cp\x01");
        }


        m_iAdvanceCounter = m_iNumStepsToAdvance;

        String sRFEReceivedString;

        m_objRFE.ProcessReceivedString(true, out sRFEReceivedString);
    }
Exemple #3
0
 private void btnConnectRFExplorer_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     if (comboBoxPortsRFExplorer.Items.Count > 0)
     {
         m_objRFE.ConnectPort(comboBoxPortsRFExplorer.SelectedValue.ToString(), Convert.ToInt32(comboBoxBaudrateRFExplorer.SelectedItem.ToString()));
         if (m_objRFE.PortConnected)
         {
             m_objRFE.SendCommand_RequestConfigData();
         }
         Thread.Sleep(2000);
         m_objRFE.ProcessReceivedString(true, out m_sRFEReceivedString);
     }
     UpdateButtonStatus();
     Cursor.Current = Cursors.Default;
 }
        static void Main(string[] args)
        {
            //start application by displaying some help on screen
            PrintHelp(args.Length == 0);
            if (args.Length == 0)
            {
                return; //no parameters, nothing to do, just finish here
            }
            //Create and initialize a RFECommunicator object to proxy a RF Explorer device (of any kind)
            g_objRFE = new RFECommunicator(true, IsIOT(args)); //Initialize a new Spectrum Analyzer object
            g_objRFE.ReportInfoAddedEvent           += new EventHandler(OnRFE_ReportLog);
            g_objRFE.ReceivedConfigurationDataEvent += new EventHandler(OnRFE_ReceivedConfigData);
            g_objRFE.UpdateDataEvent += new EventHandler(OnRFE_UpdateData);
            g_objRFE.AutoConfigure    = false;

            UpdateBaudrate(args);

            //Connect to specified serial port
            if (!ConnectPort(args))
            {
                ClosePort();
                return; //if cannot connect to serial port, we cannot do anything else
            }

            //g_objRFE.DebugSentTracesEnabled = true;
            //g_objRFE.DebugTracesEnabled = true;

            //Request analyzer to send current configuration and enable sweep data dump
            if (UpdateFrequencyRange(args))
            {
                g_objRFE.SendCommand_RequestConfigData();
                UpdateSweepTime(args);
                WaitAndProcess(2, false);

                //Set working frequency range from command line parameters
                if (SetFrequencyRange(args))
                {
                    UpdateFileNames(args);
                    //If correct, process responses and display output for some seconds
                    WaitAndProcess(g_nTotalSeconds);
                }
            }

            //Close port and finish
            ClosePort();
        }
        private void OnHoldMode_CheckedChanged(object sender, EventArgs e)
        {
            if (m_objAnalyzer == null)
            {
                return;
            }

            m_objAnalyzer.HoldMode = m_chkHoldMode.Checked;
            if (m_objAnalyzer.HoldMode)
            {
                //Send hold mode to RF Explorer to stop RS232 traffic
                m_objAnalyzer.SendCommand_Hold();
            }
            else
            {
                //Not on hold anymore, restore RS232 traffic
                m_objAnalyzer.SendCommand_RequestConfigData();
            }

            OnHoldModeChangeEvent(new EventArgs());
        }
        public bool Connect()
        {
            if (m_dev.GetConnectedPorts())
            {
                m_dev.ConnectPort(m_dev.ValidCP2101Ports[m_port], m_baud, RFECommunicator.IsUnixLike() && !RFECommunicator.IsMacOS(), true);
            }

            if (m_dev.PortConnected)
            {
                Console.WriteLine("Connected to port " + m_dev.ValidCP2101Ports[m_port]);

                m_dev.SendCommand_RequestConfigData();

                return(true);
            }
            else
            {
                Console.WriteLine("ERROR: no port available, please review your connection");

                return(false);
            }
        }