decode tag blocks array
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 27 Jul 2010 19:09:28 +0000 (21:09 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 27 Jul 2010 19:09:28 +0000 (21:09 +0200)
lib/RFID/Serial/Decode/RFID501.pm
t/05-RFID501.t

index c0176f6..14f5bf3 100644 (file)
@@ -22,6 +22,8 @@ was done to be compliant with 3M implementation
 
   my $hash = RFID::Serial::Decode::RFID501->to_hash( $bytes );
 
+  my $hash = RFID::Serial::Decode::RFID501->to_hash( [ 'blk1', 'blk2', ... , 'blk7' ] );
+
 =cut
 
 my $item_type = {
@@ -44,6 +46,10 @@ sub to_hash {
 
        return unless $data;
 
+       $data = join('', @$data) if ref $data eq 'ARRAY';
+
+       warn "## to_hash $data\n";
+
        my ( $u1, $set_item, $u2, $type, $content, $br_lib, $custom ) = unpack('C4Z16Nl>',$data);
        my $hash = {
                u1 => $u1,      # FIXME
index d8e15e9..2e43df3 100755 (executable)
@@ -12,6 +12,20 @@ BEGIN {
 ok( my $hash = RFID::Serial::Decode::RFID501->to_hash( "\x04\x11\x00\x00200912310123\x00\x00\x00\x00" ), 'decode_tag' );
 diag dump $hash;
 
-ok( my $hash = RFID::Serial::Decode::RFID501->to_hash( "\x04\x11\x00\x011301234567\x00\x00\x00\x00\x00\x00" ), 'decode_tag' );
+ok( $hash = RFID::Serial::Decode::RFID501->to_hash( "\x04\x11\x00\x011301234567\x00\x00\x00\x00\x00\x00" ), 'decode_tag' );
+diag dump $hash;
+
+my $tag = [
+       "\4\21\0\0",
+       2009,
+       "0101",
+       "0123",
+       "\0\0\0\0",
+       "\xFF\xFF\xFF\xFF",
+       "\x7F\xFF\xFF\xFF",
+       "\0\0\0\0",
+];
+
+ok( $hash = RFID::Serial::Decode::RFID501->to_hash( $tag ), 'decode_tag' );
 diag dump $hash;