rename module to Biblio::RFID in source
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 25 Aug 2010 17:13:24 +0000 (19:13 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 25 Aug 2010 17:13:24 +0000 (19:13 +0200)
1  2 
lib/RFID/Biblio/RFID501.pm
lib/RFID/Biblio/Reader/3M810.pm
scripts/print.pl
scripts/scan.pl
t/00-load.t

@@@ -1,4 -1,4 +1,4 @@@
- package RFID::Biblio::RFID501;
+ package Biblio::RFID::RFID501;
  
  use warnings;
  use strict;
@@@ -7,7 -7,7 +7,7 @@@ use Data::Dump qw(dump)
  
  =head1 NAME
  
RFID::Biblio::RFID501 - RFID Standard for Libraries
Biblio::RFID::RFID501 - RFID Standard for Libraries
  
  =head1 DESCRIPTION
  
@@@ -81,19 -81,19 +81,19 @@@ unsecured (door will ignore it
  
  =head2 to_hash
  
-   my $hash = RFID::Biblio::Decode::RFID501->to_hash( $bytes );
+   my $hash = Biblio::RFID::Decode::RFID501->to_hash( $bytes );
  
-   my $hash = RFID::Biblio::Decode::RFID501->to_hash( [ 'blk1', 'blk2', ... , 'blk7' ] );
+   my $hash = Biblio::RFID::Decode::RFID501->to_hash( [ 'blk1', 'blk2', ... , 'blk7' ] );
  
  =head2 from_hash
  
-   my $blocks = RFID::Biblio::Decode::RFID->from_hash({ content => "1301234567" });
+   my $blocks = Biblio::RFID::Decode::RFID->from_hash({ content => "1301234567" });
  
  =head2 blank_3m
  
  =head2 blank
  
-   my $blocks = RFID::Biblio::Decode::RFID->blank;
+   my $blocks = Biblio::RFID::Decode::RFID->blank;
  
  =cut
  
@@@ -152,8 -152,6 +152,8 @@@ sub from_hash 
  
        warn "## from_hash ",dump($hash);
  
 +      $hash->{$_} ||= 0 foreach ( qw( set total type branch library ) );
 +
        return pack('C4Z16Nl>l',
                0x04,
                ( $hash->{set} << 4 ) | ( $hash->{total} & 0x0f ),
@@@ -1,16 -1,16 +1,16 @@@
- package RFID::Biblio::Reader::3M810;
+ package Biblio::RFID::Reader::3M810;
  
  =head1 NAME
  
RFID::Biblio::Reader::3M810 - support for 3M 810 RFID reader
Biblio::RFID::Reader::3M810 - support for 3M 810 RFID reader
  
  =head1 DESCRIPTION
  
- This module uses L<RFID::Biblio::Reader::Serial> over USB/serial adapter
+ This module uses L<Biblio::RFID::Reader::Serial> over USB/serial adapter
  with 3M 810 RFID reader, often used in library applications.
  
  This is most mature implementation which supports full API defined
- in L<RFID::Biblio::Reader::API>. This include scanning for all tags in reader
+ in L<Biblio::RFID::Reader::API>. This include scanning for all tags in reader
  range, reading and writing of data, and AFI security manipulation.
  
  This implementation is developed using Portmon on Windows to capture serial traffic
@@@ -27,8 -27,8 +27,8 @@@ this reader is available at L<http://bl
  use warnings;
  use strict;
  
- use base 'RFID::Biblio::Reader::Serial';
- use RFID::Biblio;
+ use base 'Biblio::RFID::Reader::Serial';
+ use Biblio::RFID;
  
  use Data::Dump qw(dump);
  use Carp qw(confess);
@@@ -56,10 -56,8 +56,10 @@@ sub init 
  
        # drain on startup
        my ( $count, $str ) = $port->read(3);
 -      my $data = $port->read( ord(substr($str,2,1)) );
 -      warn "drain ",as_hex( $str, $data ),"\n";
 +      if ( $count ) {
 +              my $data = $port->read( ord(substr($str,2,1)) );
 +              warn "drain ",as_hex( $str, $data ),"\n";
 +      }
  
        $port->read_char_time(100);      # 0.1 s char timeout
        $port->read_const_time(500); # 0.5 s read timeout
@@@ -310,4 -308,4 +310,4 @@@ __END_
  
  =head1 SEE ALSO
  
- L<RFID::Biblio::Reader::API>
+ L<Biblio::RFID::Reader::API>
diff --combined scripts/print.pl
@@@ -6,8 -6,8 +6,8 @@@ use strict
  use Data::Dump qw(dump);
  use Getopt::Long;
  use lib 'lib';
- use RFID::Biblio::Reader;
- use RFID::Biblio::RFID501;
+ use Biblio::RFID::Reader;
+ use Biblio::RFID::RFID501;
  use Storable;
  
  my $evolis_dir = '/home/dpavlin/klin/Printer-EVOLIS'; # FIXME
@@@ -17,7 -17,7 +17,7 @@@ use Printer::EVOLIS::Parallel
  my $loop = 1;
  my $reader = '3M';
  my $debug = 0;
 -my $afi   = 0x42;
 +my $afi   = 0x00; # XXX
  my $test  = 0;
  
  my $log_print = 'log.print';
@@@ -55,8 -55,8 +55,8 @@@ while(<>) 
  
  print "# queue ", dump @queue;
  
- my $rfid = RFID::Biblio::Reader->new( $reader );
- $RFID::Biblio::debug = $debug;
+ my $rfid = Biblio::RFID::Reader->new( $reader );
+ $Biblio::RFID::debug = $debug;
  
  sub tag {
        my $tag = shift;
@@@ -64,7 -64,7 +64,7 @@@
                , " AFI: "
                , uc unpack('H2', $rfid->afi($tag))
                , " "
-               , dump( RFID::Biblio::RFID501->to_hash( $rfid->blocks($tag) ) )
+               , dump( Biblio::RFID::RFID501->to_hash( $rfid->blocks($tag) ) )
                , $/
                ;
  }
@@@ -98,8 -98,8 +98,8 @@@ do 
                                my $card = shift @queue;
                                my $number = $card->[0];
                                print "PROGRAM $tag $number\n";
-                               $rfid->write_blocks( $tag => RFID::Biblio::RFID501->from_hash({ content => $number }) );
-                               $rfid->write_afi( $tag => chr($afi) );
+                               $rfid->write_blocks( $tag => Biblio::RFID::RFID501->from_hash({ content => $number }) );
+                               $rfid->write_afi( $tag => chr($afi) ) if $afi;
  
                                $programmed->{$tag} = $number;
                                store $programmed, $persistant_path;
diff --combined scripts/scan.pl
@@@ -6,8 -6,8 +6,8 @@@ use strict
  use Data::Dump qw(dump);
  use Getopt::Long;
  use lib 'lib';
- use RFID::Biblio::Reader;
- use RFID::Biblio::RFID501;
+ use Biblio::RFID::Reader;
+ use Biblio::RFID::RFID501;
  
  my $loop = 0;
  my $reader;
@@@ -19,8 -19,8 +19,8 @@@ GetOptions
        'debug+'    => \$debug,
  ) || die $!;
  
- my $rfid = RFID::Biblio::Reader->new( $reader );
- $RFID::Biblio::debug = $debug;
+ my $rfid = Biblio::RFID::Reader->new( $reader );
+ $Biblio::RFID::debug = $debug;
  
  sub tag {
        my $tag = shift;
@@@ -28,7 -28,7 +28,7 @@@
                , " AFI: "
                , uc unpack('H2', $rfid->afi($tag))
                , " "
-               , dump( RFID::Biblio::RFID501->to_hash( $rfid->blocks($tag) ) )
+               , dump( Biblio::RFID::RFID501->to_hash( $rfid->blocks($tag) ) )
                , $/
                ;
  }
@@@ -48,6 -48,4 +48,6 @@@ do 
  
        warn localtime()." visible: ",join(' ',@visible),"\n";
  
 +      sleep 1;
 +
  } while $loop;
diff --combined t/00-load.t
@@@ -1,17 -1,16 +1,17 @@@
  #!/usr/bin/perl -T
  
 -use Test::More tests => 7;
 +use Test::More tests => 8;
  
  BEGIN {
        use lib 'lib';
-       use_ok( 'RFID::Biblio' );
-       use_ok( 'RFID::Biblio::Reader::API' );
-       use_ok( 'RFID::Biblio::Reader::Serial' );
-       use_ok( 'RFID::Biblio::Reader::3M810' );
-       use_ok( 'RFID::Biblio::Reader::CPRM02' );
-       use_ok( 'RFID::Biblio::Reader::librfid' );
-       use_ok( 'RFID::Biblio::Reader' );
-       use_ok( 'RFID::Biblio::RFID501' );
 -    use_ok( 'Biblio::RFID' );
 -    use_ok( 'Biblio::RFID::Reader::API' );
 -    use_ok( 'Biblio::RFID::Reader::Serial' );
 -    use_ok( 'Biblio::RFID::Reader::3M810' );
 -    use_ok( 'Biblio::RFID::Reader::CPRM02' );
 -    use_ok( 'Biblio::RFID::Reader::librfid' );
 -    use_ok( 'Biblio::RFID::Reader' );
++      use_ok( 'Biblio::RFID' );
++      use_ok( 'Biblio::RFID::Reader::API' );
++      use_ok( 'Biblio::RFID::Reader::Serial' );
++      use_ok( 'Biblio::RFID::Reader::3M810' );
++      use_ok( 'Biblio::RFID::Reader::CPRM02' );
++      use_ok( 'Biblio::RFID::Reader::librfid' );
++      use_ok( 'Biblio::RFID::Reader' );
++      use_ok( 'Biblio::RFID::RFID501' );
  }
  
- diag( "Testing RFID::Biblio $RFID::Biblio::VERSION, Perl $], $^X" );
+ diag( "Testing Biblio::RFID $Biblio::RFID::VERSION, Perl $], $^X" );