Пример #1
0
 def __init__(self, like=None, verbosity=1):
     dev_descs = pynfc.list_devices()
     if not dev_descs:
         raise RuntimeError('No readers found')
     
     if isinstance(like, int): 
         self.dev_desc = dev_descs[like]
     elif isinstance(like, str): 
         self.dev_desc = [d for d in dev_descs if re.search(d.device, like, flags=re.I|re.DOTALL)][0]
     else:
         self.dev_desc = dev_descs[0]
         
     # Connect to the reader and the tag
     self.reader = self.dev_desc.connect(target=False, verbosity=verbosity)
Пример #2
0
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

import sys
from rfid.libnfc import pynfc, pycrypto1, py14443a


def hex_dump(string):
    """Dumps data as hexstrings"""
    return ' '.join(["%0.2X" % ord(x) for x in string])


### NFC device setup
devs = pynfc.list_devices()
if not devs:
    print "No readers found"
    sys.exit(1)
dev = devs[0]
# Connect to the reader
print "Connect to reader:",
nfc = dev.connect(target=False)
print bool(nfc)
# Set tup the various connection fields
print "Easy Framing False:", nfc.configure(nfc.NDO_EASY_FRAMING, False)
print "Field Down:", nfc.configure(nfc.NDO_ACTIVATE_FIELD, False)
print "CRC False:", nfc.configure(nfc.NDO_HANDLE_CRC, False)
print "Parity True:", nfc.configure(nfc.NDO_HANDLE_PARITY, True)
print "Field Up:", nfc.configure(nfc.NDO_ACTIVATE_FIELD, True)
Пример #3
0
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

import sys
from rfid.libnfc import pynfc, pycrypto1, py14443a



def hex_dump(string):
    """Dumps data as hexstrings"""
    return ' '.join(["%0.2X" % ord(x) for x in string])

### NFC device setup
devs = pynfc.list_devices()
if not devs:
    print "No readers found"
    sys.exit(1)
dev = devs[0]
# Connect to the reader
print "Connect to reader:",
nfc = dev.connect(target = False)
print bool(nfc)
# Set tup the various connection fields
print "Easy Framing False:", nfc.configure(nfc.NDO_EASY_FRAMING, False)
print "Field Down:", nfc.configure(nfc.NDO_ACTIVATE_FIELD, False)
print "CRC False:", nfc.configure(nfc.NDO_HANDLE_CRC, False)
print "Parity True:", nfc.configure(nfc.NDO_HANDLE_PARITY, True)
print "Field Up:", nfc.configure(nfc.NDO_ACTIVATE_FIELD, True)