swap lsb-msb bytes for write_blocks
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 4 Aug 2010 13:41:19 +0000 (15:41 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 4 Aug 2010 13:41:19 +0000 (15:41 +0200)
And correct order of DB_N and DB_SIZE to make it really working :-)

lib/RFID/Biblio/CPRM02.pm

index ec2efdd..dd01a68 100644 (file)
@@ -211,7 +211,12 @@ sub write_blocks {
        }
        my $DB_N    = length($data) / $DB_SIZE;
 
-       cpr( sprintf("FF  B0 24  01  $tag   %02x %02x %02x  %s", $DB_ADR, $DB_SIZE, $DB_N, as_hex($data)), "Write Multiple Blocks $tag", sub {
+       my $send_data;
+       foreach my $block ( 0 .. $DB_N ) {
+               $send_data .= reverse split(//, substr( $data, $block * $DB_SIZE, $DB_SIZE ) );
+       }
+
+       cpr( sprintf("FF  B0 24  01  $tag   %02x %02x %02x  %s", $DB_ADR, $DB_N, $DB_SIZE, as_hex($send_data)), "Write Multiple Blocks $tag", sub {
                my $data = shift;
                warn dump( $data );
        });