def build_message(cmd, data):
	"""
	Gets command name (str) and data field (str) and creates a valid protocol message
	Returns: str, or None if error occured
	"""
	if len(cmd)>16 or len(data)>9999:
		return None
	spaces='                '
	zeos="0000"
	full_msg=cmd +spaces[0:16-len(cmd)]+"|"+zeos[0:4-len(str(len(data)))]+ str(len(data))+"|"+data

	return full_msg