diff --git a/src/SampleApp.WinDesktop/MainWindow.xaml b/src/SampleApp.WinDesktop/MainWindow.xaml
index f77b176..b25b0b0 100644
--- a/src/SampleApp.WinDesktop/MainWindow.xaml
+++ b/src/SampleApp.WinDesktop/MainWindow.xaml
@@ -67,18 +67,12 @@
-
-
-
-
-
+
1200
2400
4800
diff --git a/src/SampleApp.WinDesktop/MainWindow.xaml.cs b/src/SampleApp.WinDesktop/MainWindow.xaml.cs
index a82c648..ace07bb 100644
--- a/src/SampleApp.WinDesktop/MainWindow.xaml.cs
+++ b/src/SampleApp.WinDesktop/MainWindow.xaml.cs
@@ -165,82 +165,6 @@ namespace SampleApp.WinDesktop
MessageBox.Show("Error connecting: " + ex.Message);
}
}
-
- //Attempts to perform an auto discovery of serial ports
- private async void AutoDiscoverButton_Click(object sender, RoutedEventArgs e)
- {
- var button = sender as Button;
- button.IsEnabled = false;
- System.IO.Ports.SerialPort port = await Task.Run(() => {
- return FindPort(
- new System.Progress((s) => { Dispatcher.BeginInvoke((Action)delegate() { autoDiscoverStatus.Text = s; }); }));
- });
- if (port != null) //we found a port
- {
- autoDiscoverStatus.Text = "";
- serialPorts.Text = port.PortName;
- baudRates.Text = port.BaudRate.ToString();
- ConnectToSerialButton_Click(sender, e);
- }
- else
- autoDiscoverStatus.Text = "No GPS port found";
- button.IsEnabled = false;
- }
-
- //Iterates all serial ports and attempts to open them at different baud rates
- //and looks for a GPS message.
- private static System.IO.Ports.SerialPort FindPort(IProgress progress = null)
- {
- var ports = System.IO.Ports.SerialPort.GetPortNames().OrderBy(s => s);
- foreach (var portName in ports)
- {
- using (var port = new System.IO.Ports.SerialPort(portName))
- {
- var defaultRate = port.BaudRate;
- List baudRatesToTest = new List(new[] { 9600, 4800, 115200, 19200, 57600, 38400, 2400 }); //Ordered by likelihood
- //Move default rate to first spot
- if (baudRatesToTest.Contains(defaultRate)) baudRatesToTest.Remove(defaultRate);
- baudRatesToTest.Insert(0, defaultRate);
- foreach (var baud in baudRatesToTest)
- {
-
- if (progress != null)
- progress.Report(string.Format("Trying {0} @ {1}baud", portName, baud));
- port.BaudRate = baud;
- port.ReadTimeout = 2000; //this might not be long enough
- bool success = false;
- try
- {
- port.Open();
- if (!port.IsOpen)
- continue; //couldn't open port
- try
- {
- port.ReadTo("$GP");
- }
- catch (TimeoutException)
- {
- continue;
- }
- success = true;
- }
- catch
- {
- //Error reading
- }
- finally
- {
- port.Close();
- }
- if (success)
- {
- return new System.IO.Ports.SerialPort(portName, baud);
- }
- }
- }
- }
- return null;
- }
}
public class ReverseConverter : IValueConverter