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;
|
Expired = Environment.TickCount - Elapsed > Timeout;
|
||||||
// If timeout we clean the buffer
|
// If timeout we clean the buffer
|
||||||
if (Expired && (SizeAvail > 0))
|
if (Expired && (SizeAvail > 0))
|
||||||
try
|
|
||||||
{
|
{
|
||||||
byte[] Flush = new byte[SizeAvail];
|
try
|
||||||
TCPSocket.Receive(Flush, 0, SizeAvail, SocketFlags.None);
|
{
|
||||||
|
byte[] Flush = new byte[SizeAvail];
|
||||||
|
TCPSocket.Receive(Flush, 0, SizeAvail, SocketFlags.None);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
LastError = S7Consts.errTCPDataReceive;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|||||||
@@ -498,21 +498,16 @@ namespace Sharp7
|
|||||||
|
|
||||||
private void CreateSocket()
|
private void CreateSocket()
|
||||||
{
|
{
|
||||||
try
|
Socket = new MsgSocket();
|
||||||
{
|
Socket.ConnectTimeout = DefaultTimeout;
|
||||||
Socket = new MsgSocket();
|
Socket.ReadTimeout = DefaultTimeout;
|
||||||
Socket.ConnectTimeout = DefaultTimeout;
|
Socket.WriteTimeout = DefaultTimeout;
|
||||||
Socket.ReadTimeout = DefaultTimeout;
|
|
||||||
Socket.WriteTimeout = DefaultTimeout;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int TCPConnect()
|
private int TCPConnect()
|
||||||
{
|
{
|
||||||
if (_LastError==0)
|
if (_LastError==0)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_LastError=Socket.Connect(IPAddress, _PLCPort);
|
_LastError=Socket.Connect(IPAddress, _PLCPort);
|
||||||
@@ -521,6 +516,7 @@ namespace Sharp7
|
|||||||
{
|
{
|
||||||
_LastError = S7Consts.errTCPConnectionFailed;
|
_LastError = S7Consts.errTCPConnectionFailed;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return _LastError;
|
return _LastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -575,10 +571,13 @@ namespace Sharp7
|
|||||||
// Receives the S7 Payload
|
// Receives the S7 Payload
|
||||||
RecvPacket(PDU, 7, Size - IsoHSize);
|
RecvPacket(PDU, 7, Size - IsoHSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_LastError == 0)
|
if (_LastError == 0)
|
||||||
|
{
|
||||||
return Size;
|
return Size;
|
||||||
else
|
}
|
||||||
return 0;
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int ISOConnect()
|
private int ISOConnect()
|
||||||
|
|||||||
Reference in New Issue
Block a user