/[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 20 by dpavlin, Fri Oct 3 21:25:02 2008 UTC revision 21 by dpavlin, Fri Oct 3 21:47:24 2008 UTC
# Line 70  it under the same terms ans Perl itself. Line 70  it under the same terms ans Perl itself.
70    
71  =cut  =cut
72    
73    my $tags_data;
74    my $visible_tags;
75    
76  my $port=new Device::SerialPort($device) || die "can't open serial port $device: $!\n";  my $port=new Device::SerialPort($device) || die "can't open serial port $device: $!\n";
77  warn "using $device $handshake $baudrate $databits $parity $stopbits" if $debug;  warn "using $device $handshake $baudrate $databits $parity $stopbits" if $debug;
78  $handshake=$port->handshake($handshake);  $handshake=$port->handshake($handshake);
# Line 125  cmd( 'D6 00  05   FE     00  05 Line 128  cmd( 'D6 00  05   FE     00  05
128                          warn "## tags ",as_hex($tags), " [$tl] = ",dump( $tags ) if $debug;                          warn "## tags ",as_hex($tags), " [$tl] = ",dump( $tags ) if $debug;
129                          print "seen $nr tags: ", join(',', @tags ) , "\n";                          print "seen $nr tags: ", join(',', @tags ) , "\n";
130    
131                          # read data from tag                          my $removed_tags = $visible_tags;
132                          read_tag( $_ ) foreach @tags;                          $visible_tags = {};
133    
134                            foreach my $tag ( @tags ) {
135                                    next if $visible_tags->{$tag}++;
136                                    read_tag( $tag );
137                                    if ( delete $removed_tags->{$tag} ) {
138                                            print "removed tag $tag\n";
139                                    }
140                            }
141    
142                  }                  }
143          }          }
144  ) foreach ( 1 .. 100 );  ) foreach ( 1 .. 100 );
145    
 my $read_cached;  
   
146  sub read_tag {  sub read_tag {
147          my ( $tag ) = @_;          my ( $tag ) = @_;
148    
         return if $read_cached->{ $tag }++;  
           
149          print "read_tag $tag\n";          print "read_tag $tag\n";
150    
151          cmd(          cmd(
# Line 163  sub read_tag { Line 170  sub read_tag {
170                                  warn sprintf "## tag %08s %02d %s |%-4s|\n", $tag, $ord, as_hex( $data ), $data;                                  warn sprintf "## tag %08s %02d %s |%-4s|\n", $tag, $ord, as_hex( $data ), $data;
171                                  $data[ $ord ] = $data;                                  $data[ $ord ] = $data;
172                          }                          }
173                          $read_cached->{ $tag } = join('', @data);                          $tags_data->{ $tag } = join('', @data);
174                          print "DATA $tag ",dump( $read_cached ), "\n";                          print "DATA $tag ",dump( $tags_data ), "\n";
175                  }                  }
176          );          );
177    

Legend:
Removed from v.20  
changed lines
  Added in v.21

  ViewVC Help
Powered by ViewVC 1.1.26