@@ -261,15 +261,15 @@ private void OnDataReceived(byte[] PDU, int len)
261261 if ( PDU [ pos ] != 0x72 )
262262 {
263263 m_ReceivedNeedMoreDataForCompletePDU = false ;
264- m_LastError = S7Consts . errIsoInvalidPDU ;
264+ m_LastError = S7Consts . errIsoInvalidPDU1 ;
265265 return ;
266266 }
267267 pos ++ ;
268268 protoVersion = PDU [ pos ] ;
269269 if ( protoVersion != ProtocolVersion . V1 && protoVersion != ProtocolVersion . V2 && protoVersion != ProtocolVersion . V3 && protoVersion != ProtocolVersion . SystemEvent )
270270 {
271271 m_ReceivedNeedMoreDataForCompletePDU = false ;
272- m_LastError = S7Consts . errIsoInvalidPDU ;
272+ m_LastError = S7Consts . errIsoInvalidPDU2 ;
273273 return ;
274274 }
275275 // For the first fragment, write the ProtocolVersion into the stream in advance
@@ -303,7 +303,7 @@ private void OnDataReceived(byte[] PDU, int len)
303303 {
304304 Console . WriteLine ( "S7CommPlusConnection - OnDataReceived: SystemEvent has fatal error" ) ;
305305 // Termination neccessary
306- m_LastError = S7Consts . errIsoInvalidPDU ;
306+ m_LastError = S7Consts . errIsoInvalidPDU3 ;
307307 }
308308 else
309309 {
@@ -364,13 +364,13 @@ private int checkResponseWithIntegrity(IS7pRequest request, IS7pResponse respons
364364 {
365365 if ( response == null )
366366 {
367- Console . WriteLine ( "checkResponseWithIntegrity: ERROR! response == null" ) ;
368- return S7Consts . errIsoInvalidPDU ;
367+ // Console.WriteLine("checkResponseWithIntegrity: ERROR! response == null");
368+ return S7Consts . errIsoInvalidPDU4 ;
369369 }
370370 if ( request . SequenceNumber != response . SequenceNumber )
371371 {
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 ;
374374 }
375375 // Overflow is possible and allowed
376376 UInt32 reqIntegCheck = ( UInt32 ) request . SequenceNumber + request . IntegrityId ;
@@ -428,9 +428,8 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
428428 sslRes = InitSslResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
429429 if ( sslRes == null )
430430 {
431- Console . WriteLine ( "S7CommPlusConnection - Connect: InitSslResponse with Error!" ) ;
432431 m_client . Disconnect ( ) ;
433- return m_LastError ;
432+ return S7Consts . errInitSslResponse ;
434433 }
435434
436435 #endregion
@@ -467,15 +466,15 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
467466 var createObjRes = CreateObjectResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
468467 if ( createObjRes == null )
469468 {
470- Console . WriteLine ( "S7CommPlusConnection - Connect: CreateObjectResponse with Error!" ) ;
469+ // Console.WriteLine("S7CommPlusConnection - Connect: CreateObjectResponse with Error!");
471470 m_client . Disconnect ( ) ;
472- return S7Consts . errIsoInvalidPDU ;
471+ return S7Consts . errIsoInvalidPDU6 ;
473472 }
474473 // There are (always?) at least two IDs in the response.
475474 // Usually the first is used for polling data, and the 2nd for jobs which use notifications, e.g. alarming, subscriptions.
476475 m_SessionId = createObjRes . ObjectIds [ 0 ] ;
477476 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));
479478
480479 // Evaluate Struct 314
481480 PValue sval = createObjRes . ResponseObject . GetAttribute ( Ids . ServerSessionVersion ) ;
@@ -504,9 +503,9 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
504503 var setMultiVarRes = SetMultiVariablesResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
505504 if ( setMultiVarRes == null )
506505 {
507- Console . WriteLine ( "S7CommPlusConnection - Connect: SetMultiVariablesResponse with Error!" ) ;
506+ // Console.WriteLine("S7CommPlusConnection - Connect: SetMultiVariablesResponse with Error!");
508507 m_client . Disconnect ( ) ;
509- return S7Consts . errIsoInvalidPDU ;
508+ return S7Consts . errIsoInvalidPDU7 ;
510509 }
511510
512511 #endregion
@@ -543,9 +542,9 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
543542 var getVarSubstreamedRes = GetVarSubstreamedResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
544543 if ( getVarSubstreamedRes == null )
545544 {
546- Console . WriteLine ( "S7CommPlusConnection - Connect.Password: GetVarSubstreamedResponse with Error!" ) ;
545+ // Console.WriteLine("S7CommPlusConnection - Connect.Password: GetVarSubstreamedResponse with Error!");
547546 m_client . Disconnect ( ) ;
548- return S7Consts . errIsoInvalidPDU ;
547+ return S7Consts . errIsoInvalidPDU8 ;
549548 }
550549
551550 // Check access level
@@ -574,9 +573,9 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
574573 var getVarSubstreamedRes_challenge = GetVarSubstreamedResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
575574 if ( getVarSubstreamedRes_challenge == null )
576575 {
577- Console . WriteLine ( "S7CommPlusConnection - Connect.Password: getVarSubstreamedRes_challenge with Error!" ) ;
576+ // Console.WriteLine("S7CommPlusConnection - Connect.Password: getVarSubstreamedRes_challenge with Error!");
578577 m_client . Disconnect ( ) ;
579- return S7Consts . errIsoInvalidPDU ;
578+ return S7Consts . errIsoInvalidPDU9 ;
580579 }
581580
582581 byte [ ] challenge = ( getVarSubstreamedRes_challenge . Value as ValueUSIntArray ) . GetValue ( ) ;
@@ -589,9 +588,9 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
589588 }
590589 if ( challengeResponse . Length != challenge . Length )
591590 {
592- Console . WriteLine ( "S7CommPlusConnection - Connect.Password: challengeResponse.Length != challenge.Length" ) ;
591+ // Console.WriteLine("S7CommPlusConnection - Connect.Password: challengeResponse.Length != challenge.Length");
593592 m_client . Disconnect ( ) ;
594- return S7Consts . errIsoInvalidPDU ;
593+ return S7Consts . errIsoInvalidPDU10 ;
595594 }
596595 for ( int i = 0 ; i < challengeResponse . Length ; ++ i )
597596 {
@@ -623,7 +622,7 @@ public int Connect(string address, string password = "", int timeoutMs = 5000)
623622 {
624623 Console . WriteLine ( "S7CommPlusConnection - Connect.Password: setVariableResponse with Error!" ) ;
625624 m_client . Disconnect ( ) ;
626- return S7Consts . errIsoInvalidPDU ;
625+ return S7Consts . errIsoInvalidPDU11 ;
627626 }
628627
629628 }
@@ -845,9 +844,9 @@ public int SetPlcOperatingState(Int32 state)
845844 var setVarRes = SetVariableResponse . DeserializeFromPdu ( m_ReceivedPDU ) ;
846845 if ( setVarRes == null )
847846 {
848- Console . WriteLine ( "S7CommPlusConnection - Connect: SetVariableResponse with Error!" ) ;
847+ // Console.WriteLine("S7CommPlusConnection - Connect: SetVariableResponse with Error!");
849848 m_client . Disconnect ( ) ;
850- return S7Consts . errIsoInvalidPDU ;
849+ return S7Consts . errIsoInvalidPDU12 ;
851850 }
852851
853852 return 0 ;
0 commit comments