diff --git a/MatterControlLib/PrinterCommunication/Drivers/TCPIP/TcpipSerialPort.cs b/MatterControlLib/PrinterCommunication/Drivers/TCPIP/TcpipSerialPort.cs index 5b93a4403..0ec6afe80 100644 --- a/MatterControlLib/PrinterCommunication/Drivers/TCPIP/TcpipSerialPort.cs +++ b/MatterControlLib/PrinterCommunication/Drivers/TCPIP/TcpipSerialPort.cs @@ -3,13 +3,15 @@ using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; +using MatterHackers.Agg.UI; +using MatterHackers.Localizations; using MatterHackers.MatterControl; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.SerialPortCommunication.FrostedSerial; namespace TcpipDriver { - class TcpipSerialPort :IFrostedSerialPort + class TcpipSerialPort : IFrostedSerialPort { // Telnet protocol characters const byte IAC = 255; // escape @@ -70,7 +72,7 @@ namespace TcpipDriver { get { - if(stream.DataAvailable) + if (stream.DataAvailable) { int bytesRead = stream.Read(readBuffer, bufferIndex, readBuffer.Length); bufferIndex += bytesRead; @@ -106,7 +108,7 @@ namespace TcpipDriver set { - if(stream != null) + if (stream != null) { stream.ReadTimeout = value; } @@ -128,7 +130,7 @@ namespace TcpipDriver set { - if(stream != null) + if (stream != null) { stream.WriteTimeout = value; } @@ -178,6 +180,7 @@ namespace TcpipDriver }; this.LogInfo("Connected to: " + ipEndPoint.Address + " on port " + ipEndPoint.Port); + if (this.BaudRate != 0) { //Send Telnet handshake so that esp will enter the telnet mode allowing us to set baud and reset board @@ -187,6 +190,7 @@ namespace TcpipDriver SetBaudRate(this.BaudRate); } } + private void LogInfo(string message) { ApplicationController.Instance.LogInfo(message); @@ -263,9 +267,9 @@ namespace TcpipDriver { socket?.Close(); } - catch{ } + catch { } - for(int i =0; i< 5; i++) + for (int i = 0; i < 5; i++) { ipEndPoint = new IPEndPoint(ipAddress, port); socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); @@ -276,7 +280,7 @@ namespace TcpipDriver socket.Connect(ipEndPoint); stream = new NetworkStream(socket); this.LogInfo("Connected to: " + ipEndPoint.Address + " on port " + ipEndPoint.Port); - + // Send telnet handshake byte[] bytes = new byte[] { IAC, WILL, ComPortOpt }; Write(bytes, 0, bytes.Length); @@ -285,7 +289,7 @@ namespace TcpipDriver catch (Exception e) { ApplicationController.Instance.LogError("Exception:" + e.Message); - Thread.Sleep((int)(500 * Math.Pow(i,2))); + Thread.Sleep((int)(500 * Math.Pow(i, 2))); } }