Skip to content

Commit 852ec09

Browse files
committed
Better handling of LREAL, LINT, and ULINT CIP data types; Version 4.3.2
1 parent 1513955 commit 852ec09

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

server/enip/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def parse_context( sender_context ):
137137
# client.CIP_TYPES
138138
#
139139
# The supported CIP data types, and their CIP 'tag_type' values, byte sizes and validators. We
140-
# are generous with the "signed" types (eg. SINT, INT, DINT), and we actually allow the full
140+
# are generous with the "signed" types (eg. SINT, INT, DINT, LINT), and we actually allow the full
141141
# unsigned range, plus the negative range. There is little risk to doing this, as all provided
142142
# values will fit legitimately into the data type without loss. It does however, make acceptance of
143143
# automatically generated data easier, as we don't need to really know if the data is signed or
@@ -167,6 +167,9 @@ def bool_validate( b ):
167167
'SSTRING': (parser.SSTRING.tag_type, 0, str ),
168168
'BOOL': (parser.BOOL.tag_type, parser.BOOL.struct_calcsize, bool_validate ),
169169
'REAL': (parser.REAL.tag_type, parser.REAL.struct_calcsize, float ),
170+
'LREAL': (parser.LREAL.tag_type, parser.LREAL.struct_calcsize, float ),
171+
'LINT': (parser.LINT.tag_type, parser.LINT.struct_calcsize, lambda x: int_validate( x, -2**63, 2**64-1 )), # extra range
172+
'ULINT': (parser.ULINT.tag_type, parser.ULINT.struct_calcsize, lambda x: int_validate( x, 0, 2**64-1 )),
170173
'DINT': (parser.DINT.tag_type, parser.DINT.struct_calcsize, lambda x: int_validate( x, -2**31, 2**32-1 )), # extra range
171174
'UDINT': (parser.UDINT.tag_type, parser.UDINT.struct_calcsize, lambda x: int_validate( x, 0, 2**32-1 )),
172175
'INT': (parser.INT.tag_type, parser.INT.struct_calcsize, lambda x: int_validate( x, -2**15, 2**16-1 )), # extra range

server/enip/get_attribute.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,19 @@ class proxy( object ):
158158
159159
"""
160160
CIP_TYPES = {
161-
"real": ( parser.REAL, "REAL" ), # <name>: (<class>, <data-path> )
162-
"sint": ( parser.SINT, "SINT" ),
163-
"usint": ( parser.USINT, "USINT" ),
164-
"int": ( parser.INT, "INT" ),
165-
"uint": ( parser.UINT, "UINT" ),
166-
"dint": ( parser.DINT, "DINT" ),
167-
"udint": ( parser.UDINT, "UDINT" ),
168-
"bool": ( parser.BOOL, "BOOL" ),
169-
"word": ( parser.WORD, "WORD" ),
170-
"dword": ( parser.DWORD, "DWORD" ),
161+
"real": ( parser.REAL, "REAL" ), # <name>: (<class>, <data-path> )
162+
"lreal": ( parser.LREAL, "LREAL" ),
163+
"sint": ( parser.SINT, "SINT" ),
164+
"usint": ( parser.USINT, "USINT" ),
165+
"int": ( parser.INT, "INT" ),
166+
"uint": ( parser.UINT, "UINT" ),
167+
"dint": ( parser.DINT, "DINT" ),
168+
"udint": ( parser.UDINT, "UDINT" ),
169+
"lint": ( parser.LINT, "LINT" ),
170+
"ulint": ( parser.ULINT, "ULINT" ),
171+
"bool": ( parser.BOOL, "BOOL" ),
172+
"word": ( parser.WORD, "WORD" ),
173+
"dword": ( parser.DWORD, "DWORD" ),
171174
"ipaddr": ( parser.IPADDR, "IPADDR" ), # a network-order UDINT as a dotted-quad
172175
"string": ( parser.STRING, "STRING.string" ),
173176
"sstring": ( parser.SSTRING, "SSTRING.string" ),

server/enip/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,9 +1117,15 @@ def __setitem__( self, key, value ):
11171117
typenames = {
11181118
"BOOL": ( parser.BOOL, 0 ),
11191119
"INT": ( parser.INT, 0 ),
1120+
"UINT": ( parser.UINT, 0 ),
1121+
"LINT": ( parser.LINT, 0 ),
1122+
"ULINT": ( parser.ULINT, 0 ),
11201123
"DINT": ( parser.DINT, 0 ),
1124+
"UDINT": ( parser.UDINT, 0 ),
11211125
"SINT": ( parser.SINT, 0 ),
1126+
"USINT": ( parser.USINT, 0 ),
11221127
"REAL": ( parser.REAL, 0.0 ),
1128+
"LREAL": ( parser.LREAL, 0.0 ),
11231129
"SSTRING": ( parser.SSTRING, '' ),
11241130
"STRING": ( parser.STRING, '' ),
11251131
}

server/enip/parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class DINT( TYPE ):
225225
struct_calcsize = struct.calcsize( struct_format )
226226

227227
class ULINT( TYPE ):
228-
"""An EtherNet/IP LINT; 64-bit unsigned integer"""
228+
"""An EtherNet/IP ULINT; 64-bit unsigned integer"""
229229
tag_type = 0x00c9
230230
struct_format = '<Q'
231231
struct_calcsize = struct.calcsize( struct_format )
@@ -1738,6 +1738,7 @@ class typed_data( cpppo.dfa ):
17381738
INT yes = 0x00c3 # 2 bytes
17391739
DINT yes = 0x00c4 # 4 bytes
17401740
REAL yes = 0x00ca # 4 bytes
1741+
LREAL yes = 0x00cb # 8 bytes
17411742
USINT yes = 0x00c6 # 1 byte
17421743
UINT yes = 0x00c7 # 2 bytes
17431744
WORD = 0x00d2 # 2 byte (16-bit boolean array)
@@ -1756,7 +1757,10 @@ class typed_data( cpppo.dfa ):
17561757
UINT.tag_type: UINT,
17571758
DINT.tag_type: DINT,
17581759
UDINT.tag_type: UDINT,
1760+
LINT.tag_type: LINT,
1761+
ULINT.tag_type: ULINT,
17591762
REAL.tag_type: REAL,
1763+
LREAL.tag_type: LREAL,
17601764
SSTRING.tag_type: SSTRING,
17611765
STRING.tag_type: STRING,
17621766
}

version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version_info__ = ( 4, 3, 1 )
1+
__version_info__ = ( 4, 3, 2 )
22
__version__ = '.'.join( map( str, __version_info__ ))

0 commit comments

Comments
 (0)