def _hm_form_message(<EOL>self,<EOL>thermostat_id,<EOL>protocol,<EOL>source,<EOL>function,<EOL>start,<EOL>payload<EOL>):
if protocol == constants.HMV3_ID:<EOL><INDENT>start_low = (start & constants.BYTEMASK)<EOL>start_high = (start >> <NUM_LIT:8>) & constants.BYTEMASK<EOL>if function == constants.FUNC_READ:<EOL><INDENT>payload_length = <NUM_LIT:0><EOL>length_low = (constants.RW_LENGTH_ALL & constants.BYTEMASK)<EOL>length_high = (constants.RW_LENGTH_ALL<EOL>>> <NUM_LIT:8>) & constants.BYTEMASK<EOL><DEDENT>else:<EOL><INDENT>payload_length = len(payload)<EOL>length_low = (payload_length & constants.BYTEMASK)<EOL>length_high = (payload_length >> <NUM_LIT:8>) & constants.BYTEMASK<EOL><DEDENT>msg = [<EOL>thermostat_id,<EOL><NUM_LIT:10> + payload_length,<EOL>source,<EOL>function,<EOL>start_low,<EOL>start_high,<EOL>length_low,<EOL>length_high<EOL>]<EOL>if function == constants.FUNC_WRITE:<EOL><INDENT>msg = msg + payload<EOL>type(msg)<EOL><DEDENT>return msg<EOL><DEDENT>else:<EOL><INDENT>assert <NUM_LIT:0>, "<STR_LIT>" % protocol<EOL><DEDENT>
Forms a message payload, excluding CRC