Licensed under an MIT-style license: see LICENSE file for details.
'''
-import serial
+import serial, logging
xor = lambda x, y: x ^ y
def checksum(string):
serial = self.send_packet(command)[3:]
# Select the card for use
- capacity = ord(self.send_packet('\x03\x02' + serial)[3])
+ try:
+ select_response = self.send_packet('\x03\x02' + serial)
+ capacity = ord(select_response[3])
+ except IndexError:
+ logging.warning('Tried to select card but failed: card_type %s, serial %s, select_response %s' % (card_type.__repr__(), serial.__repr__(), select_response.__repr__()))
+ capacity = 0
return (serial, capacity)
def sector_login(self, blockvect, key, keytype=0):
self.mifare_timeout = now + 0.5
mifare_uid = self.mifare.get_card_id()
if mifare_uid != None:
- logging.info('Got MIFARE card id %s'%(str(mifare_uid)))
+ logging.info('Got MIFARE card id %s'%(repr(mifare_uid)))
self.events.append((MIFARE, mifare_uid))
timeout = 0
if timeout == 0: