PN532-RFID-NFC-LibNFC

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

Utiliser LibNFC

Utiliser le breakout PN532 avec libnfc

libnfc is a mature, cross-platform, open-source NFC library that can be easily configured to work with the PN532 Breakout Board. While Linux is probably the easiest platform to use libnfc with, it can be configured for the Mac and Windows as well, though you may need to dig around on the libnfc Community Forums for some specific details on compiling .dlls for Windows, etc.

If you want to test the PN532 Breakout Board out with libnfc, this simple tutorial should walk you through the absolute basics of compiling and configuring libnfc, and using some of the canned example SW included in the library.

Libnfc sous Linux

Dans cet exemple, nous utilisons Ubuntu 10.10.

Etape 1: télécharger libnfc

Download the latest version of libnfc from Google Code (ex. "libnfc-1.4.1.tar.gz") and extract the contents of the file as follows:

$ wget http://libnfc.googlecode.com/files/libnfc-x.x.x.tar.gz
$ tar -xvzf libnfc-x.x.x.tar.gz
$ cd libnfc-x.x.x

Etape 2: Configurer libnfc pour PN532 via UART

libnfc currently only supports communication over UART, using any inexpensive USB to UART adapter like the FTDI Friend or a TTL FTDI cable. Before compiling, however, you will need to configure libnfc to include support for UART and the PN532 chipset, which can be done with the following commmand (executing in the folder where the above archive was unzipped):

$ ./configure --with-drivers=pn532_uart --enable-serial-autoprobe

Note: If you also wish to include debug output, you can add the '–enable-serial-autoprobe' flag (minus the single quotes) to the configure options

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

Etape 3: Faire le Build et installer libnfc

You can build and install libnfc with the following three commands, also run from the folder where the original archive was unzipped:

  $ make clean
  $ make
  $ make install

Etape 4: Détecter le lecteur

Nous allons maintenant vérifier si libnfc est capable de retrouver notre lecteur pn532.

Now that libnfc is (hopefully) built and installed, you can run the 'nfc-list' example to try to detect an attached NFC board. Make sure the board is connected to the FTDI or USB/UART adapter, and that it is connected to your PC, and run the following commands:

  $ cd examples
  $ ./nfc-list

This should list the devices that were detected.

Etape 5: lecture de carte MiFare

Nous allons faire une opération de polling pour récupérer les infos des cartes au standard ISO14443A (les cartes Mifare).

Next, you can use the 'nfc-poll' example to wait 30 seconds for an ISO14443A card or tag and display some basic information about this card. In the examples folder that we changed to above, run the following command:

$ ./nfc-poll

This should give you some basic information on any card that entered the magnetic field within the specified delay.

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

Libnfc avec Mac OSX Lion

scott-42 was kind of enough to post some tips on getting libnfc working on a Mac using an FTDI adapter. A couple simple changes to the code were required (as of v1.6.0-rc1), with the details here.

Keeping in mind the code changes mentionned above, the following steps should get libnfc compiling and working via an FTDI type adapter and UART on Lion (using libnfc 1.6.0_rc1):

Télécharger et configurer libnfc

Download and build libnfc and configure if for PN532 UART (making the code changes above before running make):

  wget http://libnfc.googlecode.com/files/libnfc-1.6.0-rc1.tar.gz
  tar -xvzf libnfc-1.6.0-rc1.tar.gz
  cd libnfc-1.6.0-rc1
  ./configure --with-drivers=pn532_uart --enable-serial-autoprobe
  sudo make
  sudo make install

Détecter le lecteur

If everything worked out, switch to the examples folder and see if you can find the PN532 and wait for an appropriate tag:

  cd examples
  Kevins-Mac-mini:examples kevin$ ./nfc-poll
  /Users/kevin/libnfc-1.6.0-rc1/examples/.libs/nfc-poll uses libnfc 1.6.0-rc1 (r1326)
  NFC reader: pn532_uart:/dev/tty.usbserial-FTE5WWPB - PN532 v1.6 (0x07) opened
  NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations)
  ISO/IEC 14443A (106 kbps) target:
      ATQA (SENS_RES): 00  04  
         UID (NFCID1): 3e  b9  6e  66  
         SAK (SEL_RES): 08

There are some dependencies to get libnfc running, but since it isn't an Adafruit project and we can't really support it directly ourselves, you will probably have better luck looking at the libnfc forums for Mac support. There are a few active users developping on the Mac. https://learn.adafruit.com/adafruit-pn532-rfid-nfc/libnfc


Source: PN532 RFID/NFC Breakout and Shield créé par LadyAda pour AdaFruit Industries. Crédit [www.adafruit.com AdaFruit Industries]

Traduit par Meurisse D. pour MCHobby.be

Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.