@@ -261,15 +261,15 @@ private void OnDataReceived(byte[] PDU, int len)
261
261
if ( PDU [ pos ] != 0x72 )
262
262
{
263
263
m_ReceivedNeedMoreDataForCompletePDU = false ;
264
- m_LastError = S7Consts . errIsoInvalidPDU ;
264
+ m_LastError = S7Consts . errIsoInvalidPDU1 ;
265
265
return ;
266
266
}
267
267
pos ++ ;
268
268
protoVersion = PDU [ pos ] ;
269
269
if ( protoVersion != ProtocolVersion . V1 && protoVersion != ProtocolVersion . V2 && protoVersion != ProtocolVersion . V3 && protoVersion != ProtocolVersion . SystemEvent )
270
270
{
271
271
m_ReceivedNeedMoreDataForCompletePDU = false ;
272
- m_LastError = S7Consts . errIsoInvalidPDU ;
272
+ m_LastError = S7Consts . errIsoInvalidPDU2 ;
273
273
return ;
274
274
}
275
275
// For the first fragment, write the ProtocolVersion into the stream in advance
@@ -303,7 +303,7 @@ private void OnDataReceived(byte[] PDU, int len)
303
303
{
304
304
Console . WriteLine ( "S7CommPlusConnection - OnDataReceived: SystemEvent has fatal error" ) ;
305
305
// Termination neccessary
306
- m_LastError = S7Consts . errIsoInvalidPDU ;
306
+ m_LastError = S7Consts . errIsoInvalidPDU3 ;
307
307
}
308
308
else
309
309
{
@@ -364,13 +364,13 @@ private int checkResponseWithIntegrity(IS7pRequest request, IS7pResponse respons
364
364
{
365
365
if ( response == null )
366
366
{
367
- Console . WriteLine ( "checkResponseWithIntegrity: ERROR! response == null" ) ;
368
- return S7Consts . errIsoInvalidPDU ;
367
+ // Console.WriteLine("checkResponseWithIntegrity: ERROR! response == null");
368
+ return S7Consts . errIsoInvalidPDU4 ;
369
369
}
370
370
if ( request . SequenceNumber != response . SequenceNumber )
371
371
{
372
- Console . WriteLine ( String . Format ( "checkResponseWithIntegrity: ERROR! SeqenceNumber of Response ({0}) doesn't match Request ({1})" , response . SequenceNumber , request . SequenceNumber ) ) ;
373
- return S7Consts . errIsoInvalidPDU ;
372
+ // Console.WriteLine(String.Format("checkResponseWithIntegrity: ERROR! SeqenceNumber of Response ({0}) doesn't match Request ({1})", response.SequenceNumber, request.SequenceNumber));
373
+ return S7Consts . errIsoInvalidPDU5 ;
374
374
}
375
375
// Overflow is possible and allowed
376
376
UInt32 reqIntegCheck = ( UInt32 ) request . SequenceNumber + request . IntegrityId ;
@@ -428,9 +428,8 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
428
428
sslRes = InitSslResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
429
429
if ( sslRes == null )
430
430
{
431
- Console . WriteLine ( "S7CommPlusConnection - Connect: InitSslResponse with Error!" ) ;
432
431
m_client . Disconnect ( ) ;
433
- return m_LastError ;
432
+ return S7Consts . errInitSslResponse ;
434
433
}
435
434
436
435
#endregion
@@ -467,15 +466,15 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
467
466
var createObjRes = CreateObjectResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
468
467
if ( createObjRes == null )
469
468
{
470
- Console . WriteLine ( "S7CommPlusConnection - Connect: CreateObjectResponse with Error!" ) ;
469
+ // Console.WriteLine("S7CommPlusConnection - Connect: CreateObjectResponse with Error!");
471
470
m_client . Disconnect ( ) ;
472
- return S7Consts . errIsoInvalidPDU ;
471
+ return S7Consts . errIsoInvalidPDU6 ;
473
472
}
474
473
// There are (always?) at least two IDs in the response.
475
474
// Usually the first is used for polling data, and the 2nd for jobs which use notifications, e.g. alarming, subscriptions.
476
475
m_SessionId = createObjRes . ObjectIds [ 0 ] ;
477
476
m_SessionId2 = createObjRes . ObjectIds [ 1 ] ;
478
- Console . WriteLine ( "S7CommPlusConnection - Connect: Using SessionId=0x" + String . Format ( "{0:X04}" , m_SessionId ) ) ;
477
+ // Console.WriteLine("S7CommPlusConnection - Connect: Using SessionId=0x" + String.Format("{0:X04}", m_SessionId));
479
478
480
479
// Evaluate Struct 314
481
480
PValue sval = createObjRes . ResponseObject . GetAttribute ( Ids . ServerSessionVersion ) ;
@@ -504,9 +503,9 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
504
503
var setMultiVarRes = SetMultiVariablesResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
505
504
if ( setMultiVarRes == null )
506
505
{
507
- Console . WriteLine ( "S7CommPlusConnection - Connect: SetMultiVariablesResponse with Error!" ) ;
506
+ // Console.WriteLine("S7CommPlusConnection - Connect: SetMultiVariablesResponse with Error!");
508
507
m_client . Disconnect ( ) ;
509
- return S7Consts . errIsoInvalidPDU ;
508
+ return S7Consts . errIsoInvalidPDU7 ;
510
509
}
511
510
512
511
#endregion
@@ -543,9 +542,9 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
543
542
var getVarSubstreamedRes = GetVarSubstreamedResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
544
543
if ( getVarSubstreamedRes == null )
545
544
{
546
- Console . WriteLine ( "S7CommPlusConnection - Connect.Password: GetVarSubstreamedResponse with Error!" ) ;
545
+ // Console.WriteLine("S7CommPlusConnection - Connect.Password: GetVarSubstreamedResponse with Error!");
547
546
m_client . Disconnect ( ) ;
548
- return S7Consts . errIsoInvalidPDU ;
547
+ return S7Consts . errIsoInvalidPDU8 ;
549
548
}
550
549
551
550
// Check access level
@@ -574,9 +573,9 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
574
573
var getVarSubstreamedRes_challenge = GetVarSubstreamedResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
575
574
if ( getVarSubstreamedRes_challenge == null )
576
575
{
577
- Console . WriteLine ( "S7CommPlusConnection - Connect.Password: getVarSubstreamedRes_challenge with Error!" ) ;
576
+ // Console.WriteLine("S7CommPlusConnection - Connect.Password: getVarSubstreamedRes_challenge with Error!");
578
577
m_client . Disconnect ( ) ;
579
- return S7Consts . errIsoInvalidPDU ;
578
+ return S7Consts . errIsoInvalidPDU9 ;
580
579
}
581
580
582
581
byte [ ] challenge = ( getVarSubstreamedRes_challenge . Value as ValueUSIntArray ) . GetValue ( ) ;
@@ -589,9 +588,9 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
589
588
}
590
589
if ( challengeResponse . Length != challenge . Length )
591
590
{
592
- Console . WriteLine ( "S7CommPlusConnection - Connect.Password: challengeResponse.Length != challenge.Length" ) ;
591
+ // Console.WriteLine("S7CommPlusConnection - Connect.Password: challengeResponse.Length != challenge.Length");
593
592
m_client . Disconnect ( ) ;
594
- return S7Consts . errIsoInvalidPDU ;
593
+ return S7Consts . errIsoInvalidPDU10 ;
595
594
}
596
595
for ( int i = 0 ; i < challengeResponse . Length ; ++ i )
597
596
{
@@ -623,7 +622,7 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
623
622
{
624
623
Console . WriteLine ( "S7CommPlusConnection - Connect.Password: setVariableResponse with Error!" ) ;
625
624
m_client . Disconnect ( ) ;
626
- return S7Consts . errIsoInvalidPDU ;
625
+ return S7Consts . errIsoInvalidPDU11 ;
627
626
}
628
627
629
628
}
@@ -845,9 +844,9 @@ public int SetPlcOperatingState(Int32 state)
845
844
var setVarRes = SetVariableResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
846
845
if ( setVarRes == null )
847
846
{
848
- Console . WriteLine ( "S7CommPlusConnection - Connect: SetVariableResponse with Error!" ) ;
847
+ // Console.WriteLine("S7CommPlusConnection - Connect: SetVariableResponse with Error!");
849
848
m_client . Disconnect ( ) ;
850
- return S7Consts . errIsoInvalidPDU ;
849
+ return S7Consts . errIsoInvalidPDU12 ;
851
850
}
852
851
853
852
return 0 ;
0 commit comments