6 use Data::Dump qw(dump);
9 use Biblio::RFID::Reader;
10 use Biblio::RFID::RFID501;
19 'reader=s', => \$reader,
22 'set=i' => \$hash->{set},
23 'total=i', => \$hash->{total},
24 'type=i', => \$hash->{type},
25 'branch=i', => \$hash->{branch},
26 'library=i' => \$hash->{library},
27 '3mblank' => \$blank->{blank_3m},
28 'blank' => \$blank->{blank},
31 my ( $sid, $content ) = @ARGV;
32 if ( $sid =~ m/.+,.+/ && ! defined $content ) {
33 ( $sid, $content ) = split(/,/, $sid);
36 die "usage: $0 [--reader regex_filter] [--afi 214] [--type 1] E0_RFID_SID [barcode]\n" unless $sid && ( $content || $afi || $blank );
38 $hash->{content} = $content if defined $content;
40 my $rfid = Biblio::RFID::Reader->new( $reader );
41 $Biblio::RFID::debug = $debug;
43 foreach my $tag ( $rfid->tags, $sid ) {
44 warn "visible $tag\n";
45 next unless $tag eq $sid;
46 if ( grep { defined $_ } values %$blank ) {
47 my $type = ( grep { $blank->{$_} } keys %$blank )[0];
48 warn "BLANK $type $tag\n";
49 $rfid->write_blocks( $tag => Biblio::RFID::RFID501->$type );
50 } elsif ( $content ) {
51 warn "PROGRAM $tag with $content\n";
52 $rfid->write_blocks( $tag => Biblio::RFID::RFID501->from_hash($hash) );
55 warn "AFI $tag with $afi\n";
56 $rfid->write_afi( $tag => chr($afi) );