--- 3m-810.pl 2009/04/08 14:48:22 33 +++ 3m-810.pl 2009/04/08 15:03:49 34 @@ -41,6 +41,7 @@ my $handshake = "none"; my $program_path = './program/'; +my $secure_path = './secure/'; my $response = { 'd500090400110a0500027250' => 'version?', @@ -207,6 +208,10 @@ meteor( 'write', $tag ); write_tag( $tag ); } + if ( -e "$secure_path/$tag" ) { + meteor( 'secure', $tag ); + secure_tag( $tag ); + } } foreach my $tag ( keys %$last_visible_tags ) { @@ -301,14 +306,14 @@ $data = substr($data,0,16); - my $hex_data = unpack('H*', $data) . ' 00' x ( 16 - length($data) ); + my $hex_data = unpack('h*', $data) . ' 00' x ( 16 - length($data) ); print "write_tag $tag = $data ",dump( $hex_data ); cmd( - "D6 00 26 04 $tag 00 06 00 04 11 00 01 $hex_data 00 00 00 00 FD3B", "write $tag", - "D6 00 0D 04 00 $tag 06 AFB1", sub { assert() }, - ) foreach ( 1 .. 3 ); # XXX 3M software does this three times! + "d6 00 26 04 $tag 00 06 00 04 11 00 01 $hex_data 00 00 00 00 fd3b", "write $tag", + "d6 00 0d 04 00 $tag 06 afb1", sub { assert() }, + ) foreach ( 1 .. 3 ); # xxx 3m software does this three times! my $to = $path; $to .= '.' . time(); @@ -319,6 +324,24 @@ delete $tags_data->{$tag}; # force re-read of tag } +sub secure_tag { + my ($tag) = @_; + + my $path = "$secure_path/$tag"; + my $data = substr(read_file( $path ),0,2); + + cmd( + "d6 00 0c 09 $tag $data 1234", "secure $tag -> $data", + "d6 00 0c 09 00 $tag 1234", sub { assert() }, + ); + + my $to = $path; + $to .= '.' . time(); + + rename $path, $to; + print ">> $to\n"; +} + exit; for ( 1 .. 3 ) {