def extract_from_frame(data):
if len(data) <= <NUM_LIT:4>:<EOL><INDENT>raise PyVLXException("<STR_LIT>", data=data)<EOL><DEDENT>length = data[<NUM_LIT:0>] * <NUM_LIT> + data[<NUM_LIT:1>] - <NUM_LIT:1><EOL>if len(data) != length + <NUM_LIT:3>:<EOL><INDENT>raise PyVLXException("<STR_LIT>", data=data, current_length=len(data), expected_length=length + <NUM_LIT:3>)<EOL><DEDENT>if calc_crc(data[:-<NUM_LIT:1>]) != data[-<NUM_LIT:1>]:<EOL><INDENT>raise PyVLXException("<STR_LIT>", data=data, expected_crc=calc_crc(data[:-<NUM_LIT:1>]), current_crc=data[-<NUM_LIT:1>])<EOL><DEDENT>payload = data[<NUM_LIT:4>:-<NUM_LIT:1>]<EOL>try:<EOL><INDENT>command = Command(data[<NUM_LIT:2>] * <NUM_LIT> + data[<NUM_LIT:3>])<EOL><DEDENT>except ValueError:<EOL><INDENT>raise PyVLXException("<STR_LIT>", data=data)<EOL><DEDENT>return command, payload<EOL>
Extract payload and command from frame.