diff --git a/ErgometerApplication/ErgometerApplication/Ergometer.Designer.cs b/ErgometerApplication/ErgometerApplication/Ergometer.Designer.cs index 0c2343a..f1dc963 100644 --- a/ErgometerApplication/ErgometerApplication/Ergometer.Designer.cs +++ b/ErgometerApplication/ErgometerApplication/Ergometer.Designer.cs @@ -73,9 +73,7 @@ namespace ErgometerApplication // ComPortBox // this.ComPortBox.FormattingEnabled = true; - this.ComPortBox.Items.AddRange(new object[] { - "COM8", - "COM9"}); + this.ComPortBox.Items.AddRange(SerialPort.GetPortNames()); this.ComPortBox.Location = new System.Drawing.Point(12, 290); this.ComPortBox.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ComPortBox.Name = "ComPortBox"; diff --git a/ErgometerApplication/ErgometerApplication/Ergometer.cs b/ErgometerApplication/ErgometerApplication/Ergometer.cs index 40abad6..1522e33 100644 --- a/ErgometerApplication/ErgometerApplication/Ergometer.cs +++ b/ErgometerApplication/ErgometerApplication/Ergometer.cs @@ -13,6 +13,7 @@ using Newtonsoft.Json; using System.IO; using ErgometerLibrary; using System.Net.Sockets; +using System.Net; namespace ErgometerApplication { @@ -24,6 +25,7 @@ namespace ErgometerApplication int sessionID; NetCommand command; List readFile = new List(); + System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient(); public Ergometer() { InitializeComponent(); @@ -61,7 +63,7 @@ namespace ErgometerApplication Meting m = Meting.Parse(response); SaveData(m); - richTextBox1.Text = m.ToString(); + // richTextBox1.Text = m.ToString(); } } else @@ -85,6 +87,12 @@ namespace ErgometerApplication } } + IPAddress ipAddress; //= IPAddress.Parse("127.0.0.1"); + + bool ipIsOk = IPAddress.TryParse("127.0.0.1", out ipAddress); //GetIp() + if (!ipIsOk) { Console.WriteLine("ip adres kan niet geparsed worden."); Environment.Exit(1); } + client.Connect("127.0.0.1", 8888); + WriteServer("5»ses?"); sessionID = int.Parse(ReadServer()); } @@ -257,7 +265,7 @@ namespace ErgometerApplication readFile = null; } } - System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient(); + private String ReadServer() {