本文整理汇总了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
}