コード例 #1
0
 /// <summary>
 /// Fill Combo box and internal containers with all available CP210x ports
 /// </summary>
 public void GetConnectedPorts()
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         if (m_objRFE.GetConnectedPorts())
         {
             UpdateComboBox();
             if (!String.IsNullOrEmpty(m_sDefaultCOMPort))
             {
                 m_comboCOMPort.SelectedItem = m_sDefaultCOMPort;
             }
             else
             {
                 m_comboCOMPort.SelectedIndex = 0;
             }
         }
         else
         {
             m_comboCOMPort.DataSource = null;
         }
         UpdateButtonStatus();
     }
     catch { }
     Cursor.Current = Cursors.Default;
 }
コード例 #2
0
    void InitDeviceList()
    {
        int i;

        m_btnConnect.interactable = false;

        m_dropDownPort.ClearOptions();

        if (!m_objRFE.GetConnectedPorts())
        {
            return;
        }

        for (i = 0; i < m_objRFE.ValidCP2101Ports.Length; i++)
        {
            m_dropDownPort.options.Add(new Dropdown.OptionData()
            {
                text = m_objRFE.ValidCP2101Ports[i]
            });
        }

        if (m_objRFE.ValidCP2101Ports.Length > 0)
        {
            m_txtNoDevices.text = "Select Device Port";
        }

        m_dropDownPort.value = 0;
        m_dropDownPort.RefreshShownValue();

        m_btnConnect.interactable = true;
    }
コード例 #3
0
        static bool ConnectPort(string[] args)
        {
            //Connect to the right UART port (may be USB in Windows/Unix/Mac or a Raspberry Mainboard)
            if (g_bIoTBoard)
            {
                //Define pins to control baudrate (GPIO2 on Pin21) and force a HW reset of the MWSUB3G (Pin12)
                OutputPinConfiguration pinGPIO2 = ConnectorPin.P1Pin21.Output();
                m_pinConnection = new GpioConnection(pinGPIO2);
                OutputPinConfiguration pinRESET = ConnectorPin.P1Pin12.Output();
                m_pinConnection.Add(pinRESET);

                //Reset sequence
                m_pinConnection[pinRESET] = false;
                Thread.Sleep(100);
                m_pinConnection[pinGPIO2] = true; //true for 500Kbps, change to false for 2400bps low speed
                m_pinConnection[pinRESET] = true;
                Thread.Sleep(2500);               //wait for initialization firmware code to finish startup

                //Open COM port from Raspberry mainboard
                string sCOMPort = "/dev/ttyAMA0";
                g_objRFE.ConnectPort(sCOMPort, g_nBaudrate, true);
                Console.WriteLine("Connected to port " + sCOMPort);
            }
            else if (args.Contains("/p:AUTO", StringComparer.Ordinal))
            {
                //This is any non-IoT platform with a single device connected to USB
                if (g_objRFE.GetConnectedPorts())
                {
                    if (g_objRFE.ValidCP2101Ports.Length == 1)
                    {
                        bool bForceBaudrate = (RFECommunicator.IsRaspberry() && g_nBaudrate > 115200);
                        g_objRFE.ConnectPort(g_objRFE.ValidCP2101Ports[0], g_nBaudrate, RFECommunicator.IsUnixLike() && !RFECommunicator.IsMacOS(), bForceBaudrate);
                    }
                }
                if (g_objRFE.PortConnected)
                {
                    Console.WriteLine("Connected to port " + g_objRFE.ValidCP2101Ports[0]);
                }
                else
                {
                    Console.WriteLine("ERROR: no port available, please review your connection");
                    return(false);
                }
            }
            else
            {
                //Use specified port from command line
                int nPos = Array.FindIndex(args, x => x.StartsWith("/p:"));
                if (nPos >= 0)
                {
                    string sCOMPort = args[nPos].Replace("/p:", "");
                    Console.WriteLine("Trying manual port: " + sCOMPort);
                    g_objRFE.ConnectPort(sCOMPort, g_nBaudrate, RFECommunicator.IsUnixLike() && !RFECommunicator.IsMacOS());
                    Console.WriteLine("Connected to port " + sCOMPort);
                }
            }

            return(g_objRFE.PortConnected);
        }
コード例 #4
0
 private void GetConnectedPortsRFExplorer()
 {
     Cursor.Current = Cursors.WaitCursor;
     comboBoxPortsRFExplorer.DataSource = null;
     if (m_objRFE.GetConnectedPorts())
     {
         comboBoxPortsRFExplorer.DataSource = m_objRFE.ValidCP2101Ports;
     }
     UpdateButtonStatus();
     Cursor.Current = Cursors.Default;
 }
コード例 #5
0
 public void GetConnectedPorts()
 {
     Cursor.Current            = Cursors.WaitCursor;
     m_comboCOMPort.DataSource = null;
     if (m_objRFE.GetConnectedPorts())
     {
         m_comboCOMPort.DataSource   = m_objRFE.ValidCP2101Ports;
         m_comboCOMPort.SelectedItem = m_sDefaultCOMPort;
     }
     UpdateButtonStatus();
     Cursor.Current = Cursors.Default;
 }
コード例 #6
0
        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);
            }
        }