X-Git-Url: http://git.rot13.org/?p=Biblio-RFID.git;a=blobdiff_plain;f=scripts%2Fprogram.pl;h=565bb2a178b0fa2648f354e2a2e1a3b75b130d1f;hp=ec33b889414ec40adb605d07c4539ce4289025a1;hb=c288a23cfbda56592eb77fdafb8bdf4f0bbc33fa;hpb=28e4aab986d5658c963db3cb53476f612053f8f6 diff --git a/scripts/program.pl b/scripts/program.pl index ec33b88..565bb2a 100755 --- a/scripts/program.pl +++ b/scripts/program.pl @@ -29,25 +29,31 @@ 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 ); +if ( $sid =~ m/.+,.+/ && ! defined $content ) { + ( $sid, $content ) = split(/,/, $sid); +} + +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 ( $blank ) { -warn dump( $blank ); + 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) ); } }