def _hm_verify_message_crc_uk(<EOL>self,<EOL>thermostat_id,<EOL>protocol,<EOL>source,<EOL>expectedFunction,<EOL>expectedLength,<EOL>datal<EOL>):
<EOL>badresponse = <NUM_LIT:0><EOL>if protocol == constants.HMV3_ID:<EOL><INDENT>checksum = datal[len(datal) - <NUM_LIT:2>:]<EOL>rxmsg = datal[:len(datal) - <NUM_LIT:2>]<EOL>crc = CRC16()   <EOL>expectedchecksum = crc.run(rxmsg)<EOL>if expectedchecksum == checksum:<EOL><INDENT>logging.info("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>logging.error("<STR_LIT>")<EOL>serror = "<STR_LIT>"<EOL>sys.stderr.write(serror)<EOL>badresponse += <NUM_LIT:1><EOL><DEDENT>dest_addr = datal[<NUM_LIT:0>]<EOL>frame_len_l = datal[<NUM_LIT:1>]<EOL>frame_len_h = datal[<NUM_LIT:2>]<EOL>frame_len = (frame_len_h << <NUM_LIT:8>) | frame_len_l<EOL>source_addr = datal[<NUM_LIT:3>]<EOL>func_code = datal[<NUM_LIT:4>]<EOL>if (dest_addr != <NUM_LIT> and dest_addr != <NUM_LIT>):<EOL><INDENT>logging.info("<STR_LIT>")<EOL>serror = "<STR_LIT>" % (dest_addr)<EOL>sys.stderr.write(serror)<EOL>badresponse += <NUM_LIT:1><EOL><DEDENT>if dest_addr != thermostat_id:<EOL><INDENT>logging.info("<STR_LIT>")<EOL>serror = "<STR_LIT>" % (dest_addr)<EOL>sys.stderr.write(serror)<EOL>badresponse += <NUM_LIT:1><EOL><DEDENT>if (source_addr < <NUM_LIT:1> or source_addr > <NUM_LIT:32>):<EOL><INDENT>logging.info("<STR_LIT>")<EOL>serror = "<STR_LIT>" % (source_addr)<EOL>sys.stderr.write(serror)<EOL>badresponse += <NUM_LIT:1><EOL><DEDENT>if source_addr != source:<EOL><INDENT>logging.info("<STR_LIT>")<EOL>serror = "<STR_LIT>" % (source_addr)<EOL>sys.stderr.write(serror)<EOL>badresponse += <NUM_LIT:1><EOL><DEDENT>if (<EOL>func_code != constants.FUNC_WRITE<EOL>and func_code != constants.FUNC_READ<EOL>):<EOL><INDENT>logging.info("<STR_LIT>")<EOL>serror = "<STR_LIT>" % (func_code)<EOL>sys.stderr.write(serror)<EOL>badresponse += <NUM_LIT:1><EOL><DEDENT>if func_code != expectedFunction:<EOL><INDENT>logging.info("<STR_LIT>")<EOL>serror = "<STR_LIT>" % (func_code)<EOL>sys.stderr.write(serror)<EOL>badresponse += <NUM_LIT:1><EOL><DEDENT>if (<EOL>func_code == constants.FUNC_WRITE and frame_len != <NUM_LIT:7><EOL>):<EOL><INDENT>logging.info("<STR_LIT>")<EOL>serror = "<STR_LIT>" % (frame_len)<EOL>sys.stderr.write(serror)<EOL>badresponse += <NUM_LIT:1><EOL><DEDENT>if len(datal) != frame_len:<EOL><INDENT>logging.info("<STR_LIT>")<EOL>serror = "<STR_LIT>" % (len(datal), frame_len)<EOL>sys.stderr.write(serror)<EOL>badresponse += <NUM_LIT:1><EOL><DEDENT>if (badresponse == <NUM_LIT:0>):<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>assert <NUM_LIT:0>, "<STR_LIT>" % protocol<EOL><DEDENT>
Verifies message appears legal