trapshyu
Posts: 3
Joined: Thu Feb 08, 2018 8:37 am

Need the PN532 Module to only read and output the UID of the smart card

Thu Mar 22, 2018 1:58 pm

Hello everyone, I would like to begin with telling you that this is my first foray into using raspberry pi, nfc modules, linux commandline, and basically any kind of programming whatsoever.
I would also like to say this beforehand that if this is the wrong place to have posted about this particular problem, or if I have rambled on too much providing unnecessary information, do forgive me and try helping me anyway.

I am currently working on a project from my employer to develop a smart card reader for the company's employees' ID cards using the raspberry pi, since he himself (head of the IT dept.) is a raspberry pi enthusiast. Fast fowarding to what I have achieved so far-

I have connected the PN532 (https://www.sunfounder.com/pn532-nfc.html) to my Raspberry Pi Zero via UART interface and have successfully been able to read the smart cards used by the company through it. The following is the output I recieve-

Code: Select all

[email protected]:~/libnfc/examples $ sudo ./nfc-poll
/home/pi/libnfc/examples/.libs/lt-nfc-poll uses libnfc libnfc-1.7.1-191-g216145f
NFC reader: PN532 board via UART 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): 03  44  
       UID (NFCID1): 04  08  67  f2  6d  3f  80  
      SAK (SEL_RES): 20  
                ATS: 75  77  81  02  80  
Waiting for card removing...nfc_initiator_target_is_present: Target Released
done.
Now what basically is happening here is that the PN532 is reading all the data stored on the smart card, but what my employer desires is that the PN532 read and output only the UID. Where the output on the terminal should look something like this-

!![the UID of the particular smart card]!!

And this last step is where I am stuck at. PLEASE HELP!

User avatar
topguy
Posts: 4914
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Need the PN532 Module to only read and output the UID of the smart card

Thu Mar 22, 2018 11:27 pm

Do you know C programming ? If not, the minimum is to read about the printf() that prints stuff. And then change the existing "printf" calls in the program to fit your needs.

Also maybe look at the better commented example: https://github.com/nfc-tools/libnfc/blo ... example1.c

trapshyu
Posts: 3
Joined: Thu Feb 08, 2018 8:37 am

Re: Need the PN532 Module to only read and output the UID of the smart card

Fri Mar 23, 2018 8:48 am

topguy wrote: Do you know C programming ? If not, the minimum is to read about the printf() that prints stuff. And then change the existing "printf" calls in the program to fit your needs.

Also maybe look at the better commented example: https://github.com/nfc-tools/libnfc/blo ... example1.c
Yes I can handle some C programming, but I am so far unable to figure out which file it is that I need to edit, could you please shine some light in that regard?

trapshyu
Posts: 3
Joined: Thu Feb 08, 2018 8:37 am

Re: Need the PN532 Module to only read and output the UID of the smart card

Fri Mar 23, 2018 9:30 am

trapshyu wrote:
Fri Mar 23, 2018 8:48 am
topguy wrote: Do you know C programming ? If not, the minimum is to read about the printf() that prints stuff. And then change the existing "printf" calls in the program to fit your needs.

Also maybe look at the better commented example: https://github.com/nfc-tools/libnfc/blo ... example1.c
Yes I can handle some C programming, but I am so far unable to figure out which file it is that I need to edit, could you please shine some light in that regard?
Okay update: I did figure out which .c file needs editing via the github link that you @topguy posted (thank you for that), now I just need to figure the code to replace the existing printf() code to make it appear instead of like this -

Code: Select all

 ATQA (SENS_RES): 03  44  
       UID (NFCID1): 04  08  67  f2  6d  3f  80  
      SAK (SEL_RES): 20  
                ATS: 75  77  81  02  80  
to like this-

Code: Select all

UID (NFCID1): !!040867f26d3f80!!

kafffee
Posts: 3
Joined: Tue Jan 30, 2018 4:30 pm

Re: Need the PN532 Module to only read and output the UID of the smart card

Sun Oct 14, 2018 10:16 am

Hi there,

I have a similar problem. Even though I know how to replace the printf methods to meet my needs the program exits immediately after its done with its output and I need to read.more than one tag on top

Return to “Other projects”