split Get System Info
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 4 Aug 2010 13:55:29 +0000 (15:55 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 4 Aug 2010 13:55:29 +0000 (15:55 +0200)
This will allow us to re-use it to get AFI byte

lib/RFID/Biblio/CPRM02.pm

index dd01a68..6358a67 100644 (file)
@@ -145,29 +145,39 @@ cpr( 'FF  B0  01 00', 'ISO - Inventory', sub {
 }
 
 
-sub read_blocks {
+sub _get_system_info {
        my $tag = shift;
-       $tag = shift if ref $tag;
 
-       my $max_block;
+       my $info;
 
        cpr( "FF  B0 2B  01  $tag", "Get System Information $tag", sub {
                my $data = shift;
 
                warn "# data ",as_hex($data);
 
-               my $DSFID    = substr($data,5-2,1);
-               my $UID      = substr($data,6-2,8);
-               my $AFI      = substr($data,14-2,1);
-               my $MEM      = substr($data,15-2,1);
-               my $SIZE     = substr($data,16-2,1);
-               my $IC_REF   = substr($data,17-2,1);
-
-               warn "# split ",as_hex( $DSFID, $UID, $AFI, $MEM, $SIZE, $IC_REF );
+               $info = {
+                       DSFID    => substr($data,5-2,1),
+                       UID      => substr($data,6-2,8),
+                       AFI      => substr($data,14-2,1),
+                       MEM      => substr($data,15-2,1),
+                       SIZE     => substr($data,16-2,1),
+                       IC_REF   => substr($data,17-2,1),
+               };
 
-               $max_block = ord($SIZE);
        });
 
+       return $info;
+}
+
+
+sub read_blocks {
+       my $tag = shift;
+       $tag = shift if ref $tag;
+
+       my $info = _get_system_info $tag;
+
+       my $max_block = ord($info->{SIZE}) || die "no SIZE in ",dump( $info );
+
        my $tag_blocks;
 
        my $block = 0;