简体   繁体   English

使用Desfire EV1标签和nfcpy时出现问题

[英]Problems working with Desfire EV1 tags and nfcpy

Trying to write an ndef record to a Desfire EV1 tag isn't working. 试图将一个ndef记录写入Desfire EV1标签是行不通的。 I believe this is because the tag isn't formatted, however, when I try to do that (with tagtool.py) I get an error. 我相信这是因为标签没有格式化,但是,当我尝试这样做时(使用tagtool.py)我收到错误。

I'm using an Adafruit PN532 attached to a Raspberry Pi 3 B+ via mini-UART (S0 instead of AMA0 as I need Bluetooth for something else). 我正在使用通过mini-UART连接到Raspberry Pi 3 B +的Adafruit PN532(S0而不是AMA0,因为我需要蓝牙用于其他东西)。

python tagtool.py --device tty:S0 format
No handlers could be found for logger "nfc.llcp.sec"
[nfc.clf] searching for reader on path tty:S0
[nfc.clf] using PN532v1.6 at /dev/ttyS0
** waiting for a tag **
[nfc.tag.tt4] no ndef capability file
[nfc.tag.tt4] format error: no ndef or not writeable
Sorry, I could not format this tag.

python tagtool.py --device tty:S0 -v
No handlers could be found for logger "nfc.llcp.sec"
[nfc.clf] searching for reader on path tty:S0
[nfc.clf] using PN532v1.6 at /dev/ttyS0
** waiting for a tag **
Type4ATag MIU=63 FWT=0.077329
[nfc.tag.tt4] no ndef capability file
Memory Dump:
[nfc.tag.tt4] no ndef capability file

Python 2.7.13 (default, Sep 26 2018, 18:42:22)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import nfc
No handlers could be found for logger "nfc.llcp.sec"
>>> clf = nfc.ContactlessFrontend('tty:S0')
>>> tag = clf.connect(rdwr={'on-connect': lambda tag: False})
>>> print(tag)
Type4ATag MIU=63 FWT=0.077329
>>> print(tag.ndef)
None

Upon looking through the tagtool source it appears that only support for formatting type 1 and 3 tags have been added. 查看tagtool源后,似乎只添加了对格式化类型1和3标记的支持。

def format_tt1_tag(self, tag):
    if self.options.magic is not None:
        tag.write_byte(8, self.options.magic)
    if self.options.ver is not None:
        tag.write_byte(9, self.options.ver)
    if self.options.tms is not None:
        tag.write_byte(10, self.options.tms)
    if self.options.rwa is not None:
        tag.write_byte(11, self.options.rwa)

def format_tt2_tag(self, tag):
    pass

def format_tt3_tag(self, tag):
    attribute_data = tag.read_from_ndef_service(0)
    if self.options.ver is not None:
        attribute_data[0] = self.options.ver
    if self.options.nbr is not None:
        attribute_data[1] = self.options.nbr
    if self.options.nbw is not None:
        attribute_data[2] = self.options.nbw
    if self.options.max is not None:
        attribute_data[3:5] = struct.pack(">H", self.options.max)
    if self.options.rfu is not None:
        attribute_data[5:9] = 4 * [self.options.rfu]
    if self.options.wf is not None:
        attribute_data[9] = self.options.wf
    if self.options.rw is not None:
        attribute_data[10] = self.options.rw
    if self.options.len is not None:
        attribute_data[11:14] = struct.pack(">I", self.options.len)[1:]
    if self.options.crc is not None:
        attribute_data[14:16] = struct.pack(">H", self.options.crc)
    else:
        checksum = sum(attribute_data[:14])
        attribute_data[14:16] = struct.pack(">H", checksum)
    tag.write_to_ndef_service(attribute_data, 0)

def format_tt4_tag(self, tag):
    pass

The tagtool.py script can format any NFC Forum Type 1/2/3/4 Tag. tagtool.py脚本可以格式化任何NFC论坛类型1/2/3/4标签。 Those tags are equipped with NDEF management information that is defined by the NFC Forum tag specifications. 这些标签配备了由NFC论坛标签规范定义的NDEF管理信息。 Mifare Desfire EV1 is a multi-application capable tag with application identifiers (AID) and associated files. Mifare Desfire EV1是一个支持多应用程序的标签,带有应用程序标识符(AID)和相关文件。 For NDEF storage a specific AID must be present with a defined file structure. 对于NDEF存储,必须存在具有已定义文件结构的特定AID。 This is usually done with manufacturer tools. 这通常使用制造商工具完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM