Skip to content

Commit 80584f4

Browse files
committed
- added log message when STARTDT received while connection is already
active
1 parent 6872d89 commit 80584f4

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

lib60870/CS104/ClientConnection.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ private void sendNextAvailableASDU()
512512
{
513513
oldestSentASDU = 0;
514514
newestSentASDU = 0;
515-
516515
}
517516
else
518517
{
@@ -1011,36 +1010,33 @@ private bool HandleMessage(byte[] buffer, int msgSize)
10111010
return false;
10121011
}
10131012
}
1014-
10151013
// Check for TESTFR_ACT message
10161014
else if ((buffer[2] & 0x43) == 0x43)
10171015
{
1018-
10191016
DebugLog("Send TESTFR_CON");
10201017

10211018
socketStream.Write(TESTFR_CON_MSG, 0, TESTFR_CON_MSG.Length);
10221019
}
1023-
10241020
// Check for STARTDT_ACT message
10251021
else if ((buffer[2] & 0x07) == 0x07)
10261022
{
1027-
10281023
DebugLog("Send STARTDT_CON");
10291024

1025+
socketStream.Write(STARTDT_CON_MSG, 0, TESTFR_CON_MSG.Length);
1026+
10301027
if (this.isActive == false)
10311028
{
10321029
this.isActive = true;
10331030

10341031
this.server.Activated(this);
10351032
}
1036-
1037-
socketStream.Write(STARTDT_CON_MSG, 0, TESTFR_CON_MSG.Length);
1033+
else {
1034+
DebugLog("STARTDT-ACT received while connection is already active");
1035+
}
10381036
}
1039-
10401037
// Check for STOPDT_ACT message
10411038
else if ((buffer[2] & 0x13) == 0x13)
10421039
{
1043-
10441040
DebugLog("Send STOPDT_CON");
10451041

10461042
if (this.isActive == true)
@@ -1052,7 +1048,6 @@ private bool HandleMessage(byte[] buffer, int msgSize)
10521048

10531049
socketStream.Write(STOPDT_CON_MSG, 0, TESTFR_CON_MSG.Length);
10541050
}
1055-
10561051
// Check for TESTFR_CON message
10571052
else if ((buffer[2] & 0x83) == 0x83)
10581053
{
@@ -1062,7 +1057,6 @@ private bool HandleMessage(byte[] buffer, int msgSize)
10621057

10631058
ResetT3Timeout(currentTime);
10641059
}
1065-
10661060
// S-message
10671061
else if (buffer[2] == 0x01)
10681062
{
@@ -1080,7 +1074,6 @@ private bool HandleMessage(byte[] buffer, int msgSize)
10801074

10811075
if (CheckSequenceNumber(seqNo) == false)
10821076
return false;
1083-
10841077
}
10851078
else
10861079
{
@@ -1129,7 +1122,6 @@ private bool handleTimeouts()
11291122

11301123
if (unconfirmedReceivedIMessages > 0)
11311124
{
1132-
11331125
if ((currentTime - lastConfirmationTime) >= (UInt64)(apciParameters.T2 * 1000))
11341126
{
11351127

@@ -1147,7 +1139,6 @@ private bool handleTimeouts()
11471139
{
11481140
if (((long)currentTime - sentASDUs[oldestSentASDU].sentTime) >= (apciParameters.T1 * 1000))
11491141
{
1150-
11511142
PrintSendBuffer();
11521143
DebugLog("I message timeout for " + oldestSentASDU + " seqNo: " + sentASDUs[oldestSentASDU].seqNo);
11531144
return false;
@@ -1162,7 +1153,6 @@ private bool AreByteArraysEqual(byte[] array1, byte[] array2)
11621153
{
11631154
if (array1.Length == array2.Length)
11641155
{
1165-
11661156
for (int i = 0; i < array1.Length; i++)
11671157
{
11681158
if (array1[i] != array2[i])
@@ -1284,15 +1274,13 @@ private void HandleConnection()
12841274

12851275
while (running)
12861276
{
1287-
12881277
try
12891278
{
12901279
// Receive the response from the remote device.
12911280
int bytesRec = receiveMessage(bytes);
12921281

12931282
if (bytesRec > 0)
12941283
{
1295-
12961284
DebugLog("RCVD: " + BitConverter.ToString(bytes, 0, bytesRec));
12971285

12981286
if (HandleMessage(bytes, bytesRec) == false)

0 commit comments

Comments
 (0)