added --debug flag (repeatable)
[Biblio-RFID.git] / scripts / scan.pl
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use Data::Dump qw(dump);
7 use Getopt::Long;
8 use lib 'lib';
9 use RFID::Biblio::Reader;
10 use RFID::Biblio::RFID501;
11
12 my $loop = 0;
13 my $reader;
14 my $debug = 0;
15
16 GetOptions(
17         'loop!'     => \$loop,
18         'reader=s', => \$reader,
19         'debug+'    => \$debug,
20 ) || die $!;
21
22 my $rfid = RFID::Biblio::Reader->new( $reader );
23 $RFID::Biblio::debug = $debug;
24
25 do {
26         my @visible = $rfid->tags;
27         foreach my $tag ( @visible ) {
28                 print $tag
29                         , " AFI: "
30                         , uc unpack('H2', $rfid->afi($tag))
31                         , " "
32                         , dump( RFID::Biblio::RFID501->to_hash( $rfid->blocks($tag) ) )
33                         , $/
34                         ;
35         }
36 } while $loop;