X-Git-Url: http://git.rot13.org/?p=Biblio-RFID.git;a=blobdiff_plain;f=scripts%2Fprogram.pl;h=ec33b889414ec40adb605d07c4539ce4289025a1;hp=f15dfa836b939eb5e73d37d043e256678061316a;hb=28e4aab986d5658c963db3cb53476f612053f8f6;hpb=55baf82bee4acf05f093c6bf70a359bda7feb3ba diff --git a/scripts/program.pl b/scripts/program.pl index f15dfa8..ec33b88 100755 --- a/scripts/program.pl +++ b/scripts/program.pl @@ -6,26 +6,48 @@ use strict; use Data::Dump qw(dump); use Getopt::Long; use lib 'lib'; -use RFID::Biblio::Readers; -use RFID::Biblio::RFID501; +use Biblio::RFID::Reader; +use Biblio::RFID::RFID501; -my $only; +my $reader; +my $afi = 0x00; +my $debug = 0; +my $hash; +my $blank; GetOptions( - 'only=s', => \$only, + '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 E0_RFID_SID content\n" unless $sid && $content; - -my @rfid = RFID::Biblio::Readers->available( $only ); - -foreach my $rfid ( @rfid ) { - my $visible = $rfid->scan; - foreach my $tag ( keys %$visible ) { - next unless $tag eq $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 ) { + warn "visible $tag\n"; + next unless $tag eq $sid; + 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, RFID::Biblio::RFID501->from_hash({ content => $content }) ); + $rfid->write_blocks( $tag => Biblio::RFID::RFID501->from_hash($hash) ); + $rfid->write_afi( $tag => chr($afi) ) if $afi; } }