本文整理匯總了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();
示例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;
}
示例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();
//}
}
示例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");
}
示例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
}