From 4610d0b1ac317aa152babb49712e06b06d861313 Mon Sep 17 00:00:00 2001 From: oroulet Date: Mon, 19 Jul 2021 21:02:50 +0200 Subject: [PATCH] correctly encode enums as Int32 and not UInt32 --- asyncua/ua/ua_binary.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/asyncua/ua/ua_binary.py b/asyncua/ua/ua_binary.py index 38aed7e3a..3babd881b 100644 --- a/asyncua/ua/ua_binary.py +++ b/asyncua/ua/ua_binary.py @@ -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) @@ -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