Coder Social home page Coder Social logo

pyrfidgeek's Introduction

PyRFIDGeek is a python package for reading and writing ISO 15693 cards following the Danish RFID data model for libraries, using serial communication to RFIDGeek boards (tested with RFIDUARTUSB7970 from RFIDGeek) and possibly other boards based on the TI TRF7970A chip, such as TI's Evaluation Module (EVM). In addition, it can scan for ISO14443A/B cards and return their UIDs, but there's no read/write support for ISO14443 or Mifare (pull requests are welcome :))

To install from PyPI:

pip install rfidgeek

Initialization

If you haven't already, you might need to install the CP210x USB to UART Bridge VCP Drivers first.

You then need to find out the name of the virtual com port the RFID board is connected to. On Mac OS , it's most likely /dev/tty.SLAB_USBtoUART. If not, look for similar names under /dev/. On Windows, it will be COMx, where x is some number. Check device manager or scan through the ports to find x.

Once you have the COM port name, you can initialize PyRFIDGeek like so:

from rfidgeek import PyRFIDGeek, ISO14443A, ISO15693

rfid = PyRFIDGeek(serial_port='/dev/tty.SLAB_USBtoUART')

There's additional serial port options that can be changed, but most likely the defaults will do fine.

Examples

See also the example_*.py files.

Scanning for ISO 14443 and 15693 tags:

for protocol in [ISO14443A, ISO15693]:
    rfid.set_protocol(protocol)
    for uid in rfid.inventory():
        print('Found {} tag: {}', protocol, uid)

rfid.close()

Reading ISO 15693 tags

rfid.set_protocol(ISO15693)

for uid in rfid.inventory(single_slot=False):
    item = rfid.read_danish_model_tag(uid)
    print
    print ' # Item id: %s (part %d of %d)' % (item['id'], item['partno'], item['nparts'])
    print '   Country: %s, library: %s' % (item['country'], item['library'])
    if item['crc_ok']:
        print '   CRC check successful'
    else:
        print '   CRC check failed'
    print

rfid.close()

Writing ISO 15693 tags

rfid.set_protocol(ISO15693)
uids = rfid.inventory()

for partno, uid in enumerate(uids):
    item = {
        'partno': partno,
        'nparts': len(uids),
        'country': 'NO',
        'library': '1030310',   # ISIL
        'id': '75K110086'       # Document id
    }
    if rfid.write_danish_model_tag(uid, item):
        print 'Wrote tag %d of %d' % (partno, len(uids))
    else:
        print 'Write failed, please try again'

rfid.close()

Debugging

To see all messages sent and received, add a logging handler before you initialize the RFIDGeek module, such as StreamHandler that prints to stderr by default:

import logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(ch)

...

Optionally, install termcolor (pip install termcolor) to get color coded messages.

pyrfidgeek's People

Contributors

danmichaelo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyrfidgeek's Issues

Support for Raspberry Pi

I was planning on using this package with the "DLP-RFID2D USB" RFID reader on a Raspberry Pi. Do you think there will be any compatibility issues when trying to run this code on the Raspberry Pi OS which is Linux based (since you only mentioned Windows and Mac in the readme)?

Thanks!

Edit: I was able to successfully read tags using the module.

Question

Any support for ISO 18000-6C?

Undeclared dependency on `termcolor` Python package

Thanks for your work on this package.

I've had success (only tested reading) using this package with the DLP Design DLP-RFID2D USB stick.

I did run into one issue:

Given that it's only used for (optional) logging it seems reasonable to not change to require termcolor but rather provide a "pass through" implementation of the function colored() used.

In the interim I just installed the required library via:

pip install termcolor

Thanks again for your efforts!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.