private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(mCbxPort.Text)) { return; } if (string.IsNullOrEmpty(mCbxBandrate.Text)) { return; } try { _mMavLink = new MavLinkSerialPortTransport { BaudRate = Convert.ToInt32(mCbxBandrate.Text), SerialPortName = mCbxPort.Text, MavlinkSystemId = 0xFF, MavlinkComponentId = 0xBE }; _mMavLink.OnPacketReceived += OnMavLinkPacketReceived; _mMavLink.Initialize(); } catch (Exception) { MessageBox.Show(@"通信接口初始化失败!"); return; } _mMavLink.BeginHeartBeatLoop(); button1.Enabled = false; button2.Enabled = true; }
public void ConnectMavlinkSerial(string port, int baudrate) { MavSerialTransport.MavlinkSystemId = 1; MavSerialTransport.MavlinkComponentId = 12; MavSerialTransport.SerialPortName = port; MavSerialTransport.BaudRate = baudrate; MavSerialTransport.Initialize(); MavSerialTransport.OnPacketReceived += OnMavLinkPacketReceived; }
private void btnConnect_Click(object sender, EventArgs e) { mluc.SerialPortName = "COM22"; mluc.BaudRate = 57600; mluc.HeartBeatUpdateRateMs = 1000; mluc.OnPacketReceived += OnMavLinkPacketReceived; mluc.Initialize(); mluc.BeginHeartBeatLoop(); pnlConnect.BackColor = Color.ForestGreen; lblConnect.Text = "Connected"; btnConnect.Enabled = false; }