MissionPlanner.Comms.SerialPort.Open C# (CSharp) Method

Open() public method

public Open ( ) : void
return void
        public new void Open()
        {
            // 500ms write timeout - win32 api default
            this.WriteTimeout = 500;

            if (base.IsOpen)
                return;

            try
            {
                // this causes element not found with bluetooth devices.
                if (BaudRate > 115200)
                {
                    Console.WriteLine("Doing SerialPortFixer");
                    SerialPortFixer.Execute(this.PortName);
                    Console.WriteLine("Done SerialPortFixer");
                }
            }
            catch (Exception ex) { Console.WriteLine(ex.ToString()); }

            if (PortName.StartsWith("/"))
                if (!File.Exists(PortName))
                    throw new Exception("No such device");

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

Usage Example

コード例 #1
0
        Stream port = null;// File.Open(@"C:\Users\hog\Desktop\gps data\asterx-m", FileMode.Open);

        public AP_GPS_COMNAV()
        {
            var sport = new SerialPort("COM13", 115200);

            sport.Open();

            port = sport.BaseStream;
        }
All Usage Examples Of MissionPlanner.Comms.SerialPort::Open