From 41257cf2d2e318df3c4015969f48fdc08d602560 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 2 Sep 2010 18:45:38 +0200 Subject: [PATCH] cleanup programming script --- scripts/program.pl | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/program.pl b/scripts/program.pl index 443e475..7dbfc7f 100755 --- a/scripts/program.pl +++ b/scripts/program.pl @@ -11,24 +11,25 @@ use Biblio::RFID::RFID501; my $reader; my $afi; +my $debug = 0; GetOptions( 'reader=s', => \$reader, 'afi=i', => \$afi, + 'debug+', => \$debug, ) || die $!; my ( $sid, $content ) = @ARGV; die "usage: $0 [--reader regex_filter] [--afi 214] E0_RFID_SID [barcode]\n" unless $sid && ( $content | $afi ); -my @rfid = Biblio::RFID::Reader->available( $reader ); +my $rfid = Biblio::RFID::Reader->new( $reader ); +$Biblio::RFID::debug = $debug; -foreach my $rfid ( @rfid ) { - my $visible = $rfid->scan; - foreach my $tag ( keys %$visible ) { - next unless $tag eq $sid; - warn "PROGRAM $tag with $content\n"; - $rfid->write_blocks( $tag => Biblio::RFID::RFID501->from_hash({ content => $content }) ); - $rfid->write_afi( $tag => chr($afi) ) if $afi; - } +foreach my $tag ( $rfid->tags ) { + warn "visible $tag\n"; + next unless $tag eq $sid; + warn "PROGRAM $tag with $content\n"; + $rfid->write_blocks( $tag => Biblio::RFID::RFID501->from_hash({ content => $content }) ); + $rfid->write_afi( $tag => chr($afi) ) if $afi; } -- 2.20.1