Skip to content

Commit

Permalink
correctly encode enums as Int32 and not UInt32
Browse files Browse the repository at this point in the history
  • Loading branch information
oroulet committed Jul 19, 2021
1 parent 2710f57 commit 4610d0b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions asyncua/ua/ua_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ def to_binary(uatype, val):
return getattr(Primitives, uatype.__name__).pack(val)
if issubclass(uatype, Enum):
if isinstance(val, (IntEnum, Enum)):
return Primitives.UInt32.pack(val.value)
return Primitives.UInt32.pack(val)
return Primitives.Int32.pack(val.value)
return Primitives.Int32.pack(val)
if hasattr(ua.VariantType, uatype.__name__):
vtype = getattr(ua.VariantType, uatype.__name__)
return pack_uatype(vtype, val)
Expand Down Expand Up @@ -489,7 +489,7 @@ def struct_from_binary(objtype, data):
if isinstance(objtype, str):
objtype = getattr(ua, objtype)
if issubclass(objtype, Enum):
return objtype(Primitives.UInt32.unpack(data))
return objtype(Primitives.Int32.unpack(data))
enc_count = -1
kwargs = {}
enc = 0
Expand Down

0 comments on commit 4610d0b

Please sign in to comment.