From 6e87a007525b313dcf2da194977bb1abdf62026f Mon Sep 17 00:00:00 2001 From: laforge Date: Sun, 8 Oct 2006 01:05:50 +0000 Subject: - 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 --- utils/librfid-tool.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'utils') 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': -- cgit v1.2.3