X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=scripts%2Fprogram.pl;h=45a06b3a524ed7c1bb995e1cde722f9fdbd11284;hb=48764d1207ef06ad96b937bd2365227f78090109;hp=7dbfc7f8d3664f6008b4ef6cdc834a23ef878c1c;hpb=41257cf2d2e318df3c4015969f48fdc08d602560;p=Biblio-RFID.git diff --git a/scripts/program.pl b/scripts/program.pl index 7dbfc7f..45a06b3 100755 --- a/scripts/program.pl +++ b/scripts/program.pl @@ -10,17 +10,28 @@ use Biblio::RFID::Reader; use Biblio::RFID::RFID501; my $reader; -my $afi; +my $afi = 0x00; my $debug = 0; +my $hash; +my $blank; GetOptions( 'reader=s', => \$reader, 'afi=i', => \$afi, 'debug+', => \$debug, + 'set=i' => \$hash->{set}, + 'total=i', => \$hash->{total}, + 'type=i', => \$hash->{type}, + 'branch=i', => \$hash->{branch}, + 'library=i' => \$hash->{library}, + '3mblank' => \$blank->{blank_3m}, + 'blank' => \$blank->{blank}, ) || die $!; my ( $sid, $content ) = @ARGV; -die "usage: $0 [--reader regex_filter] [--afi 214] E0_RFID_SID [barcode]\n" unless $sid && ( $content | $afi ); +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; @@ -28,8 +39,14 @@ $Biblio::RFID::debug = $debug; 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; + 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 { + warn "PROGRAM $tag with $content\n"; + $rfid->write_blocks( $tag => Biblio::RFID::RFID501->from_hash($hash) ); + $rfid->write_afi( $tag => chr($afi) ) if $afi; + } }