satel_integra/satel_integra.py
def verify_and_strip(resp):
    """Verify checksum and strip header and footer of received frame."""
    if resp[0:2] != b'\xFE\xFE':
        _LOGGER.error("Houston, we got problem:")
        print_hex(resp)
        raise Exception("Wrong header - got %X%X" % (resp[0], resp[1]))
    if resp[-2:] != b'\xFE\x0D':
        raise Exception("Wrong footer - got %X%X" % (resp[-2], resp[-1]))
    output = resp[2:-2].replace(b'\xFE\xF0', b'\xFE')

    c = checksum(bytearray(output[0:-2]))

    if (256 * output[-2:-1][0] + output[-1:][0]) != c:
        raise Exception("Wrong checksum - got %d expected %d" % (
            (256 * output[-2:-1][0] + output[-1:][0]), c))

    return output[0:-2]
def verify_and_strip(resp):
    if resp[0:2] != b'\xFE\xFE':
        _LOGGER.error("Houston, we got problem:")
        print_hex(resp)
        raise Exception("Wrong header - got %X%X" % (resp[0], resp[1]))
    if resp[-2:] != b'\xFE\x0D':
        raise Exception("Wrong footer - got %X%X" % (resp[-2], resp[-1]))
    output = resp[2:-2].replace(b'\xFE\xF0', b'\xFE')

    c = checksum(bytearray(output[0:-2]))

    if (256 * output[-2:-1][0] + output[-1:][0]) != c:
        raise Exception("Wrong checksum - got %d expected %d" % (
            (256 * output[-2:-1][0] + output[-1:][0]), c))

    return output[0:-2]
def verify_and_strip ( resp ) : if resp [ 0 : 2 ] != b'\xFE\xFE' : _LOGGER . error ( "Houston, we got problem:" ) print_hex ( resp ) raise Exception ( "Wrong header - got %X%X" % ( resp [ 0 ] , resp [ 1 ] ) ) if resp [ - 2 : ] != b'\xFE\x0D' : raise Exception ( "Wrong footer - got %X%X" % ( resp [ - 2 ] , resp [ - 1 ] ) ) output = resp [ 2 : - 2 ] . replace ( b'\xFE\xF0' , b'\xFE' ) c = checksum ( bytearray ( output [ 0 : - 2 ] ) ) if ( 256 * output [ - 2 : - 1 ] [ 0 ] + output [ - 1 : ] [ 0 ] ) != c : raise Exception ( "Wrong checksum - got %d expected %d" % ( ( 256 * output [ - 2 : - 1 ] [ 0 ] + output [ - 1 : ] [ 0 ] ) , c ) ) return output [ 0 : - 2 ]
Verify checksum and strip header and footer of received frame.
Verify checksum and strip header and footer of received frame .