NFC data transfer too slow using nfcpy

Bug #1517483 reported by NFC_code
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nfcpy
Invalid
Undecided
Unassigned

Bug Description

Hi guys,
I have written a python application, based on nfcpy, that transfers a binary file onto a type 2 tag.
So far everything worked fine besides the transfer speed. On windows the transfer rate is around 200Bytes/second and on Linux slightly better, 280Bytes/second whereas I would expect a closer values to the theoretical value of 800Bytes/second.
I have stripped completely my python script and my Tag code, so basically I can't blame any of the two applications.
When debugging I do see that the messages take quite a while to write, around 0.8 seconds per record, which is quite a lot. My records have 150 bytes.
So at this point I am inclined to blame the USB driver or the nfcpy which are the only black boxes in this setup.
I have used two different card readers, the Sony S380 and the ACR122, the results on the Sony are slightly better, maybe because it uses a newer version of the PN5XX (PN533) and the ACR122 uses the PN532.
Regarding the drivers I have been using the native drivers, which don't work, and the lisbusb v1.2.6.0, libusbkcv3.0.7.0 which give the above results.
On Linux, the performance increases a bit, to around 250bytes/second, still far from the intended speed.
Does someone have an idea how I can improve the transfer rate on my setup?

my code:

...

if __name__ == '__main__':

...

    msg = None
    with nfc.ContactlessFrontend('usb') as clf:
        print('\nTouch an nfctag containing an ndef message.')
        nfctag = None
        while not nfctag or not nfctag.ndef:
            def onconnect(tag):
                print(tag);
                return False
            def onrelease(tag):
                sys.exit()
            nfctag = clf.connect(rdwr={'on-connect': onconnect, 'on-release': onrelease})
            print(nfctag.ndef.message.type)
            if (packageDebugEnabled):
                printmessage(nfctag.ndef.message)

  ...

        with open(BinaryFile, "rb") as binaryFile:
            while (transfer == TRANSFER_ONGOING):
               ...
                if (readyForNextPackage):
                   ...
                    for chunk in iter(lambda: binaryFile.read(dataChuckSize), b""):
...
                        chunky = list(packageTransferMsgId) + list(CardReaderTag) + list(packagesSizeStringLSB) + list(packagesSizeStringMSB) + list(formattedPackageNumber) + list(chunk) + emptyList

...

                        str1 = ''.join(package)
                        record0 = nfc.ndef.Record(mimeType, '', b'{}'.format(str1))
                        nfctag.ndef.message = nfc.ndef.Message(record0)
   ...
                    if nfctag.ndef.has_changed:
                        message = nfctag.ndef.message
   ....

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) wrote :

Can you please measure transfer speed with tagtool.py. For read use "tagtool.py -d nfc.tag --reltime -v" and calculate the data rate from a number of consecutive read ops. Similar for write with "tagtool.py load <binary-ndef-file>".

With an NTAG216 I get about 670 byte/sec for reading and 435 byte/sec for writing.

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) wrote :

It is unclear how the issue would be caused by a bug in nfcpy and no further information was provided by the submitter.

Changed in nfcpy:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.