From: Dobrica Pavlinusic Date: Fri, 4 Apr 2014 10:33:11 +0000 (+0200) Subject: added --[3m]blank option X-Git-Url: http://git.rot13.org/?p=Biblio-RFID.git;a=commitdiff_plain;h=28e4aab986d5658c963db3cb53476f612053f8f6 added --[3m]blank option --- diff --git a/scripts/program.pl b/scripts/program.pl index 755a5ea..ec33b88 100755 --- a/scripts/program.pl +++ b/scripts/program.pl @@ -10,9 +10,10 @@ 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, @@ -23,10 +24,12 @@ GetOptions( '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] [--type 1] 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; @@ -36,8 +39,15 @@ $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($hash) ); - $rfid->write_afi( $tag => chr($afi) ) if $afi; + if ( $blank ) { +warn dump( $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; + } }