def read_topic(read_function, topic=None, nmax=100):
        """ Read specific topic

        Args: 
            read_function: function to read a single message and return msg, data
            topic (list, str, or None)
            nmax (int)
        Returns:
            topic, data

        """
        n = 0
        while True:
            n = n + 1
            msg, obj = read_function()

            if topic is None:
                # always return object
                return msg, obj
            if len(topic) == 0:
                break

            if isinstance(topic, list):
                if msg in topic:
                    break
            else:
                if topic == msg:
                    break
            if msg is None or n > nmax:
                # to good message found
                msg = ''
                obj = None
                break

        return msg, obj