Implement mifare_ultralight_write() using macros.
Update issue 58 I can't reproduce this bug, but saw that the mifare_ultralight_write() was implemented in an old-school way. I updated the code so that you should have better traces when compiling the library in debug mode and running: romain@marvin ~/Projects/libfreefare % cutter -n test_mifare_ultralight_write test ===> 0000 30 07 |0. | <=== 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| ===> 0000 a2 07 12 34 56 78 |...4Vx | ===> 0000 30 07 |0. | <=== 0000 12 34 56 78 00 00 00 00 00 00 00 00 00 00 00 00 |.4Vx............| ===> 0000 a2 07 aa 55 00 ff |...U.. | ===> 0000 30 07 |0. | <=== 0000 aa 55 00 ff 00 00 00 00 00 00 00 00 00 00 00 00 |.U..............| ===> 0000 a2 07 00 00 00 00 |...... | ===> 0000 30 07 |0. | <=== 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| . Finished in 0,548238 seconds (total: 0,069079 seconds) 1 test(s), 12 assertion(s), 0 failure(s), 0 error(s), 0 pending(s), 0 omission(s), 0 notification(s) 100% passed
This commit is contained in:
parent
b6cbeb2e20
commit
573fc1b778
1 changed files with 7 additions and 9 deletions
|
@ -221,16 +221,14 @@ mifare_ultralight_write (MifareTag tag, const MifareUltralightPageNumber page, c
|
||||||
ASSERT_MIFARE_ULTRALIGHT (tag);
|
ASSERT_MIFARE_ULTRALIGHT (tag);
|
||||||
ASSERT_VALID_PAGE (tag, page, true);
|
ASSERT_VALID_PAGE (tag, page, true);
|
||||||
|
|
||||||
uint8_t cmd[6];
|
BUFFER_INIT (cmd, 6);
|
||||||
cmd[0] = 0xA2;
|
BUFFER_INIT (res, 1);
|
||||||
cmd[1] = page;
|
|
||||||
memcpy (cmd + 2, data, sizeof (MifareUltralightPage));
|
|
||||||
|
|
||||||
size_t n;
|
BUFFER_APPEND (cmd, 0xA2);
|
||||||
if (!(nfc_initiator_transceive_bytes (tag->device, cmd, sizeof (cmd), NULL, &n))) {
|
BUFFER_APPEND (cmd, page);
|
||||||
errno = EIO;
|
BUFFER_APPEND_BYTES (cmd, data, sizeof (MifareUltralightPage));
|
||||||
return -1;
|
|
||||||
}
|
ULTRALIGHT_TRANSCEIVE (tag, cmd, res);
|
||||||
|
|
||||||
/* Invalidate page in cache */
|
/* Invalidate page in cache */
|
||||||
MIFARE_ULTRALIGHT(tag)->cached_pages[page] = 0;
|
MIFARE_ULTRALIGHT(tag)->cached_pages[page] = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue