summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2006-10-08 01:05:50 +0000
committerlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2006-10-08 01:05:50 +0000
commit6e87a007525b313dcf2da194977bb1abdf62026f (patch)
tree0d4d3d8947bffe5fd69cede516241e923f938276 /utils
parent1db4b3b435b8e79c36ac12515152168a45e5ac8e (diff)
- fix segfault during rfid_scan()
- add accessor functions for protocol and layer2 names - print l2 and proto name + uid after successful scan git-svn-id: https://svn.gnumonks.org/trunk/librfid@1899 e0336214-984f-0b4b-a45f-81c69e1f0ede
Diffstat (limited to 'utils')
-rw-r--r--utils/librfid-tool.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/utils/librfid-tool.c b/utils/librfid-tool.c
index c96f948..e1270f1 100644
--- a/utils/librfid-tool.c
+++ b/utils/librfid-tool.c
@@ -330,6 +330,24 @@ static int l2_by_name(const char *name)
return -1;
}
+static void do_scan(void)
+{
+ int rc;
+ printf("scanning for RFID token...\n");
+ rc = rfid_scan(rh, &l2h, &ph);
+ if (rc >= 2) {
+ unsigned char uid_buf[16];
+ unsigned int uid_len = sizeof(uid_buf);
+ rfid_layer2_getopt(l2h, RFID_OPT_LAYER2_UID, &uid_buf,
+ &uid_len);
+ printf("Layer 2 success (%s): %s\n", rfid_layer2_name(l2h),
+ hexdump(uid_buf, uid_len));
+ }
+ if (rc >= 3) {
+ printf("Protocol success (%s)\n", rfid_protocol_name(ph));
+ }
+}
+
static void help(void)
{
printf( " -s --scan\n"
@@ -368,8 +386,7 @@ int main(int argc, char **argv)
case 's':
if (reader() < 0)
exit(1);
- printf("scanning for RFID token...\n");
- i = rfid_scan(rh, &l2h, &ph);
+ do_scan();
exit(0);
break;
case 'p':
personal git repositories of Harald Welte. Your mileage may vary