python-snap7
python-snap7 copied to clipboard
No function to get Small Integer
There is no function to get small int which is 1 Byte when compared to int ( 2 Bytes).
def get_sint(bytearray_, byte_index):
"""
Get Small int value from byte array.
small int are represented in one bytes
"""
data = bytearray_[byte_index:byte_index+1]
data[0] = data[0] & 0xff
packed = struct.pack('B', *data)
value = struct.unpack('>b', packed)[0]
return value
related pull request https://github.com/gijzelaerr/python-snap7/pull/125
and some more https://github.com/gijzelaerr/python-snap7/pull/184