/[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 16 by dpavlin, Thu Oct 2 22:53:57 2008 UTC revision 17 by dpavlin, Fri Oct 3 08:53:57 2008 UTC
# Line 256  sub checksum { Line 256  sub checksum {
256          warn "## checksum ",dump( $bytes, $xor, $checksum ) if $debug;          warn "## checksum ",dump( $bytes, $xor, $checksum ) if $debug;
257    
258          my $len = ord(substr($bytes,2,1));          my $len = ord(substr($bytes,2,1));
259          my $len_real = length($bytes);          my $len_real = length($bytes) - 1;
260          print "length wrong: $len_real != $len\n" if $len_real != $len;  
261            if ( $len_real != $len ) {
262                    print "length wrong: $len_real != $len\n";
263                    $bytes = substr($bytes,0,2) . chr($len_real) . substr($bytes,4);
264            }
265    
266          if ( defined $checksum && $xor ne $checksum ) {          if ( defined $checksum && $xor ne $checksum ) {
267                  print "checksum doesn't match: ", as_hex($xor), " != ", as_hex($checksum), " data: ", as_hex($bytes), "\n";                  print "checksum doesn't match: ", as_hex($xor), " != ", as_hex($checksum), " data: ", as_hex($bytes), "\n";
# Line 297  sub readchunk { Line 301  sub readchunk {
301  sub str2bytes {  sub str2bytes {
302          my $str = shift || confess "no str?";          my $str = shift || confess "no str?";
303          my $b = $str;          my $b = $str;
304          $b =~ s/\s+(\S\S)(\S\S)+\s*/ $1 $2/;    # fix checksum          $b =~ s/\s+//g;
305          $b =~ s/\s+$//;          $b =~ s/(..)/\\x$1/g;
306          $b =~ s/\s+/\\x/g;          $b = "\"$b\"";
         $b = '"\x' . $b . '"';  
307          my $bytes = eval $b;          my $bytes = eval $b;
308          die $@ if $@;          die $@ if $@;
309          warn "## str2bytes( $str ) => $b => ",as_hex($bytes) if $debug;          warn "## str2bytes( $str ) => $b => ",as_hex($bytes) if $debug;

Legend:
Removed from v.16  
changed lines
  Added in v.17

  ViewVC Help
Powered by ViewVC 1.1.26