From: Bernard Blackham Date: Fri, 29 Feb 2008 13:21:21 +0000 (+0000) Subject: Update mifare port. Add function to get uid. X-Git-Tag: IMPORT-FROM-UCCCVS~15 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=912fe3f190d0fbffaa6bde6a499ab60aa0db89e4;p=uccvend-vendserver.git Update mifare port. Add function to get uid. --- diff --git a/sql-edition/servers/MIFAREClient.py b/sql-edition/servers/MIFAREClient.py index 358f550..502df18 100644 --- a/sql-edition/servers/MIFAREClient.py +++ b/sql-edition/servers/MIFAREClient.py @@ -4,12 +4,12 @@ from LDAPConnector import get_uid, set_card_id class MIFAREClient: def __init__(self): - self.port = Serial('/dev/ttyS2', baudrate = 19200) + self.port = Serial('/dev/ttyS0', baudrate = 19200) self.reader = MIFAREReader(self.port) self.reader.set_led(red = False, green = True) self.reader.beep(100) - def get_card(self): + def get_card_id(self): self.reader.set_led(red = True, green = False) try: card_id, capacity = self.reader.select_card() @@ -21,6 +21,13 @@ class MIFAREClient: self.reader.beep(100) return card_id + def get_card_uid(self): + card_id = self.get_card_id() + if card_id == None: + return None + else: + return get_uid(card_id) + def add_card(self, uid): self.reader.set_led(red = True, green = False) for attempt in range(5): @@ -30,8 +37,8 @@ class MIFAREClient: except MIFAREException: pass else: - set_card_id(card_id, uid) + set_card_id(uid, card_id) self.reader.set_led(red = False, green = True) return True self.reader.set_led(red = False, green = True) - return False \ No newline at end of file + return False