From c203de04bd740e324b06615b98932ac9fa734ed2 Mon Sep 17 00:00:00 2001 From: laforge Date: Sun, 27 Jan 2008 02:15:48 +0000 Subject: * improve scanning support: ** first try REQA/HLTA/REQA/HLTA until no more tags found ** then power off the field and start from the beginning again * add proper RF field on/off switching support to all readers * reduce timer to actual value, don't multiply by 10 * detect collisions during transceive_sf (ATQA) * make UID length depend on cascade level, not ATQA git-svn-id: https://svn.gnumonks.org/trunk/librfid@2056 e0336214-984f-0b4b-a45f-81c69e1f0ede --- utils/librfid-tool.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'utils') diff --git a/utils/librfid-tool.c b/utils/librfid-tool.c index 74f6128..dab7db3 100644 --- a/utils/librfid-tool.c +++ b/utils/librfid-tool.c @@ -260,12 +260,17 @@ static int l2_by_name(const char *name) return -1; } -static void do_scan(void) +static int do_scan(int first) { int rc; unsigned int size; unsigned int size_len = sizeof(size); + if (first) { + rh->reader->rf_power(rh, 0); + usleep(10*1000); + rh->reader->rf_power(rh, 1); + } printf("scanning for RFID token...\n"); rc = rfid_scan(rh, &l2h, &ph); if (rc >= 2) { @@ -283,6 +288,31 @@ static void do_scan(void) &size, &size_len) == 0) printf("Size: %u bytes\n", size); } + + return rc; +} + +static void do_endless_scan() +{ + int rc; + int first = 1; + + while (1) { + if (first) + putc('\n', stdout); + printf("==> doing %s scan\n", first ? "first" : "successive"); + rc = do_scan(first); + if (rc >= 3) { + printf("closing proto\n"); + rfid_protocol_close(ph); + } + if (rc >= 2) { + printf("closing layer2\n"); + rfid_layer2_close(l2h); + first = 0; + } else + first = 1; + } } #define OPTION_OFFSET 256 @@ -399,14 +429,13 @@ int main(int argc, char **argv) case 's': if (reader_init() < 0) exit(1); - do_scan(); + do_scan(0); exit(0); break; case 'S': if (reader_init() < 0) exit(1); - while (1) - do_scan(); + do_endless_scan(); exit(0); break; case 'p': -- cgit v1.2.3