}
+sub write_blocks {
+ my $tag = shift;
+ $tag = shift if ref $tag;
+
+ my $data = shift;
+ $data = join('', @$data) if ref $data eq 'ARRAY';
+
+ my $DB_ADR = 0; # start at first block
+ my $DB_SIZE = 4; # bytes in one block FIXME this should be read from transponder and not hard-coded
+ if ( my $padding = length($data) % $DB_SIZE ) {
+ warn "WARNING: data block not padded to $DB_SIZE bytes";
+ $data .= "\x00" x $padding;
+ }
+ my $DB_N = length($data) / $DB_SIZE;
+
+ cpr( sprintf("FF B0 24 01 $tag %02x %02x %02x %s", $DB_ADR, $DB_SIZE, $DB_N, as_hex($data)), "Write Multiple Blocks $tag", sub {
+ my $data = shift;
+ warn dump( $data );
+ });
+
+}
+
+sub read_afi {}
+sub write_afi {}
+
1
ok( my @tags = $o->inventory, 'inventory' );
-ok( my $blocks = $o->read_blocks( $_ ), "read_blocks $_" ) foreach @tags;
+foreach my $tag ( @tags ) {
+
+ ok( my $blocks = $o->read_blocks( $tag ), "read_blocks $tag" );
+
+ my $pattern = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F";
+ ok( $o->write_blocks( $tag, $pattern ), "write_blocks $tag" );
+
+ $pattern = "0123456789ABCDEF.....";
+ ok( $o->write_blocks( $tag, $pattern ), "write_blocks $tag" );
+
+# ok( $o->write_blocks( $tag, $blocks->{$tag} ), "write_blocks $tag" );
+
+}
ok( my $visible = $o->scan, 'scan' );
diag dump $visible;