--- 3m-810.pl 2009/03/28 14:20:27 24 +++ 3m-810.pl 2009/03/29 01:05:49 25 @@ -10,12 +10,17 @@ use IO::Socket::INET; -my $meteor = IO::Socket::INET->new( '192.168.1.13:4671' ) || die "can't connect to meteor: $!"; +my $meteor_server = '192.168.1.13:4671'; + +my $meteor = IO::Socket::INET->new( $meteor_server ) + || die "can't connect to meteor $meteor_server: $!"; sub meteor { - my ( $item, $html ) = @_; - warn ">> meteor $item $html\n"; - print $meteor "ADDMESSAGE test $item|" . localtime() . "
$html\n"; + my @a = @_; + push @a, scalar localtime() if $a[0] =~ m{^info}; + + warn ">> meteor ",dump( @a ); + print $meteor "ADDMESSAGE test ",join('|',@a),"\n"; } my $debug = 0; @@ -110,7 +115,7 @@ 'D5 00 09 04 00 11 0A 05 00 02 7250', sub { my $hw_ver = join('.', unpack('CCCC', skip_assert(3) )); print "hardware version $hw_ver\n"; - meteor( -1, "Found reader $hw_ver" ); + meteor( 'info', "Found reader hardware $hw_ver" ); }); cmd( 'D6 00 0C 13 04 01 00 02 00 03 00 04 00 AAF2','FIXME: stats?', @@ -126,7 +131,7 @@ if ( ! $nr ) { print "no tags in range\n"; update_visible_tags(); - meteor( -1, "No tags in range" ); + meteor( 'info-none-in-range' ); $tags_data = {}; } else { @@ -140,10 +145,9 @@ warn "## tags ",as_hex($tags), " [$tl] = ",dump( $tags ) if $debug; print "$nr tags in range: ", join(',', @tags ) , "\n"; - update_visible_tags( @tags ); + meteor( 'info-in-range', join(' ',@tags)); - my $html = join('', map { "
  • $_" } @tags); - meteor( 0, "Tags:" ); + update_visible_tags( @tags ); } } ) while(1); @@ -159,7 +163,12 @@ foreach my $tag ( @tags ) { if ( ! defined $last_visible_tags->{$tag} ) { - read_tag( $tag ); + if ( defined $tags_data->{$tag} ) { +# meteor( 'in-range', $tag ); + } else { + meteor( 'read', $tag ); + read_tag( $tag ); + } $visible_tags->{$tag}++; } else { warn "## using cached data for $tag" if $debug; @@ -170,6 +179,7 @@ foreach my $tag ( keys %$last_visible_tags ) { my $data = delete $tags_data->{$tag}; print "removed tag $tag with data ",dump( $data ),"\n"; + meteor( 'removed', $tag ); } warn "## update_visible_tags(",dump( @tags ),") = ",dump( $visible_tags )," removed: ",dump( $last_visible_tags ), " data: ",dump( $tags_data ) if $debug; @@ -181,8 +191,6 @@ confess "no tag?" unless $tag; - return if defined $tags_data->{$tag}; - print "read_tag $tag\n"; cmd( @@ -222,9 +230,6 @@ } warn "?? D6 00 0F FE 00 00 05 01 $tag 941A ##### ready?\n"; - my $item = unpack('H*', substr($tag,-8) ) % 100000; - meteor( $item, "Loading $item" ); - } exit;