write_afi
[Biblio-RFID.git] / t / 10-3M-810.t
index 7a737a7..d52b355 100755 (executable)
@@ -14,4 +14,24 @@ ok( my $o = RFID::Serial::3M810->new( device => '/dev/ttyUSB0' ), 'new' );
 ok( my @tags = $o->inventory, 'inventory' );
 diag dump @tags;
 
-ok( my $blocks = $o->read_blocks( $_ ), "read_blocks $_" ) foreach @tags;
+my $old_afi;
+
+foreach my $tag ( @tags ) {
+
+       ok( my $blocks = $o->read_blocks( $tag ), "read_blocks $tag" );
+
+       ok( my $afi = $o->read_afi( $tag ), "read_afi $tag" );
+
+       my $new_afi = "\x42";
+
+       ok( $o->write_afi( $tag, $new_afi ), sprintf( "write_afi %s %x", $tag, $new_afi ) );
+
+       cmp_ok( $o->read_afi( $tag ), 'eq', $new_afi, 'AFI check' );
+
+       ok( $o->write_afi( $tag, $afi ), sprintf( "write_afi %s %x", $tag, $afi ) );
+
+}
+
+ok( my $visible = $o->scan, 'scan' );
+diag dump $visible;
+