|
27 | 27 |
|
28 | 28 | __all__ = ['parse_int', 'parse_path', 'parse_path_elements', 'parse_path_component',
|
29 | 29 | 'format_path', 'format_context', 'parse_context', 'CIP_TYPES', 'parse_operations',
|
30 |
| - 'client', 'await_response', 'connector', 'recycle', 'main' ] |
| 30 | + 'client', 'await_response', 'connector', 'recycle', 'main', 'ENIPStatusError' ] |
31 | 31 |
|
32 | 32 |
|
33 | 33 | """enip.client -- EtherNet/IP client API and module entry point
|
@@ -70,6 +70,11 @@ def parse_path_component( *args, **kwds ):
|
70 | 70 |
|
71 | 71 | log = logging.getLogger( "enip.cli" )
|
72 | 72 |
|
| 73 | +class ENIPStatusError( Exception ): |
| 74 | + def __init__(self, status=None): |
| 75 | + self.status = status |
| 76 | + super( ENIPStatusError, self ).__init__("Response EtherNet/IP status: %d" % ( status )) |
| 77 | + |
73 | 78 |
|
74 | 79 | def format_path( segments, count=None ):
|
75 | 80 | """Format some simple path segment lists in a human-readable form. Raises an Exception if
|
@@ -1153,7 +1158,7 @@ def collect( self, timeout=None ):
|
1153 | 1158 | elif not response: # empty response indicates clean EOF
|
1154 | 1159 | raise StopIteration( "Session terminated" )
|
1155 | 1160 | elif 'enip.status' in response and response.enip.status != 0:
|
1156 |
| - raise Exception( "Response EtherNet/IP status: %d" % ( response.enip.status )) |
| 1161 | + raise ENIPStatusError( status=response.enip.status ) |
1157 | 1162 | elif 'enip.CIP.send_data.CPF.item[1].unconnected_send.request.multiple.request' in response:
|
1158 | 1163 | # Multiple Service Packet; request.multiple.request is an array of read/write_tag/frag
|
1159 | 1164 | replies = response.enip.CIP.send_data.CPF.item[1].unconnected_send.request.multiple.request
|
|
0 commit comments