added --[3m]blank option
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 4 Apr 2014 10:33:11 +0000 (12:33 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 4 Apr 2014 10:33:11 +0000 (12:33 +0200)
scripts/program.pl

index 755a5ea..ec33b88 100755 (executable)
@@ -10,9 +10,10 @@ use Biblio::RFID::Reader;
 use Biblio::RFID::RFID501;
 
 my $reader;
 use Biblio::RFID::RFID501;
 
 my $reader;
-my $afi;
+my $afi = 0x00;
 my $debug = 0;
 my $hash;
 my $debug = 0;
 my $hash;
+my $blank;
 
 GetOptions(
        'reader=s', => \$reader,
 
 GetOptions(
        'reader=s', => \$reader,
@@ -23,10 +24,12 @@ GetOptions(
        'type=i',       => \$hash->{type},
        'branch=i',     => \$hash->{branch},
        'library=i'     => \$hash->{library},
        '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 $!;
 
 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;
 
 
 $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;
 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;
+       }
 }
 
 }