projects
/
Biblio-RFID.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4097fd6
)
create log file with date,tag,number
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Fri, 3 Sep 2010 12:37:10 +0000
(14:37 +0200)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Fri, 3 Sep 2010 12:37:10 +0000
(14:37 +0200)
scripts/scan.pl
patch
|
blob
|
history
diff --git
a/scripts/scan.pl
b/scripts/scan.pl
index
ec61fd5
..
dd281a7
100755
(executable)
--- a/
scripts/scan.pl
+++ b/
scripts/scan.pl
@@
-12,11
+12,13
@@
use Biblio::RFID::RFID501;
my $loop = 0;
my $reader;
my $debug = 0;
my $loop = 0;
my $reader;
my $debug = 0;
+my $log;
GetOptions(
'loop!' => \$loop,
'reader=s', => \$reader,
'debug+' => \$debug,
GetOptions(
'loop!' => \$loop,
'reader=s', => \$reader,
'debug+' => \$debug,
+ 'log=s' => \$log,
) || die $!;
my $rfid = Biblio::RFID::Reader->new( $reader );
) || die $!;
my $rfid = Biblio::RFID::Reader->new( $reader );
@@
-33,20
+35,36
@@
sub tag {
;
}
;
}
+my $saved;
+
+sub iso_date {
+ my @t = localtime(time);
+ return sprintf "%04d-%02d-%02dT%02d:%02d:%02d", $t[5]+1900,$t[4]+1,$t[3],$t[2],$t[1],$t[0];
+}
+
+sub log_tag {
+ my $tag = shift;
+ return if $saved->{tag};
+ my $hash = Biblio::RFID::RFID501->to_hash( $rfid->blocks($tag) );
+ open(my $fh, '>>', $log) || die "$log: $!";
+ print $fh iso_date,",$tag,", $hash->{content}, "\n";
+ close($fh);
+}
+
do {
my @visible = $rfid->tags(
enter => sub {
my $tag = shift;
do {
my @visible = $rfid->tags(
enter => sub {
my $tag = shift;
- print
localtime().
" enter ", tag($tag);
-
+ print
iso_date,
" enter ", tag($tag);
+ log_tag $tag;
},
leave => sub {
my $tag = shift;
},
leave => sub {
my $tag = shift;
- print
localtime().
" leave ", tag($tag);
+ print
iso_date,
" leave ", tag($tag);
},
);
},
);
- warn
localtime().
" visible: ",join(' ',@visible),"\n";
+ warn
iso_date,
" visible: ",join(' ',@visible),"\n";
sleep 1;
sleep 1;