#include <librfid/rfid_protocol_mifare_classic.h>
#include <librfid/rfid_protocol_mifare_ul.h>
+static const char *
+hexdump(const void *data, unsigned int len)
+{
+ static char string[1024];
+ unsigned char *d = (unsigned char *) data;
+ unsigned int i, left;
+
+ string[0] = '\0';
+ left = sizeof(string);
+ for (i = 0; len--; i += 3) {
+ if (i >= sizeof(string) -4)
+ break;
+ snprintf(string+i, 4, " %02x", *d++);
+ }
+ return string;
+}
+
static struct rfid_reader_handle *rh;
static struct rfid_layer2_handle *l2h;
static struct rfid_protocol_handle *ph;
return -1;
}
- sleep(2);
-
printf("opening layer2 handle\n");
l2h = rfid_layer2_init(rh, RFID_LAYER2_ISO14443A);
//l2h = rfid_layer2_init(rh, RFID_LAYER2_ISO14443B);
if (rv < 0)
return rv;
- printf("%s\n", rfid_hexdump(ret, rlen));
+ printf("%d: [%s]\n", rlen, hexdump(ret, rlen));
return 0;
}
if (rv < 0)
return rv;
- printf("%d: [%s]\n", rlen, rfid_hexdump(ret, rlen));
+ printf("%d: [%s]\n", rlen, hexdump(ret, rlen));
return 0;
}
return rv;
/* FIXME: parse response */
- printf("%s\n", rfid_hexdump(resp, rlen));
+ printf("%s\n", hexdump(resp, rlen));
return 0;
}
return rv;
/* FIXME: parse response */
- printf("%s\n", rfid_hexdump(resp, rlen));
+ printf("%s\n", hexdump(resp, rlen));
return 0;
}
if (ret < 0)
return ret;
- printf("Page 0x%x: %s\n", i, rfid_hexdump(buf, 4));
+ printf("Page 0x%x: %s\n", i, hexdump(buf, 4));
}
return 0;
}
if (ret < 0)
return ret;
- printf("Page 0x%x: %s\n", i, rfid_hexdump(buf, len));
+ printf("Page 0x%x: %s\n", i, hexdump(buf, len));
}
return 0;
}