Example #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (tsLoading.Visible)
            {
                return;
            }


            string path = string.Empty;

            try
            {
                Msg_configuration_control msg = new Msg_configuration_control();
                msg.command            = (byte)CONFIG_COMMAND.CONFIG_COMMAND_BOOTLOADER;
                mavlink_packet.Message = msg;
                byte[] bytes = mavlink.Send(mavlink_packet);
                serialPort.Write(bytes, 0, bytes.Length);

                Disconnect(false);
                Enabled = false;
                UpdateForm.ShowDialog(this, serialPort.PortName, path);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Error while communication:\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Enabled = true;
            Connect(true);
        }
Example #2
0
 public static DialogResult ShowDialog(IWin32Window parent, string portName, string fileName)
 {
     using (UpdateForm dlg = new UpdateForm(portName, fileName))
     {
         return(dlg.ShowDialog(parent));
     }
 }
Example #3
0
        private void MainForm_KeyUp(object sender, KeyEventArgs e)
        {
            if (currentStep == StateMachineStep.Connected && e.KeyCode == Keys.U)
            {
                btnUpdate.Visible = true;
            }

            if (currentStep == StateMachineStep.None && e.KeyCode == Keys.L)
            {
                try
                {
                    serialPort.Open();
                    StateMachineUpdate(StateMachineStep.Connected);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Error while open serial port:\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (currentStep == StateMachineStep.None && e.KeyCode == Keys.F)
            {
                try
                {
                    Enabled = false;
                    if (UpdateForm.ShowDialog(this, serialPort.PortName, String.Empty) == DialogResult.OK)
                    {
                        Connect(false);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Error while communication:\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                Enabled = true;
            }
        }