summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2008-01-27 02:15:48 +0000
committerlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2008-01-27 02:15:48 +0000
commitc203de04bd740e324b06615b98932ac9fa734ed2 (patch)
tree42801098aab2fdd4e2a63af47035c0d817b60ed6 /utils
parent6b2db45060b26cc4e42ca6130f236596f9a02c82 (diff)
* 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
Diffstat (limited to 'utils')
-rw-r--r--utils/librfid-tool.c37
1 files changed, 33 insertions, 4 deletions
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':
personal git repositories of Harald Welte. Your mileage may vary