Пример #1
0
        private void _btn_connect_Click(object sender, EventArgs e)
        {
            try
            {
                if (_btn_connect.Checked)
                {
                    _serial.Close();
                    //DisconnectPanels();

                    _btn_connect.Checked = false;
                }
                else
                {
                    connected = DateTime.Now;

                    /*if (_serial != null)
                     * {
                     *  //_serial.Close();
                     *  string portname = _serial.PortName;
                     *  int baudrate = _serial.BaudRate;
                     *  //if (_serial == null)
                     *  //_serial = new SerialCommunication_CSV();
                     *  _serial.Open(portname, baudrate);
                     *  _btnBasicConfiguration.Enabled = true;
                     * }
                     * else
                     * {*/
                    ConnectDialog cd = new ConnectDialog();
                    cd.ShowDialog(this);
                    if (_serial == null)
                    {
                        _serial = new SerialCommunication_CSV();
                        ConnectPanels();
                    }
                    _serial.Open(cd.SelectedPort(), cd.SelectedBaudrate());

                    //}
                    //ConnectPanels();
                    _btn_connect.Checked = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error connecting", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void _btn_firmware_upgrade_Click(object sender, EventArgs e)
        {
            int baudrate = _serial.BaudRate;
            string port = _serial.PortName;

            bool connected = _btn_connect.Checked;

            //if (MessageBox.Show(this, "Upgrading the firmware may enable features\r\nwhich are not legal in your country.\r\nYou are fully responsibel for your flights.\r\nAre you sure you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
            //    return;
            if (Properties.Settings.Default.ShowFirmwareUpgradeWarning)
            {
                PSTaskDialog.cTaskDialog.ShowTaskDialogBox("Warning",
                     "Are you sure you wish to upgrade the firmware?",
                     "Upgrading the firmware may enable features which are not legal in your country. We are not aware of the laws in your country and cannot be held responsible. You are fully responsible for your own actions.",
                      "", "", "Don't show this message again", "", "I know what I am doing and take full responsability|Cancel", PSTaskDialog.eTaskDialogButtons.OK, PSTaskDialog.eSysIcons.Warning, PSTaskDialog.eSysIcons.Warning);
                if (PSTaskDialog.cTaskDialog.VerificationChecked)
                {
                    Properties.Settings.Default.ShowFirmwareUpgradeWarning = false;
                    Properties.Settings.Default.Save();
                }

                if (PSTaskDialog.cTaskDialog.CommandButtonResult == 1)
                    return;
            }

            if (_serial == null)   // Ask COM port & baudrate if not known yet
            {
                ConnectDialog cd = new ConnectDialog();
                cd.ShowDialog(this);
                _serial = new SerialCommunication_CSV();
                _serial.Open(cd.SelectedPort(), cd.SelectedBaudrate());
                ConnectPanels();
            }

            FileDialog fd = new OpenFileDialog();
            if (fd.ShowDialog() != DialogResult.OK)
                return;

            if (_serial.IsOpen)  // Close the current connection if it's open
                _serial.Close(); //_btn_connect_Click(null, null);

            string c = " -k=" + port + " -f=\"" + fd.FileName + "\"  -p -d=dsPIC33FJ256MC710 -u=" + baudrate + " -q=0a;5a;5a;3b;31;31;32;33;0a -r=115200 -b=1200 -o";
            Process p = System.Diagnostics.Process.Start(Application.StartupPath + "\\ds30loader\\ds30LoaderConsole.exe", c);
            p.WaitForExit();

            if (p.ExitCode != -1)
                MessageBox.Show("New firmware has been written", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            else
            {
                if (MessageBox.Show("There has been an error!", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry)
                    _btn_firmware_upgrade_Click(null, null);
            }

            if (connected)  // Reconnect if the state was connected
            {
                _serial.Open(port, baudrate);//_btn_connect_Click(null, null);
            }
        }
Пример #3
0
        private void _btn_connect_Click(object sender, EventArgs e)
        {
            try
            {
                if (_btn_connect.Checked)
                {
                    _serial.Close();
                    //DisconnectPanels();

                    _btn_connect.Checked = false;
                }
                else
                {
                    connected = DateTime.Now;
                    /*if (_serial != null)
                    {
                        //_serial.Close();
                        string portname = _serial.PortName;
                        int baudrate = _serial.BaudRate;
                        //if (_serial == null)
                        //_serial = new SerialCommunication_CSV();
                        _serial.Open(portname, baudrate);
                        _btnBasicConfiguration.Enabled = true;
                    }
                    else
                    {*/
                        ConnectDialog cd = new ConnectDialog();
                        cd.ShowDialog(this);
                        if (_serial == null)
                        {
                            _serial = new SerialCommunication_CSV();
                            ConnectPanels();
                        }
                        _serial.Open(cd.SelectedPort(), cd.SelectedBaudrate());

                    //}
                    //ConnectPanels();
                    _btn_connect.Checked = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error connecting", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
        private void _btn_firmware_upgrade_Click(object sender, EventArgs e)
        {
            int    baudrate = _serial.BaudRate;
            string port     = _serial.PortName;

            bool connected = _btn_connect.Checked;

            //if (MessageBox.Show(this, "Upgrading the firmware may enable features\r\nwhich are not legal in your country.\r\nYou are fully responsibel for your flights.\r\nAre you sure you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
            //    return;
            if (Properties.Settings.Default.ShowFirmwareUpgradeWarning)
            {
                PSTaskDialog.cTaskDialog.ShowTaskDialogBox("Warning",
                                                           "Are you sure you wish to upgrade the firmware?",
                                                           "Upgrading the firmware may enable features which are not legal in your country. We are not aware of the laws in your country and cannot be held responsible. You are fully responsible for your own actions.",
                                                           "", "", "Don't show this message again", "", "I know what I am doing and take full responsability|Cancel", PSTaskDialog.eTaskDialogButtons.OK, PSTaskDialog.eSysIcons.Warning, PSTaskDialog.eSysIcons.Warning);
                if (PSTaskDialog.cTaskDialog.VerificationChecked)
                {
                    Properties.Settings.Default.ShowFirmwareUpgradeWarning = false;
                    Properties.Settings.Default.Save();
                }

                if (PSTaskDialog.cTaskDialog.CommandButtonResult == 1)
                {
                    return;
                }
            }



            if (_serial == null)   // Ask COM port & baudrate if not known yet
            {
                ConnectDialog cd = new ConnectDialog();
                cd.ShowDialog(this);
                _serial = new SerialCommunication_CSV();
                _serial.Open(cd.SelectedPort(), cd.SelectedBaudrate());
                ConnectPanels();
            }

            FileDialog fd = new OpenFileDialog();

            if (fd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (_serial.IsOpen)  // Close the current connection if it's open
            {
                _serial.Close(); //_btn_connect_Click(null, null);
            }
            string  c = " -k=" + port + " -f=\"" + fd.FileName + "\"  -p -d=dsPIC33FJ256MC710 -u=" + baudrate + " -q=0a;5a;5a;3b;31;31;32;33;0a -r=115200 -b=1200 -o";
            Process p = System.Diagnostics.Process.Start(Application.StartupPath + "\\ds30loader\\ds30LoaderConsole.exe", c);

            p.WaitForExit();



            if (p.ExitCode != -1)
            {
                MessageBox.Show("New firmware has been written", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (MessageBox.Show("There has been an error!", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry)
                {
                    _btn_firmware_upgrade_Click(null, null);
                }
            }

            if (connected)                    // Reconnect if the state was connected
            {
                _serial.Open(port, baudrate); //_btn_connect_Click(null, null);
            }
        }