--- 3m-810.pl 2009/04/06 13:18:55 30 +++ 3m-810.pl 2009/04/08 14:48:22 33 @@ -101,6 +101,23 @@ my $tags_data; my $visible_tags; +my $item_type = { + 1 => 'Book', + 6 => 'CD/CD ROM', + 2 => 'Magazine', + 13 => 'Book with Audio Tape', + 9 => 'Book with CD/CD ROM', + 0 => 'Other', + + 5 => 'Video', + 4 => 'Audio Tape', + 3 => 'Bound Journal', + 8 => 'Book with Diskette', + 7 => 'Diskette', +}; + +warn "## known item type: ",dump( $item_type ) if $debug; + my $port=new Device::SerialPort($device) || die "can't open serial port $device: $!\n"; warn "using $device $handshake $baudrate $databits $parity $stopbits" if $debug; $handshake=$port->handshake($handshake); @@ -222,7 +239,9 @@ $tag_data_block->{$tag}->[ $ord ] = $data; } $tags_data->{ $tag } = join('', @{ $tag_data_block->{$tag} }); - print "DATA $tag ",dump( $tags_data ), "\n"; + + my $item_type_nr = ord(substr( $tags_data->{$tag}, 3, 1 )); + print "DATA $tag ",dump( $tags_data ), " item type: ", ( $item_type->{ $item_type_nr } || "UNKWOWN '$item_type_nr' in " . dump( $item_type ) ), "\n"; } sub read_tag { @@ -249,6 +268,28 @@ } ); + my $security; + + cmd( + "D6 00 0B 0A $tag 1234", "check security $tag", + "D6 00 0D 0A 00", sub { + my $rest = shift; + my $from_tag; + ( $from_tag, $security ) = ( substr($rest,0,8), substr($rest,8,1) ); + die "security from other tag: ",as_hex( $from_tag ) if $from_tag ne str2bytes( $tag ); + $security = as_hex( $security ); + warn "# SECURITY $tag = $security\n"; + } + ); + + my $data = $tags_data->{$tag} || die "no data for $tag"; + my ( $u1, $set_item, $u2, $type, $content, $br_lib, $custom ) = unpack('C4Z16Nl>',$data); + my $set = ( $set_item & 0xf0 ) >> 4; + my $total = ( $set_item & 0x0f ); + my $branch = $br_lib >> 20; + my $library = $br_lib & 0x000fffff; + print "TAG $tag [$u1] set: $set/$total [$u2] type: $type '$content' branch: $branch library: $library custom: $custom security: $security\n"; + } sub write_tag {