fix bytes array passwd to write_blocks
[Biblio-RFID.git] / lib / RFID / Biblio / 3M810.pm
index 5868a78..1b37a46 100644 (file)
@@ -234,7 +234,9 @@ sub read_blocks {
 sub write_blocks {
        my $tag = shift;
        $tag = shift if ref $tag;
-       my $data = join('', @_);
+
+       my $data = shift;
+       $data = join('', @$data) if ref $data eq 'ARRAY';
 
        warn "## write_blocks ",dump($tag,$data);
 
@@ -302,12 +304,9 @@ sub write_afi {
                my $data = shift;
 
                if ( my $rest = _matched $data => '09 00' ) {
-
-                       my $tag = substr($rest,0,8);
-                          $afi = substr($rest,8,1);
-
+                       my $tag_back = hex_tag substr($rest,0,8);
+                       die "write_afi got $tag_back expected $tag" if $tag_back ne $tag;
                        warn "# SECURITY ", hex_tag($tag), " AFI: ", as_hex($afi);
-
                } elsif ( $rest = _matched $data => '0A 06' ) {
                        warn "ERROR writing AFI to $tag ", as_hex($data);
                        undef $afi;