Fix whitespace

This commit is contained in:
jlewin 2019-04-05 17:09:08 -07:00
parent dc22fb102c
commit 21252cd19a

View file

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