/[RFID]/3m-810.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /3m-810.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 39 by dpavlin, Mon Jun 1 21:07:11 2009 UTC revision 40 by dpavlin, Mon Jun 1 21:17:12 2009 UTC
# Line 247  sub read_tag_data { Line 247  sub read_tag_data {
247                  die "got block $ord, expected block $expected_ord from ",dump( $block ) if $ord != $expected_ord;                  die "got block $ord, expected block $expected_ord from ",dump( $block ) if $ord != $expected_ord;
248                  my $data  = substr( $block, 2 );                  my $data  = substr( $block, 2 );
249                  die "data payload should be 4 bytes" if length($data) != 4;                  die "data payload should be 4 bytes" if length($data) != 4;
250                  warn sprintf "## tag %9s %02d %s |%-4s|\n", $tag, $ord, as_hex( $data ), $data;                  warn sprintf "## tag %9s %02d: %s |%-4s|\n", $tag, $ord, as_hex( $data ), $data;
251                  $tag_data_block->{$tag}->[ $ord ] = $data;                  $tag_data_block->{$tag}->[ $ord ] = $data;
252          }          }
253          $tags_data->{ $tag } = join('', @{ $tag_data_block->{$tag} });          $tags_data->{ $tag } = join('', @{ $tag_data_block->{$tag} });
# Line 317  sub write_tag { Line 317  sub write_tag {
317                  $hex_data =~ s{\s+}{}g;                  $hex_data =~ s{\s+}{}g;
318          } else {          } else {
319    
                 # pad to block size  
320                  $data .= "\0" x ( 4 - ( length($data) % 4 ) );                  $data .= "\0" x ( 4 - ( length($data) % 4 ) );
321    
322                  my $max_len = 7 * 4;                  my $max_len = 7 * 4;
# Line 331  sub write_tag { Line 330  sub write_tag {
330          }          }
331    
332          my $len = length($hex_data) / 2;          my $len = length($hex_data) / 2;
333          my $blocks = sprintf('%02x', $len / 4);          # pad to block size
334            $hex_data .= '00' x ( 4 - $len % 4 );
335            my $blocks = sprintf('%02x', length($hex_data) / 4);
336    
337          print "write_tag $tag = ",dump( $data ), " [$len/$blocks] == $hex_data\n";          print "write_tag $tag = ",dump( $data ), " [$len/$blocks] == $hex_data\n";
338    
339          cmd(          cmd(
340                  "d6 00  ff  04  $tag  00 $blocks 00  $hex_data  ffff", "write $tag",                  "d6 00  ff  04  $tag  00 $blocks 00  $hex_data  ffff", "write $tag",
341                  "d6 00  0d  04 00  $tag  $blocks  afb1", sub { assert() },                  "d6 00  0d  04 00  $tag  $blocks  afb1", sub { assert() },
342          ) foreach ( 1 .. 3 ); # xxx 3m software does this three times!          ); # foreach ( 1 .. 3 ); # XXX 3m software does this three times!
343    
344          my $to = $path;          my $to = $path;
345          $to .= '.' . time();          $to .= '.' . time();

Legend:
Removed from v.39  
changed lines
  Added in v.40

  ViewVC Help
Powered by ViewVC 1.1.26