SetupM8P() public method

public SetupM8P ( ICommsSerial port, MissionPlanner.Utilities.PointLatLngAlt basepos, int surveyindur, double surveyinacc ) : void
port ICommsSerial
basepos MissionPlanner.Utilities.PointLatLngAlt
surveyindur int
surveyinacc double
return void
        private void BUT_connect_Click(object sender, EventArgs e)
        {
            if (comPort.IsOpen)
            {
                threadrun = false;
                comPort.Close();
                BUT_connect.Text = Strings.Connect;
            }
            else
            {
                try
                {
                    switch (CMB_serialport.Text)
                    {
                    case "NTRIP":
                        comPort = new CommsNTRIP();
                        CMB_baudrate.SelectedIndex = 0;
                        break;

                    case "TCP Client":
                        comPort = new TcpSerial();
                        CMB_baudrate.SelectedIndex = 0;
                        break;

                    case "UDP Host":
                        comPort = new UdpSerial();
                        CMB_baudrate.SelectedIndex = 0;
                        break;

                    case "UDP Client":
                        comPort = new UdpSerialConnect();
                        CMB_baudrate.SelectedIndex = 0;
                        break;

                    default:
                        comPort          = new SerialPort();
                        comPort.PortName = CMB_serialport.Text;
                        break;
                    }
                }
                catch
                {
                    CustomMessageBox.Show(Strings.InvalidPortName);
                    return;
                }
                try
                {
                    comPort.BaudRate = int.Parse(CMB_baudrate.Text);
                }
                catch
                {
                    CustomMessageBox.Show(Strings.InvalidBaudRate);
                    return;
                }
                try
                {
                    comPort.Open();
                }
                catch (Exception ex)
                {
                    CustomMessageBox.Show("Error Connecting\nif using com0com please rename the ports to COM??\n" +
                                          ex.ToString());
                    return;
                }

                // inject init strings - m8p
                if (chk_m8pautoconfig.Checked)
                {
                    ubx_m8p.SetupM8P(comPort);
                }

                t12 = new System.Threading.Thread(new System.Threading.ThreadStart(mainloop))
                {
                    IsBackground = true,
                    Name         = "injectgps"
                };
                t12.Start();

                BUT_connect.Text = Strings.Stop;

                msgseen.Clear();
                bytes = 0;
            }
        }
示例#2
0
        private void BUT_connect_Click(object sender, EventArgs e)
        {
            threadrun = false;
            if (comPort.IsOpen)
            {
                threadrun = false;
                comPort.Close();
                BUT_connect.Text = Strings.Connect;
                try
                {
                    basedata.Close();

                    basedata = null;
                }
                catch
                {
                }
            }
            else
            {
                status_line3 = null;

                try
                {
                    switch (CMB_serialport.Text)
                    {
                    case "NTRIP":
                        comPort = new CommsNTRIP();
                        CMB_baudrate.SelectedIndex = 0;
                        ((CommsNTRIP)comPort).lat  = MainV2.comPort.MAV.cs.HomeLocation.Lat;
                        ((CommsNTRIP)comPort).lng  = MainV2.comPort.MAV.cs.HomeLocation.Lng;
                        ((CommsNTRIP)comPort).alt  = MainV2.comPort.MAV.cs.HomeLocation.Alt;
                        chk_m8pautoconfig.Checked  = false;
                        break;

                    case "TCP Client":
                        comPort = new TcpSerial();
                        CMB_baudrate.SelectedIndex = 0;
                        break;

                    case "UDP Host":
                        comPort = new UdpSerial();
                        CMB_baudrate.SelectedIndex = 0;
                        break;

                    case "UDP Client":
                        comPort = new UdpSerialConnect();
                        CMB_baudrate.SelectedIndex = 0;
                        break;

                    default:
                        comPort          = new SerialPort();
                        comPort.PortName = CMB_serialport.Text;
                        break;
                    }

                    Settings.Instance["SerialInjectGPS_port"] = CMB_serialport.Text;
                    Settings.Instance["SerialInjectGPS_baud"] = CMB_baudrate.Text;
                }
                catch
                {
                    CustomMessageBox.Show(Strings.InvalidPortName);
                    return;
                }
                try
                {
                    comPort.BaudRate = int.Parse(CMB_baudrate.Text);
                }
                catch
                {
                    CustomMessageBox.Show(Strings.InvalidBaudRate);
                    return;
                }
                try
                {
                    comPort.ReadBufferSize = 1024 * 64;


                    try
                    {
                        comPort.Open();
                    }
                    catch (ArgumentException ex)
                    {
                        log.Error(ex);
                        // try pipe method
                        comPort          = new CommsSerialPipe();
                        comPort.PortName = CMB_serialport.Text;
                        comPort.BaudRate = int.Parse(CMB_baudrate.Text);

                        try
                        {
                            comPort.Open();
                        }
                        catch
                        {
                            comPort.Close();
                            throw;
                        }
                    }


                    try
                    {
                        basedata = new BinaryWriter(new BufferedStream(
                                                        File.Open(
                                                            Settings.Instance.LogDir + Path.DirectorySeparatorChar +
                                                            DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".gpsbase", FileMode.CreateNew,
                                                            FileAccess.ReadWrite, FileShare.None)));
                    }
                    catch (Exception ex2)
                    {
                        CustomMessageBox.Show("Error creating file to save base data into " + ex2.ToString());
                    }
                }
                catch (Exception ex)
                {
                    CustomMessageBox.Show("Error Connecting\nif using com0com please rename the ports to COM??\n" +
                                          ex.ToString());
                    return;
                }

                // inject init strings - m8p
                if (chk_m8pautoconfig.Checked)
                {
                    this.LogInfo("Setup M8P");

                    ubx_m8p.SetupM8P(comPort, chk_m8p_130p.Checked, chk_movingbase.Checked);

                    if (basepos != PointLatLngAlt.Zero)
                    {
                        ubx_m8p.SetupBasePos(comPort, basepos, 0, 0, false, chk_movingbase.Checked);
                    }

                    CMB_baudrate.Text = "115200";

                    this.LogInfo("Setup M8P done");
                }

                t12 = new System.Threading.Thread(new System.Threading.ThreadStart(mainloop))
                {
                    IsBackground = true,
                    Name         = "injectgps"
                };
                t12.Start();

                BUT_connect.Text = Strings.Stop;

                msgseen.Clear();
                bytes = 0;
                invalidateRTCMStatus();
                panel1.Controls.Clear();
            }
        }
