diff --git a/.gitignore b/.gitignore index 09a0a9f..f3be4f4 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ $RECYCLE.BIN/ Network Trash Folder Temporary Items .apdisk +*.bak +storage.ide* +db.lock diff --git a/README.md b/README.md index 493ff5b..ae7097a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A Windows XAML application that communicates to a TbsShield Arduino. ##Description This application will communicate to a TbsShield equiped Arduino. It will expose actions and graph the realtime results. -See the Tbs4Rpm for a Arduino sketch that this project will communicate with. +See the [Tbs4Rpm](https://github.com/deHarro/Tbs4Rpm) for a Arduino sketch that this project will communicate with. ##Install To install, clone this into your Vs projects folder, which will place it in a folder named Tbs4Rpm. VS is not picky where you actually clone this project to on your computer and you may clone this into any folder you want. diff --git a/Tbs4Rpm/MainWindow.xaml b/Tbs4Rpm/MainWindow.xaml index 6b1a701..f398d0f 100644 --- a/Tbs4Rpm/MainWindow.xaml +++ b/Tbs4Rpm/MainWindow.xaml @@ -1,7 +1,7 @@  + Title="TBS 2" Height="410" Width="525"> @@ -9,11 +9,14 @@ - - - - - + + + + @@ -105,6 +108,8 @@ + + + + diff --git a/Tbs4Rpm/MainWindow.xaml.cs b/Tbs4Rpm/MainWindow.xaml.cs index 2d90c84..526a017 100644 --- a/Tbs4Rpm/MainWindow.xaml.cs +++ b/Tbs4Rpm/MainWindow.xaml.cs @@ -229,19 +229,15 @@ private string FindPortName(List portsSkip) { string[] ports = SerialPort.GetPortNames(); - // find the first port skipping any with single digit - // or in the portsSkip list + // find the first port skipping any in the portsSkip list for (int indexPort = 0; indexPort < ports.GetLength(0); indexPort++) { string portName = ports[indexPort]; - if (portName.Length > 4) // skip COM5 - { if (!portsSkip.Contains(portName)) { return portName; } } - } return null; } @@ -249,16 +245,19 @@ private string FindPortName(List portsSkip) private bool ConnectPort(string portName) { bool found = false; - comms = new SerialPort(portName, 19200, Parity.None); + //comms = new SerialPort(portName, 19200, Parity.None); + comms = new SerialPort(portName, 19200, Parity.None, 8, (StopBits) 1); comms.NewLine = "\r\n"; - comms.RtsEnable = true; - comms.DtrEnable = true; + comms.RtsEnable = false; // true; + comms.DtrEnable = false; // true; comms.ErrorReceived += comms_ErrorReceived; comms.ReadTimeout = 2000; // large for initial setup try { + for(int x=0; ((x<5) && (found == false)); x++) // 5-mal versuchen, den Arduino zu kontaktieren, Harry + { comms.Open(); - Thread.Sleep(1000); + Thread.Sleep(200); // 200 ms sind genug (in Verbindung mit 5 Versuchen), Harry comms.WriteLine("query version"); string message = comms.ReadLine(); if (message.StartsWith( "