无法使用Python的nfcpy库将Type2Tag格式化为NDEF

时间:2016-03-08 01:42:36

标签: python nfc rfid ndef

我正在使用nfcpy库来尝试将NDEF记录写入Type2Tag。显然这些标签不兼容NDEF。 nfcpy提供format()函数,该函数应该使标记NDEF兼容,但它不起作用。有没有办法让这些标签与NDEF兼容?或者我有错误的标签?我所知道的关于我的标签的是 1K卡。 以下是我尝试格式化标记的方法。

Python文件:

import nfc
import nfc.ndef

def connected(tag):
    print "format:", tag.format() # format tag to make it NDEF compatible
    print "on card:", tag.ndef.message.pretty() if tag.ndef else "sorry, no NDEF"
    return False

if __name__ == "__main__":
    clf = nfc.ContactlessFrontend("usb:072f:2200")
    print clf
    clf.connect(rdwr={"on-connect": connected})

输出:

ACS ACR122U on usb:002:012
format: False
on card: sorry, no NDEF

1 个答案:

答案 0 :(得分:2)

我在这里和那里都有格式()函数也存在一些问题。

有些事情要尝试:

  1. 看看您是否可以使用支持NFC的Android手机和TagWriter应用来格式化您的代码。此应用程序由NFC芯片制造商之一设计。如果这样做不行,那就什么都不能。

  2. 如果TagWriter可以格式化您的卡,但nfcpy不能,请再调试一下。我在nfc / tag / tt2.py中挖掘,如果以下行返回False,则返回False:if self.ndef and self.ndef.is_writeable: 因此,请务必查看tag.ndeftag.ndef.is_writeable以获取更多信息。