示例#3
0
        private void BUT_connect_Click(object sender, EventArgs e)
        {
            if (comPort.IsOpen)
            {
                threadrun = false;
                comPort.Close();
                BUT_connect.Text = Strings.Connect;
                try
                {
                    basedata.Close();

                    basedata = null;
                }
                catch { }
            }
            else
            {
                status_line3 = null;

                try
                {
                    switch (CMB_serialport.Text)
                    {
                    case "NTRIP":
                        comPort = new CommsNTRIP();
                        CMB_baudrate.SelectedIndex = 0;
                        break;

                    case "TCP Client":
                        comPort = new TcpSerial();
                        CMB_baudrate.SelectedIndex = 0;
                        break;

                    case "UDP Host":
                        comPort = new UdpSerial();
                        CMB_baudrate.SelectedIndex = 0;
                        break;

                    case "UDP Client":
                        comPort = new UdpSerialConnect();
                        CMB_baudrate.SelectedIndex = 0;
                        break;

                    default:
                        comPort          = new SerialPort();
                        comPort.PortName = CMB_serialport.Text;
                        break;
                    }

                    Settings.Instance["SerialInjectGPS_port"] = CMB_serialport.Text;
                    Settings.Instance["SerialInjectGPS_baud"] = CMB_baudrate.Text;
                }
                catch
                {
                    CustomMessageBox.Show(Strings.InvalidPortName);
                    return;
                }
                try
                {
                    comPort.BaudRate = int.Parse(CMB_baudrate.Text);
                }
                catch
                {
                    CustomMessageBox.Show(Strings.InvalidBaudRate);
                    return;
                }
                try
                {
                    comPort.ReadBufferSize = 1024 * 64;

                    comPort.Open();

                    try
                    {
                        basedata = new BinaryWriter(new BufferedStream(
                                                        File.Open(
                                                            Settings.Instance.LogDir + Path.DirectorySeparatorChar +
                                                            DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".gpsbase", FileMode.CreateNew,
                                                            FileAccess.ReadWrite, FileShare.None)));
                    }
                    catch (Exception ex2)
                    {
                        CustomMessageBox.Show("Error creating file to save base data into " + ex2.ToString());
                    }
                }
                catch (Exception ex)
                {
                    CustomMessageBox.Show("Error Connecting\nif using com0com please rename the ports to COM??\n" +
                                          ex.ToString());
                    return;
                }

                // inject init strings - m8p
                if (chk_m8pautoconfig.Checked)
                {
                    this.LogInfo("Setup M8P");
                    ubx_m8p.SetupM8P(comPort, basepos, int.Parse(txt_surveyinDur.Text), double.Parse(txt_surveyinAcc.Text));
                }

                t12 = new System.Threading.Thread(new System.Threading.ThreadStart(mainloop))
                {
                    IsBackground = true,
                    Name         = "injectgps"
                };
                t12.Start();

                BUT_connect.Text = Strings.Stop;

                msgseen.Clear();
                bytes = 0;
            }
        }