From 09a3dd030ddac3875b865be72e91d8326367dd4c Mon Sep 17 00:00:00 2001 From: laforge Date: Sat, 22 Oct 2005 17:55:57 +0000 Subject: mifare ultraligh have pages 0-15, not only 0-7 git-svn-id: https://svn.gnumonks.org/trunk/librfid@1552 e0336214-984f-0b4b-a45f-81c69e1f0ede --- rfid_proto_mifare_ul.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'rfid_proto_mifare_ul.c') diff --git a/rfid_proto_mifare_ul.c b/rfid_proto_mifare_ul.c index 3fec95b..1d80702 100644 --- a/rfid_proto_mifare_ul.c +++ b/rfid_proto_mifare_ul.c @@ -28,7 +28,7 @@ #include #include #include -//#include +#include //#include //#include @@ -36,9 +36,6 @@ #include "rfid_iso14443_common.h" -#define MIFARE_UL_CMD_WRITE 0xA2 -#define MIFARE_UL_CMD_READ 0x30 - /* FIXME */ #define MIFARE_UL_READ_FWT 100 #define MIFARE_UL_WRITE_FWT 100 @@ -52,7 +49,7 @@ mful_read(struct rfid_protocol_handle *ph, unsigned int page, unsigned char tx[2]; int ret; - if (page > 7) + if (page > MIFARE_UL_PAGE_MAX) return -EINVAL; tx[0] = MIFARE_UL_CMD_READ; @@ -78,12 +75,14 @@ mful_write(struct rfid_protocol_handle *ph, unsigned int page, { unsigned int i; unsigned char tx[6]; - unsigned char rx[1]; - unsigned int rx_len; + unsigned char rx[10]; + unsigned int rx_len = sizeof(rx); int ret; - if (tx_len != 4 || page > 7) +#if 0 + if (tx_len != 4 || page > MIFARE_UL_PAGE_MAX) return -EINVAL; +#endif tx[0] = MIFARE_UL_CMD_WRITE; tx[1] = page & 0xff; @@ -94,7 +93,11 @@ mful_write(struct rfid_protocol_handle *ph, unsigned int page, ret = ph->l2h->l2->fn.transcieve(ph->l2h, tx, sizeof(tx), rx, &rx_len, MIFARE_UL_WRITE_FWT, 0); - /* FIXME:look at RX, check for ACK/NAK */ + if (ret < 0) + return ret; + + if (rx[0] != MIFARE_UL_RESP_ACK) + return -EIO; return ret; } -- cgit v1.2.3