python-snap7 icon indicating copy to clipboard operation
python-snap7 copied to clipboard

No function to get Small Integer

Open Naveenraj006 opened this issue 7 years ago • 2 comments

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

Naveenraj006 avatar Jul 18 '19 10:07 Naveenraj006

related pull request https://github.com/gijzelaerr/python-snap7/pull/125

gijzelaerr avatar Oct 29 '19 06:10 gijzelaerr

and some more https://github.com/gijzelaerr/python-snap7/pull/184

gijzelaerr avatar Aug 18 '20 03:08 gijzelaerr