尝试将ndef记录写入Desfire EV1标签不起作用。我相信这是因为标记未格式化,但是,当我尝试使用tagtool.py进行标记时,会出现错误。
我正在使用通过mini-UART(S0代替AMA0,因为我需要蓝牙用于其他功能)连接到Raspberry Pi 3 B +的Adafruit PN532。
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
答案 0 :(得分:0)
在查看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
答案 1 :(得分:0)
tagtool.py
脚本可以格式化任何NFC论坛类型1/2/3/4标记。这些标签配备了由NFC论坛标签规范定义的NDEF管理信息。 Mifare Desfire EV1是一个具有多应用程序功能的标签,带有应用程序标识符(AID)和相关文件。对于NDEF存储,必须存在具有定义的文件结构的特定AID。这通常是使用制造商的工具完成的。