當前位置: 首頁>>代碼示例>>C#>>正文


C# MAVLinkInterface.Open方法代碼示例

本文整理匯總了C#中MissionPlanner.MAVLinkInterface.Open方法的典型用法代碼示例。如果您正苦於以下問題:C# MAVLinkInterface.Open方法的具體用法?C# MAVLinkInterface.Open怎麽用?C# MAVLinkInterface.Open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MissionPlanner.MAVLinkInterface的用法示例。


在下文中一共展示了MAVLinkInterface.Open方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: doConnect


//.........這裏部分代碼省略.........
                // set port, then options
                comPort.BaseStream.PortName = portname;

                log.Info("Set Baudrate");
                try
                {
                    comPort.BaseStream.BaudRate = int.Parse(baud);
                }
                catch (Exception exp)
                {
                    log.Error(exp);
                }

                // prevent serialreader from doing anything
                comPort.giveComport = true;

                log.Info("About to do dtr if needed");
                // reset on connect logic.
                if (config["CHK_resetapmonconnect"] == null || bool.Parse(config["CHK_resetapmonconnect"].ToString()) == true)
                {
                    log.Info("set dtr rts to false");
                    comPort.BaseStream.DtrEnable = false;
                    comPort.BaseStream.RtsEnable = false;

                    comPort.BaseStream.toggleDTR();
                }

                comPort.giveComport = false;

                // setup to record new logs
                try
                {
                    Directory.CreateDirectory(MainV2.LogDir);
                    comPort.logfile = new BufferedStream(File.Open(MainV2.LogDir + Path.DirectorySeparatorChar + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".tlog", FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None));

                    comPort.rawlogfile = new BufferedStream(File.Open(MainV2.LogDir + Path.DirectorySeparatorChar + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".rlog", FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None));

                    log.Info("creating logfile " + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".tlog");
                }
                catch (Exception exp2) { log.Error(exp2); CustomMessageBox.Show(Strings.Failclog); } // soft fail

                // reset connect time - for timeout functions
                connecttime = DateTime.Now;

                // do the connect
                comPort.Open(false, skipconnectcheck);

                if (!comPort.BaseStream.IsOpen)
                {
                    log.Info("comport is closed. existing connect");
                    try
                    {
                        _connectionControl.IsConnected(false);
                        UpdateConnectIcon();
                        comPort.Close();
                    }
                    catch { }
                    return;
                }

                // 3dr radio is hidden as no hb packet is ever emitted
                if (comPort.sysidseen.Count > 1)
                {
                    // we have more than one mav
                    // user selection of sysid
                    MissionPlanner.Controls.SysidSelector id = new SysidSelector();
開發者ID:rrvenki,項目名稱:MissionPlanner,代碼行數:67,代碼來源:MainV2.cs

示例2: but_multimav_Click

        private void but_multimav_Click(object sender, EventArgs e)
        {
            Comms.CommsSerialScan.Scan(false);

            DateTime deadline = DateTime.Now.AddSeconds(50);

            while (Comms.CommsSerialScan.foundport == false)
            {
                System.Threading.Thread.Sleep(100);

                if (DateTime.Now > deadline)
                {
                    CustomMessageBox.Show("Timeout waiting for autoscan/no mavlink device connected");
                    return;
                }
            }

            MAVLinkInterface com2 = new MAVLinkInterface();

            com2.BaseStream.PortName = Comms.CommsSerialScan.portinterface.PortName;
            com2.BaseStream.BaudRate = Comms.CommsSerialScan.portinterface.BaudRate;

            com2.Open(true);

            MainV2.Comports.Add(com2);

            CMB_mavs.DataSource = MainV2.Comports;
        }
開發者ID:RealTadango,項目名稱:MissionPlanner,代碼行數:28,代碼來源:temp.cs

示例3: doConnect

        public void  doConnect(MAVLinkInterface comPort, string port, string baud)
        {
            bool skipconnectcheck = true;
            comPort.BaseStream = new MissionPlanner.Comms.SerialPort();

            comPort.BaseStream.PortName = port;
            try
            {
                comPort.BaseStream.BaudRate = int.Parse(baud);
            }
            catch{};
            comPort.Open(false, skipconnectcheck);
            //this.BUT_Connect.Text = "斷開";

            // create a copy
            int[] list = comPort.sysidseen.ToArray();

            comPort.GetParam("MIS_TOTAL");

            // get all the params
            //foreach (var sysid in list)
            //{
            //    comPort.sysidcurrent = sysid;
            //    comPort.getParamList();
            //}
        }
開發者ID:kkouer,項目名稱:PcGcs,代碼行數:26,代碼來源:GCSMainForm.cs

示例4: doConnect

        public void doConnect(MAVLinkInterface comPort, string port, string baud)
        {
            bool skipconnectcheck = true;
            comPort.BaseStream = new MissionPlanner.Comms.SerialPort();

            comPort.BaseStream.PortName = port;
            try
            {
                comPort.BaseStream.BaudRate = int.Parse(baud);
            }
            catch { };

            // 記錄tlog文件
            try
            {
                Directory.CreateDirectory("D://LogFiles");
                //Directory.CreateDirectory(MainV2.LogDir);
                comPort.logfile =
                    new BufferedStream(
                        File.Open(
                            "D://LogFiles" + Path.DirectorySeparatorChar +
                            DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".tlog", FileMode.CreateNew,
                            FileAccess.ReadWrite, FileShare.None));

            }
            catch (Exception exp2)
            {
                log.Error(exp2);
                CustomMessageBox.Show(Strings.Failclog);
            } // soft fail


            comPort.Open(false, skipconnectcheck);

            // create a copy
            int[] list = comPort.sysidseen.ToArray();

            comPort.GetParam("MIS_TOTAL");
        }
開發者ID:kkouer,項目名稱:PcGcs,代碼行數:39,代碼來源:GCS.cs

示例5: BUT_connect_Click

        private void BUT_connect_Click(object sender, EventArgs e)
        {
            Comms.CommsSerialScan.Scan(false);

            DateTime deadline = DateTime.Now.AddSeconds(50);//50秒後未檢測到連接設備則提示過期

            while (Comms.CommsSerialScan.foundport == false)
            {
                System.Threading.Thread.Sleep(100);

                if (DateTime.Now > deadline)
                {
                    CustomMessageBox.Show("Timeout waiting for autoscan/no mavlink device connected");
                    return;
                }
            }

            MAVLinkInterface com2 = new MAVLinkInterface();

            com2.BaseStream.PortName = Comms.CommsSerialScan.portinterface.PortName;
            com2.BaseStream.BaudRate = Comms.CommsSerialScan.portinterface.BaudRate;

            com2.Open(true);

            MainV2.Comports.Add(com2);
            formationComports.Add(com2);//2015年12月9日14:07:09,將新follower加入到編隊list中

            // CMB_mavs.DataSource = MainV2.Comports;

            //CMB_mavs.DataSource

            //updateicons();2015年12月2日16:22:15

            bindingSource1.ResetBindings(false);

            //2015年11月25日16:47:33,連接新飛行器時設置存儲其與leader的間距
            var vectorlead = SwarmInterface.getOffsets(SwarmInterface.getLeader());
            foreach (var port in MainV2.Comports)
            {
                var vector = getOffsetFromLeader(SwarmInterface.getLeader(), (MAVLinkInterface)port);

                SwarmInterface.setOffsets(port, (float)vector.x, (float)vector.y, (float)vector.z);
            }
            //2015年11月25日16:47:38
        }
開發者ID:MikeCaptain,項目名稱:swarm,代碼行數:45,代碼來源:FormationControl.cs


注:本文中的MissionPlanner.MAVLinkInterface.Open方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。