my $self = shift;
$port = $self->port;
+ # disable timeouts
+ $port->read_char_time(0);
+ $port->read_const_time(0);
+
# 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";
+ $port->read_char_time(100); # 0.1 s char timeout
+ $port->read_const_time(500); # 0.5 s read timeout
+
setup();
}
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);
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;