mirror of
https://github.com/fbarresi/Sharp7.git
synced 2026-02-04 08:42:51 +00:00
fixed exception handling
- minor fixes in curly brackets
This commit is contained in:
@@ -97,12 +97,17 @@ namespace Sharp7
|
||||
Expired = Environment.TickCount - Elapsed > Timeout;
|
||||
// If timeout we clean the buffer
|
||||
if (Expired && (SizeAvail > 0))
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] Flush = new byte[SizeAvail];
|
||||
TCPSocket.Receive(Flush, 0, SizeAvail, SocketFlags.None);
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
LastError = S7Consts.errTCPDataReceive;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -497,22 +497,17 @@ namespace Sharp7
|
||||
private int Time_ms = 0;
|
||||
|
||||
private void CreateSocket()
|
||||
{
|
||||
try
|
||||
{
|
||||
Socket = new MsgSocket();
|
||||
Socket.ConnectTimeout = DefaultTimeout;
|
||||
Socket.ReadTimeout = DefaultTimeout;
|
||||
Socket.WriteTimeout = DefaultTimeout;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private int TCPConnect()
|
||||
{
|
||||
if (_LastError==0)
|
||||
{
|
||||
try
|
||||
{
|
||||
_LastError=Socket.Connect(IPAddress, _PLCPort);
|
||||
@@ -521,6 +516,7 @@ namespace Sharp7
|
||||
{
|
||||
_LastError = S7Consts.errTCPConnectionFailed;
|
||||
}
|
||||
}
|
||||
return _LastError;
|
||||
}
|
||||
|
||||
@@ -575,9 +571,12 @@ namespace Sharp7
|
||||
// Receives the S7 Payload
|
||||
RecvPacket(PDU, 7, Size - IsoHSize);
|
||||
}
|
||||
|
||||
if (_LastError == 0)
|
||||
{
|
||||
return Size;
|
||||
else
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user