When attempting to set or unset the final bit of signed integer values (sbyte, int16/32/64) I am getting an out of bounds error.
I am connecting to a third party server, getting the node that I require and running the following code:
def set_bit(node: SyncNode, bit: int, value: bool):
'''Sets the value of the indicated bit for the given node.'''
if value:
node.set_attr_bit(asyncua.ua.AttributeIds.Value, bit)
else:
node.unset_attr_bit(asyncua.ua.AttributeIds.Value, bit)
This raises an exception for certain values of bit (7 for sbyte, 15 for int16...) giving the reason (int16 example):
struct.error: short format requires -32768 <= number <= 32767
However this does not fail if the function would not actually change the value of the bit, for example the following code would run without issues:
value = asyncua.ua.Variant(-32768, asyncua.ua.VariantType.Int16)
node.set_value(value)
node.set_attr_bit(asyncua.ua.AttributeIds.Value, 15)
Finally, there are no issues when using unsigned variable types (byte, uint16/32/64).
When attempting to set or unset the final bit of signed integer values (sbyte, int16/32/64) I am getting an out of bounds error.
I am connecting to a third party server, getting the node that I require and running the following code:
This raises an exception for certain values of
bit
(7 for sbyte, 15 for int16...) giving the reason (int16 example):However this does not fail if the function would not actually change the value of the bit, for example the following code would run without issues:
Finally, there are no issues when using unsigned variable types (byte, uint16/32/64).
Python-Version: 3.12 opcua-asyncio Version: 1.0.6