Проблемы при работе с тегами Desfire EV1 и nfcpy - PullRequest
0 голосов
/ 15 мая 2019

Попытка записать запись ndef в тег Desfire EV1 не работает.Я полагаю, что это потому, что тег не отформатирован, однако, когда я пытаюсь сделать это (с tagtool.py), я получаю ошибку.

Я использую Adafruit PN532, подключенный к Raspberry Pi 3B + через мини-UART (S0 вместо AMA0, так как мне нужен Bluetooth для чего-то другого).

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

Ответы [ 2 ]

0 голосов
/ 07 июня 2019

Сценарий tagtool.py может форматировать любой тег NFC Forum Type 1/2/3/4. Эти теги снабжены информацией управления NDEF, которая определяется спецификациями тегов NFC Forum. Mifare Desfire EV1 - это тег с поддержкой нескольких приложений с идентификаторами приложений (AID) и связанными файлами. Для хранения NDEF должен присутствовать определенный AID с определенной файловой структурой. Обычно это делается с помощью инструментов производителя.

0 голосов
/ 17 мая 2019

При просмотре источника 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
...