Merge pull request #41 from BiTinerary/master

replaced string concatenation with more intelligible string formatting
This commit is contained in:
Mario Gómez 2018-03-20 09:22:06 -06:00 committed by GitHub
commit dd3596c774
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 12 deletions

View file

@ -57,7 +57,7 @@ while continue_reading:
if status == MIFAREReader.MI_OK: if status == MIFAREReader.MI_OK:
# Print UID # Print UID
print "Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3]) print "Card read UID: %s,%s,%s,%s" % (uid[0], uid[1], uid[2], uid[3])
# This is the default key for authentication # This is the default key for authentication
key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF] key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]

View file

@ -373,7 +373,7 @@ class MFRC522:
if not(status == self.MI_OK) or not(backLen == 4) or not((backData[0] & 0x0F) == 0x0A): if not(status == self.MI_OK) or not(backLen == 4) or not((backData[0] & 0x0F) == 0x0A):
status = self.MI_ERR status = self.MI_ERR
print str(backLen)+" backdata &0x0F == 0x0A "+str(backData[0]&0x0F) print "%s backdata &0x0F == 0x0A %s" % (backLen, backData[0]&0x0F)
if status == self.MI_OK: if status == self.MI_OK:
i = 0 i = 0
buf = [] buf = []

View file

@ -1,26 +1,24 @@
MFRC522-python MFRC522-python
============== ==============
A small class to interface with the NFC reader Module MFRC522 on the Raspberry Pi. A small class to interface with the NFC reader Module MFRC522 on the Raspberry Pi.
This is a Python port of the example code for the NFC module MF522-AN. This is a Python port of the example code for the NFC module MF522-AN.
**Important notice:** This library has not being actively updated in almost four years. **Important notice:** This library has not being actively updated in almost four years.
It might not work as intended on more recent Raspberry Pi devices. You might want to It might not work as intended on more recent Raspberry Pi devices. You might want to
take a look to the open pull-requests and forks to see other implementations and bug-fixes. take a look to the open pull-requests and forks to see other implementations and bug-fixes.
# Requirements ## Requirements
This code requires you to have SPI-Py installed from the following repository: This code requires you to have SPI-Py installed from the following repository:
https://github.com/lthiery/SPI-Py https://github.com/lthiery/SPI-Py
# Examples ## Examples
This repository includes a couple of examples showing how to read, write, and dump data from a chip. They are thoroughly commented, and should be easy to understand. This repository includes a couple of examples showing how to read, write, and dump data from a chip. They are thoroughly commented, and should be easy to understand.
# Pins ## Pins
You can use [this](http://i.imgur.com/y7Fnvhq.png) image for reference. You can use [this](http://i.imgur.com/y7Fnvhq.png) image for reference.
| Name | Pin # | Pin name | | Name | Pin # | Pin name |
|------|-------|------------| |:------:|:-------:|:------------:|
| SDA | 24 | GPIO8 | | SDA | 24 | GPIO8 |
| SCK | 23 | GPIO11 | | SCK | 23 | GPIO11 |
| MOSI | 19 | GPIO10 | | MOSI | 19 | GPIO10 |
@ -30,8 +28,8 @@ You can use [this](http://i.imgur.com/y7Fnvhq.png) image for reference.
| RST | 22 | GPIO25 | | RST | 22 | GPIO25 |
| 3.3V | 1 | 3V3 | | 3.3V | 1 | 3V3 |
# Usage ## Usage
Import the class by importing MFRC522 in the top of your script. For more info see the examples. Import the class by importing MFRC522 in the top of your script. For more info see the examples.
# License ## License
This code and examples are licensed under the GNU Lesser General Public License 3.0. This code and examples are licensed under the GNU Lesser General Public License 3.0.

View file

@ -61,7 +61,7 @@ while continue_reading:
if status == MIFAREReader.MI_OK: if status == MIFAREReader.MI_OK:
# Print UID # Print UID
print "Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3]) print "Card read UID: %s,%s,%s,%s" % (uid[0], uid[1], uid[2], uid[3])
# This is the default key for authentication # This is the default key for authentication
key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF] key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]

View file

@ -57,7 +57,7 @@ while continue_reading:
if status == MIFAREReader.MI_OK: if status == MIFAREReader.MI_OK:
# Print UID # Print UID
print "Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3]) print "Card read UID: %s,%s,%s,%s" % (uid[0], uid[1], uid[2], uid[3])
# This is the default key for authentication # This is the default key for authentication
key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF] key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]