Fix mifare_classic_transfer() with some readers.

This commit is contained in:
Romain Tartiere 2011-02-13 12:50:41 +00:00
parent d9ed7f2c24
commit 7c8c818a08
2 changed files with 18 additions and 2 deletions

7
NEWS
View file

@ -1,4 +1,9 @@
Changes between 0.2.3 and 0.3.0 [XX xxx XXXX]
Changes between 0.3.0 and 0.3.1 [XX xxx XXXX]
*) Fix mifare_classic_transfer() for devices returning a 1 byte response on
success.
Changes between 0.2.3 and 0.3.0 [23 dec 2010]
*) Add support for ISO and AES authentication through
mifare_desfire_authenticate_iso() and mifare_desfire_authenticate_aes().

View file

@ -72,6 +72,8 @@
#include <freefare.h>
#include "freefare_internal.h"
#define MC_OK 0x0A
#define MC_AUTH_A 0x60
#define MC_AUTH_B 0x61
#define MC_READ 0x30
@ -478,7 +480,16 @@ mifare_classic_transfer (MifareTag tag, const MifareClassicBlockNumber block)
CLASSIC_TRANSCEIVE (tag, cmd, res);
return (BUFFER_SIZE (res) == 0) ? 0 : res[0];
/*
* Depending on the device we are using, on success, the TRANSFER command
* returns either no data (e.g. touchatag) or a 1 byte response, 0x0A,
* meaning that the action was performed correctly (e.g. Snapper Feeder,
* SCL 3711).
*/
if (!BUFFER_SIZE (res) || ((BUFFER_SIZE (res) == 1) && (res[0] = MC_OK)))
return 0;
else
return res[0];
}