/[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 24 by dpavlin, Sat Mar 28 14:20:27 2009 UTC revision 25 by dpavlin, Sun Mar 29 01:05:49 2009 UTC
# Line 10  use Getopt::Long; Line 10  use Getopt::Long;
10    
11  use IO::Socket::INET;  use IO::Socket::INET;
12    
13  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';
14    
15    my $meteor = IO::Socket::INET->new( $meteor_server )
16             || die "can't connect to meteor $meteor_server: $!";
17    
18  sub meteor {  sub meteor {
19          my ( $item, $html ) = @_;          my @a = @_;
20          warn ">> meteor $item $html\n";          push @a, scalar localtime() if $a[0] =~ m{^info};
21          print $meteor "ADDMESSAGE test $item|" . localtime() . "<br>$html\n";  
22            warn ">> meteor ",dump( @a );
23            print $meteor "ADDMESSAGE test ",join('|',@a),"\n";
24  }  }
25    
26  my $debug = 0;  my $debug = 0;
# Line 110  cmd( 'D5 00  05   04 00 11 Line 115  cmd( 'D5 00  05   04 00 11
115       'D5 00  09   04 00 11   0A 05 00 02   7250', sub {       'D5 00  09   04 00 11   0A 05 00 02   7250', sub {
116          my $hw_ver = join('.', unpack('CCCC', skip_assert(3) ));          my $hw_ver = join('.', unpack('CCCC', skip_assert(3) ));
117          print "hardware version $hw_ver\n";          print "hardware version $hw_ver\n";
118          meteor( -1, "Found reader $hw_ver" );          meteor( 'info', "Found reader hardware $hw_ver" );
119  });  });
120    
121  cmd( 'D6 00  0C   13  04  01 00  02 00  03 00  04 00   AAF2','FIXME: stats?',  cmd( 'D6 00  0C   13  04  01 00  02 00  03 00  04 00   AAF2','FIXME: stats?',
# Line 126  cmd( 'D6 00  05   FE     00  05 Line 131  cmd( 'D6 00  05   FE     00  05
131                  if ( ! $nr ) {                  if ( ! $nr ) {
132                          print "no tags in range\n";                          print "no tags in range\n";
133                          update_visible_tags();                          update_visible_tags();
134                          meteor( -1, "No tags in range" );                          meteor( 'info-none-in-range' );
135                          $tags_data = {};                          $tags_data = {};
136                  } else {                  } else {
137    
# Line 140  cmd( 'D6 00  05   FE     00  05 Line 145  cmd( 'D6 00  05   FE     00  05
145                          warn "## tags ",as_hex($tags), " [$tl] = ",dump( $tags ) if $debug;                          warn "## tags ",as_hex($tags), " [$tl] = ",dump( $tags ) if $debug;
146                          print "$nr tags in range: ", join(',', @tags ) , "\n";                          print "$nr tags in range: ", join(',', @tags ) , "\n";
147    
148                          update_visible_tags( @tags );                          meteor( 'info-in-range', join(' ',@tags));
149    
150                          my $html = join('', map { "<li><tt>$_</tt>" } @tags);                          update_visible_tags( @tags );
                         meteor( 0, "Tags:<ul>$html</ul>" );  
151                  }                  }
152          }          }
153  ) while(1);  ) while(1);
# Line 159  sub update_visible_tags { Line 163  sub update_visible_tags {
163    
164          foreach my $tag ( @tags ) {          foreach my $tag ( @tags ) {
165                  if ( ! defined $last_visible_tags->{$tag} ) {                  if ( ! defined $last_visible_tags->{$tag} ) {
166                          read_tag( $tag );                          if ( defined $tags_data->{$tag} ) {
167    #                               meteor( 'in-range', $tag );
168                            } else {
169                                    meteor( 'read', $tag );
170                                    read_tag( $tag );
171                            }
172                          $visible_tags->{$tag}++;                          $visible_tags->{$tag}++;
173                  } else {                  } else {
174                          warn "## using cached data for $tag" if $debug;                          warn "## using cached data for $tag" if $debug;
# Line 170  sub update_visible_tags { Line 179  sub update_visible_tags {
179          foreach my $tag ( keys %$last_visible_tags ) {          foreach my $tag ( keys %$last_visible_tags ) {
180                  my $data = delete $tags_data->{$tag};                  my $data = delete $tags_data->{$tag};
181                  print "removed tag $tag with data ",dump( $data ),"\n";                  print "removed tag $tag with data ",dump( $data ),"\n";
182                    meteor( 'removed', $tag );
183          }          }
184    
185          warn "## update_visible_tags(",dump( @tags ),") = ",dump( $visible_tags )," removed: ",dump( $last_visible_tags ), " data: ",dump( $tags_data ) if $debug;          warn "## update_visible_tags(",dump( @tags ),") = ",dump( $visible_tags )," removed: ",dump( $last_visible_tags ), " data: ",dump( $tags_data ) if $debug;
# Line 181  sub read_tag { Line 191  sub read_tag {
191    
192          confess "no tag?" unless $tag;          confess "no tag?" unless $tag;
193    
         return if defined $tags_data->{$tag};  
   
194          print "read_tag $tag\n";          print "read_tag $tag\n";
195    
196          cmd(          cmd(
# Line 222  if (0) { Line 230  if (0) {
230  }  }
231          warn "?? D6 00  0F  FE  00 00  05 01   $tag  941A ##### ready?\n";          warn "?? D6 00  0F  FE  00 00  05 01   $tag  941A ##### ready?\n";
232    
         my $item = unpack('H*', substr($tag,-8) ) % 100000;  
         meteor( $item, "Loading $item" );  
   
233  }  }
234    
235  exit;  exit;

Legend:
Removed from v.24  
changed lines
  Added in v.25

  ViewVC Help
Powered by ViewVC 1.1.26