Update mifare port. Add function to get uid.
authorBernard Blackham <[email protected]>
Fri, 29 Feb 2008 13:21:21 +0000 (13:21 +0000)
committerBernard Blackham <[email protected]>
Fri, 29 Feb 2008 13:21:21 +0000 (13:21 +0000)
sql-edition/servers/MIFAREClient.py

index 358f550..502df18 100644 (file)
@@ -4,12 +4,12 @@ from LDAPConnector import get_uid, set_card_id
 \r
 class MIFAREClient:\r
     def __init__(self):\r
-        self.port = Serial('/dev/ttyS2', baudrate = 19200)\r
+        self.port = Serial('/dev/ttyS0', baudrate = 19200)\r
         self.reader = MIFAREReader(self.port)\r
         self.reader.set_led(red = False, green = True)\r
         self.reader.beep(100)\r
     \r
-    def get_card(self):\r
+    def get_card_id(self):\r
         self.reader.set_led(red = True, green = False)\r
         try:\r
             card_id, capacity = self.reader.select_card()\r
@@ -21,6 +21,13 @@ class MIFAREClient:
             self.reader.beep(100)\r
             return card_id\r
     \r
+    def get_card_uid(self):\r
+               card_id = self.get_card_id()\r
+               if card_id == None:\r
+                       return None\r
+               else:\r
+                       return get_uid(card_id)\r
+    \r
     def add_card(self, uid):\r
         self.reader.set_led(red = True, green = False)\r
         for attempt in range(5):\r
@@ -30,8 +37,8 @@ class MIFAREClient:
             except MIFAREException:\r
                 pass\r
             else:\r
-                set_card_id(card_id, uid)\r
+                set_card_id(uid, card_id)\r
                 self.reader.set_led(red = False, green = True)\r
                 return True\r
         self.reader.set_led(red = False, green = True)\r
-        return False
\ No newline at end of file
+        return False\r

UCC git Repository :: git.ucc.asn.au