Aquire and identify a card.

        The Polling command is used to detect the Type 3 Tags in the
        field. It is also used for initialization and anti-collision.

        The *system_code* identifies the card system to acquire. A
        card can have multiple systems. The first system that matches
        *system_code* will be activated. A value of 0xff for any of
        the two bytes works as a wildcard, thus 0xffff activates the
        very first system in the card. The card identification data
        returned are the Manufacture ID (IDm) and Manufacture
        Parameter (PMm).

        The *request_code* tells the card whether it should return
        additional information. The default value 0 requests no
        additional information. Request code 1 means that the card
        shall also return the system code, so polling for system code
        0xffff with request code 1 can be used to identify the first
        system on the card. Request code 2 asks for communication
        performance data, more precisely a bitmap of possible
        communication speeds. Not all cards provide that information.

        The number of *time_slots* determines whether there's a chance
        to receive a response if multiple Type 3 Tags are in the
        field. For the reader the number of time slots determines the
        amount of time to wait for a response. Any Type 3 Tag in the
        field, i.e. powered by the field, will choose a random time
        slot to respond. With the default *time_slots* value 0 there
        will only be one time slot available for all responses and
        multiple responses would produce a collision. More time slots
        reduce the chance of collisions (but may result in an
        application working with a tag that was just accidentially
        close enough). Only specific values should be used for
        *time_slots*, those are 0, 1, 3, 7, and 15. Other values may
        produce unexpected results depending on the tag product.

        :meth:`polling` returns either the tuple (IDm, PMm) or the
        tuple (IDm, PMm, *additional information*) depending on the
        response lengt, all as bytearrays.

        Command execution errors raise :exc:`~nfc.tag.TagCommandError`.

def polling(self, system_code=0xffff, request_code=0, time_slots=0):
        """Aquire and identify a card.

        The Polling command is used to detect the Type 3 Tags in the
        field. It is also used for initialization and anti-collision.

        The *system_code* identifies the card system to acquire. A
        card can have multiple systems. The first system that matches
        *system_code* will be activated. A value of 0xff for any of
        the two bytes works as a wildcard, thus 0xffff activates the
        very first system in the card. The card identification data
        returned are the Manufacture ID (IDm) and Manufacture
        Parameter (PMm).

        The *request_code* tells the card whether it should return
        additional information. The default value 0 requests no
        additional information. Request code 1 means that the card
        shall also return the system code, so polling for system code
        0xffff with request code 1 can be used to identify the first
        system on the card. Request code 2 asks for communication
        performance data, more precisely a bitmap of possible
        communication speeds. Not all cards provide that information.

        The number of *time_slots* determines whether there's a chance
        to receive a response if multiple Type 3 Tags are in the
        field. For the reader the number of time slots determines the
        amount of time to wait for a response. Any Type 3 Tag in the
        field, i.e. powered by the field, will choose a random time
        slot to respond. With the default *time_slots* value 0 there
        will only be one time slot available for all responses and
        multiple responses would produce a collision. More time slots
        reduce the chance of collisions (but may result in an
        application working with a tag that was just accidentially
        close enough). Only specific values should be used for
        *time_slots*, those are 0, 1, 3, 7, and 15. Other values may
        produce unexpected results depending on the tag product.

        :meth:`polling` returns either the tuple (IDm, PMm) or the
        tuple (IDm, PMm, *additional information*) depending on the
        response lengt, all as bytearrays.

        Command execution errors raise :exc:`~nfc.tag.TagCommandError`.

        """

        log.debug("polling for system 0x{0:04x}".format(system_code))
        if time_slots not in (0, 1, 3, 7, 15):
            log.debug("invalid number of time slots: {0}".format(time_slots))
            raise ValueError("invalid number of time slots")
        if request_code not in (0, 1, 2):
            log.debug("invalid request code value: {0}".format(request_code))
            raise ValueError("invalid request code for polling")

        timeout = 0.003625 + time_slots * 0.001208
        data = pack(">HBB", system_code, request_code, time_slots)
        data = self.send_cmd_recv_rsp(0x00, data, timeout, send_idm=False)
        if len(data) != (16 if request_code == 0 else 18):
            log.debug("unexpected polling response length")
            raise Type3TagCommandError(DATA_SIZE_ERROR)

        return (data[0:8], data[8:16]) if len(data) == 16 else \
            (data[0:8], data[8:16], data[16:18])