X-Git-Url: http://git.rot13.org/?p=Biblio-RFID.git;a=blobdiff_plain;f=scripts%2Fprogram.pl;fp=scripts%2Fprogram.pl;h=b0fc125eec1c1c2d26c5d1579d1fb10d29ab85a7;hp=45a06b3a524ed7c1bb995e1cde722f9fdbd11284;hb=6133210513a348cf98dbe7b6e0038968b5d0e02a;hpb=1621e8a8c09593b9de3ec28ec35b769be7f85ddb diff --git a/scripts/program.pl b/scripts/program.pl index 45a06b3..b0fc125 100755 --- a/scripts/program.pl +++ b/scripts/program.pl @@ -29,24 +29,27 @@ GetOptions( ) || die $!; my ( $sid, $content ) = @ARGV; -die "usage: $0 [--reader regex_filter] [--afi 214] [--type 1] E0_RFID_SID [barcode]\n" unless $sid && ( $content | $afi | $blank ); +die "usage: $0 [--reader regex_filter] [--afi 214] [--type 1] E0_RFID_SID [barcode]\n" unless $sid && ( $content || $afi || $blank ); $hash->{content} = $content if defined $content; my $rfid = Biblio::RFID::Reader->new( $reader ); $Biblio::RFID::debug = $debug; -foreach my $tag ( $rfid->tags ) { +foreach my $tag ( $rfid->tags, $sid ) { warn "visible $tag\n"; - next unless $tag eq $sid; - if ( grep { defined $_ } values $blank ) { +# next unless $tag eq $sid; + if ( grep { defined $_ } values %$blank ) { my $type = ( grep { $blank->{$_} } keys %$blank )[0]; warn "BLANK $type $tag\n"; $rfid->write_blocks( $tag => Biblio::RFID::RFID501->$type ); - } else { + } elsif ( $content ) { warn "PROGRAM $tag with $content\n"; $rfid->write_blocks( $tag => Biblio::RFID::RFID501->from_hash($hash) ); - $rfid->write_afi( $tag => chr($afi) ) if $afi; + } + if ( $afi ) { + warn "AFI $tag with $afi\n"; + $rfid->write_afi( $tag => chr($afi) ); } }