The unified diff between revisions [a12c2fb6..] and [76c1ec23..] is displayed below. It can also be downloaded as a raw diff.

#
#
# patch "mifare.py"
#  from [49cc4cc7a15338b601d57a63e1823bf011acba06]
#    to [b75aefd73f3f575a760f3c4f7957d73ad50a4b09]
#
============================================================
--- mifare.py	49cc4cc7a15338b601d57a63e1823bf011acba06
+++ mifare.py	b75aefd73f3f575a760f3c4f7957d73ad50a4b09
@@ -61,8 +61,38 @@ class MIFAREReader:
         else:
             raise MIFAREException, 'command failed: set_antenna (%s)' % state

-    def select_card(self):
-        pass
+    def select_card(self, include_halted = False):
+        """Selects a card and returns a tuple of  (serial number, capacity).
+
+        If include_halted is set, may select a card that halt() has previously
+        been called on."""
+
+        # Request type of card available
+        command = command = '\x01\x02'
+        if include_halted:
+            command += '\x52'
+        else:
+            command += '\x26'
+
+        card_type_response = self.send_packet(command)
+
+        if card_type_response[2] == '\x14':
+            raise MIFAREException, "select_card: no card available"
+        card_type = card_type_response[3:5]
+
+        if card_type == '\x44\x00': # MIFARE UltraLight
+            raise NotImplementedError, "UltraLight card selected - no functions available"
+
+        else:
+        # Otherwise, must be a standard MIFARE card.
+            # Anticollision
+            command = '\x02\x02\x04'
+            # No error handling on this command
+            serial = self.send_packet(command)[3:]
+
+            # Select the card for use
+            capacity = ord(self.send_packet('\x03\x02' + serial)[3])
+            return (serial, capacity)

     def sector_login(self, keytype, key):
         pass