summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2005-10-22 17:55:57 +0000
committerlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2005-10-22 17:55:57 +0000
commit09a3dd030ddac3875b865be72e91d8326367dd4c (patch)
treed9793c67e635f4fc4475c3dda03bf72c6b2310d2
parentcd00f34b3bd74848b4a08e48ac39ec63bdb29409 (diff)
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
-rw-r--r--include/rfid/rfid_protocol_mifare_ul.h9
-rw-r--r--rfid_proto_mifare_ul.c21
2 files changed, 21 insertions, 9 deletions
diff --git a/include/rfid/rfid_protocol_mifare_ul.h b/include/rfid/rfid_protocol_mifare_ul.h
index 34d246a..6cdec22 100644
--- a/include/rfid/rfid_protocol_mifare_ul.h
+++ b/include/rfid/rfid_protocol_mifare_ul.h
@@ -1,6 +1,15 @@
#ifndef _RFID_PROTOCOL_MFUL_H
#define _RFID_PROTOCOL_MFUL_H
+
+#define MIFARE_UL_CMD_WRITE 0xA2
+#define MIFARE_UL_CMD_READ 0x30
+
+#define MIFARE_UL_RESP_ACK 0x0a
+#define MIFARE_UL_RESP_NAK 0x00
+
+#define MIFARE_UL_PAGE_MAX 15
+
struct rfid_protocol rfid_protocol_mful;
#endif
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 <rfid/rfid.h>
#include <rfid/rfid_protocol.h>
#include <rfid/rfid_layer2.h>
-//#include <rfid/rfid_layer2_iso14443b.h>
+#include <rfid/rfid_protocol_mifare_ul.h>
//#include <rfid/rfid_asic.h>
//#include <rfid/rfid_reader.h>
@@ -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;
}
personal git repositories of Harald Welte. Your mileage may vary