Code Monkey home page Code Monkey logo

Comments (8)

alranel avatar alranel commented on August 19, 2024 1

(By the way, congratulations for the code quality of CIE-PN532. It's nicely written)

from cie-pn532.

BrightSoul avatar BrightSoul commented on August 19, 2024

Was this library tested only with the Adafruit module?

Indeed. Looking at your log, it seem a few commands get sent correctly which leads me to think the Adafruit library is working fine with this module as well. However, it fails here, when reading the second page of data from the EF_DH elementary file. It's hard to say what the problem might be since I don't own a CIE nor that module at the present time. My first guess is the NFC module is not able seek into an elementary file but I cannot tell for sure right now.

My advice is to use the low-level library from this specific vendor. The cie-PN532 project abstracts all calls to the vendor library by using the cie_Nfc base class, so a new implementation of that class should be made, following the example of the cie_Nfc_Adafruit specialized class.

In the meantime, try commenting out line #61 in the cie-ReadAll.ino sketch which will exclude reads from the EF_DH elementary file, and run it again to see whether subsequent reads work or not.

from cie-pn532.

alranel avatar alranel commented on August 19, 2024

Thank you for the quick answer! I tried commenting line 61 and this is what I get:

Found chip PN532
Firmware ver. 1.6
PN53x initialized, waiting for a CIE card...
Tag number: 1
Command (success): 0x00 0xA4 0x04 0x0C 0x0D 0xA0 0x00 0x00 0x00 0x30 0x80 0x00 0x00 0x00 0x09 0x81 0x60 0x01
Command (success): 0x00 0xA4 0x00 0x0C 0x02 0x3F 0x00
Command (success): 0x00 0xA4 0x02 0x0C 0x02 0xD0 0x03
Command (success): 0x00 0xB1 0x00 0x00 0x04 0x54 0x02 0x00 0x00 0x0E
EF_SN_ICC (12 bytes, 640 ms) [12 OCTETS STRIPPED]
We have 1286 bytes of memory left
Command (success): 0x00 0xB1 0x00 0x1D 0x04 0x54 0x02 0x00 0x21 0x06
Command (success): 0x00 0xB1 0x00 0x1D 0x04 0x54 0x02 0x00 0x25 0x06
Command (success): 0x00 0xB1 0x00 0x1D 0x04 0x54 0x02 0x00 0x29 0x06
Command (success): 0x00 0xB1 0x00 0x1D 0x04 0x54 0x02 0x00 0x2D 0x06
Command (success): 0x00 0xB1 0x00 0x1D 0x04 0x54 0x02 0x00 0x31 0x06
Command (success): 0x00 0xB1 0x00 0x1D 0x04 0x54 0x02 0x00 0x35 0x06
Command (success): 0x00 0xB1 0x00 0x1D 0x04 0x54 0x02 0x00 0x39 0x06
Unknown error 0x00 0x00
Command (failure): 0x00 0xB1 0x00 0x1D 0x04 0x54 0x02 0x00 0x00 0x3F
Couldn't fetch the elementary file content
Error reading EF_ATR
We have 1286 bytes of memory left
Command (success): 0x00 0xA4 0x04 0x0C 0x0D 0xA0 0x00 0x00 0x00 0x30 0x80 0x00 0x00 0x00 0x09 0x81 0x60 0x01
Command (success): 0x00 0xA4 0x04 0x0C 0x06 0xA0 0x00 0x00 0x00 0x00 0x39
Command (success): 0x00 0xB1 0x00 0x01 0x04 0x54 0x02 0x00 0x00 0x0E
EF_ID_Servizi (12 bytes, 458 ms) [12 OCTETS STRIPPED]
We have 1286 bytes of memory left
Unknown error 0x03 0xAE
Command (failure): 0x00 0xB1 0x00 0x04 0x04 0x54 0x02 0x00 0x08 0xE7
Couldn't fetch the elementary file content
Error reading EF_Int_Kpub
We have 1302 bytes of memory left
Unknown error 0x03 0xAE
Command (failure): 0x00 0xB1 0x00 0x05 0x04 0x54 0x02 0x00 0x08 0xE7
Couldn't fetch the elementary file content
Error reading EF_Servizi_Int_Kpub
We have 1302 bytes of memory left
EF_SOD
Command (success): 0x00 0xB1 0x00 0x06 0x04 0x54 0x02 0x00 0x00 0x03
Command (success): 0x00 0xB1 0x00 0x06 0x04 0x54 0x02 0x00 0x01 0x03
Command (success): 0x00 0xB1 0x00 0x06 0x04 0x54 0x02 0x00 0x02 0x04
Sorry, we don't support content lengths greater than 2048
EF_SOD length was 2111
We have 1302 bytes of memory left

Read complete, you can remove the card now

(I stripped the output of EF_ID_Servizi as this is a real card)

from cie-pn532.

BrightSoul avatar BrightSoul commented on August 19, 2024

Ok, thanks. I'll do some testing as soon as I get my own CIE and see if this is reproducible on the Adafruit module as well. I've just learned it has become available in my Common.
The cie-PN532 library was tested on a specimen card, do you know of any differences with the real thing?

from cie-pn532.

alranel avatar alranel commented on August 19, 2024

I'm not aware of any difference (maybe @fottavi is?) but I'll try to test with a fake card myself.

from cie-pn532.

fottavi avatar fottavi commented on August 19, 2024

Hello. The specimen card contain test certificates from a test Certification Authority, but for the rest they are equal by all means to real ones.

from cie-pn532.

alranel avatar alranel commented on August 19, 2024

I tested with a specimen card and I confirm I get the same errors as above, so the issue seems related to the hardware I'm using. Since it's a pretty common alternative to the Adafruit module (and it's also quite cheaper and, last but not least, it has a smaller form factor) it would be nice to support it!

from cie-pn532.

alranel avatar alranel commented on August 19, 2024

I did some further investigation.
When calling read_EF_DH(), readBinaryContent() is called with contentLength = 564 (I guess that's the length calculated by the BER parser). The library tries to read it in multiple chunks according to the PAGE_LENGTH constant, whose default is 228 (0xE4). However, the PN532_PACKBUFFSIZ constant in Adafruit_PN532 is set to 64. (Incidentally, that library does not perform a length check so I proposed one in adafruit/Adafruit-PN532#51)
Lowering PAGE_LENGTH to 52 makes CIE-PN532 succeed at reading all values from the card.

Then I tried to raise both PAGE_LENGTH and PN532_PACKBUFFSIZ as much as I could, and found out that the maximum working combination is {128, 139}. Above those values I either get Arduino crashes or wrong length checks. (Incidentally, 128 is 0x80 which is used for computing preambleOctets... could the two things be related?)

What do you think, @BrightSoul? A few more thoughts:

  1. Since your modified https://github.com/BrightSoul/Adafruit-PN532 library contains an unaltered PN532_PACKBUFFSIZ, how are you succeeding at all at reading EF.DH? This does not seem to be hardware-dependent. Are you sure you didn't change that value in your local copy?
  2. Where is the proper value for PN532_PACKBUFFSIZ documented? I couldn't find it in the NXP PN532 documentation, and it looks like the Adafruit module and the Elechouse one (the one I'm using) carry the same chip. Does yours show the 1.6 version number?

from cie-pn532.

Related Issues (7)

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.