Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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;
        }