Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3.  
  4. #  cardselect.py - select card and display ID
  5. #
  6. #  Adam Laurie <adam@algroup.co.uk>
  7. #  http://rfidiot.org/
  8. #
  9. #  This code is copyright (c) Adam Laurie, 2006, All rights reserved.
  10. #  For non-commercial use only, the following terms apply - for all other
  11. #  uses, please contact the author:
  12. #
  13. #    This code is free software; you can redistribute it and/or modify
  14. #    it under the terms of the GNU General Public License as published by
  15. #    the Free Software Foundation; either version 2 of the License, or
  16. #    (at your option) any later version.
  17. #
  18. #    This code is distributed in the hope that it will be useful,
  19. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. #    GNU General Public License for more details.
  22. #
  23.  
  24.  
  25. import rfidiot
  26. import sys
  27. import os
  28.  
  29. try:
  30.         card= rfidiot.card
  31. except:
  32.     print "Couldn't open reader!"
  33.         os._exit(True)
  34.  
  35. args= rfidiot.args
  36.  
  37. card.info('cardselect v0.1m')
  38. # force card type if specified
  39. if len(args) == 1:
  40.     card.settagtype(args[0])
  41. else:
  42.     card.settagtype(card.ALL)
  43.  
  44. if card.select():
  45.     print '    Card ID: ' + card.uid
  46.     if card.readertype == card.READER_PCSC:
  47.         print '    ATR: ' + card.pcsc_atr
  48. else:
  49.     if card.errorcode:
  50.         print '    '+card.ISO7816ErrorCodes[card.errorcode]
  51.     else:
  52.         print '    No card present'
  53.         os._exit(True)
  54. os._exit(False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement