407 |
while ( $start_block < $max_rfid_block ) { |
while ( $start_block < $max_rfid_block ) { |
408 |
|
|
409 |
cmd( |
cmd( |
410 |
sprintf( "D6 00 0D 02 $tag %02x %02x ffff", $start_block, $read_blocks ), |
sprintf( "D6 00 0D 02 $tag %02x %02x BEEF", $start_block, $read_blocks ), |
411 |
"read $tag offset: $start_block blocks: $read_blocks", |
"read $tag offset: $start_block blocks: $read_blocks", |
412 |
"D6 00 1F 02 00", sub { # $tag 03 00 00 04 11 00 01 01 00 31 32 33 34 02 00 35 36 37 38 531F\n"; |
"D6 00 1F 02 00", sub { # $tag 03 00 00 04 11 00 01 01 00 31 32 33 34 02 00 35 36 37 38 531F\n"; |
413 |
$start_block = read_tag_data( $start_block, @_ ); |
$start_block = read_tag_data( $start_block, @_ ); |
414 |
warn "# read tag upto $start_block\n"; |
warn "# read tag upto $start_block\n"; |
415 |
}, |
}, |
416 |
"D6 00 0F FE 00 00 05 01 $tag 941A", sub { |
"D6 00 0F FE 00 00 05 01 $tag BEEF", sub { |
417 |
print "FIXME: tag $tag ready? (expected block read instead)\n"; |
print "FIXME: tag $tag ready? (expected block read instead)\n"; |
418 |
}, |
}, |
419 |
); |
); |
423 |
my $security; |
my $security; |
424 |
|
|
425 |
cmd( |
cmd( |
426 |
"D6 00 0B 0A $tag 1234", "check security $tag", |
"D6 00 0B 0A $tag BEEF", "check security $tag", |
427 |
"D6 00 0D 0A 00", sub { |
"D6 00 0D 0A 00", sub { |
428 |
my $rest = shift; |
my $rest = shift; |
429 |
my $from_tag; |
my $from_tag; |
473 |
print "write_tag $tag = ",dump( $data ), " [$len/$blocks] == $hex_data\n"; |
print "write_tag $tag = ",dump( $data ), " [$len/$blocks] == $hex_data\n"; |
474 |
|
|
475 |
cmd( |
cmd( |
476 |
"d6 00 ff 04 $tag 00 $blocks 00 $hex_data ffff", "write $tag", |
"d6 00 ff 04 $tag 00 $blocks 00 $hex_data BEEF", "write $tag", |
477 |
"d6 00 0d 04 00 $tag $blocks afb1", sub { assert() }, |
"d6 00 0d 04 00 $tag $blocks BEEF", sub { assert() }, |
478 |
); # foreach ( 1 .. 3 ); # XXX 3m software does this three times! |
); # foreach ( 1 .. 3 ); # XXX 3m software does this three times! |
479 |
|
|
480 |
my $to = $path; |
my $to = $path; |
495 |
my $data = substr(read_file( $path ),0,2); |
my $data = substr(read_file( $path ),0,2); |
496 |
|
|
497 |
cmd( |
cmd( |
498 |
"d6 00 0c 09 $tag $data 1234", "secure $tag -> $data", |
"d6 00 0c 09 $tag $data BEEF", "secure $tag -> $data", |
499 |
"d6 00 0c 09 00 $tag 1234", sub { assert() }, |
"d6 00 0c 09 00 $tag BEEF", sub { assert() }, |
500 |
); |
); |
501 |
|
|
502 |
my $to = $path; |
my $to = $path; |
618 |
warn "## checksum ",dump( $bytes, $xor, $checksum ) if $debug; |
warn "## checksum ",dump( $bytes, $xor, $checksum ) if $debug; |
619 |
|
|
620 |
if ( defined $checksum && $xor ne $checksum ) { |
if ( defined $checksum && $xor ne $checksum ) { |
621 |
print "checksum doesn't match: ", as_hex($xor), " != ", as_hex($checksum), " data: ", as_hex($bytes), "\n"; |
warn "checksum error: ", as_hex($xor), " != ", as_hex($checksum), " data: ", as_hex($bytes), "\n" if $checksum ne "\xBE\xEF"; |
622 |
return $bytes . $xor; |
return $bytes . $xor; |
623 |
} |
} |
624 |
return $bytes . $checksum; |
return $bytes . $checksum; |