/[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 28 by dpavlin, Mon Apr 6 12:36:22 2009 UTC revision 30 by dpavlin, Mon Apr 6 13:18:55 2009 UTC
# Line 7  use warnings; Line 7  use warnings;
7  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
8  use Carp qw/confess/;  use Carp qw/confess/;
9  use Getopt::Long;  use Getopt::Long;
10    use File::Slurp;
11    
12  use IO::Socket::INET;  use IO::Socket::INET;
13    
# Line 39  my $parity       = "none"; Line 40  my $parity       = "none";
40  my $stopbits  = "1";  my $stopbits  = "1";
41  my $handshake = "none";  my $handshake = "none";
42    
43    my $program_path = './program/';
44    
45  my $response = {  my $response = {
46          'd500090400110a0500027250'                              => 'version?',          'd500090400110a0500027250'                              => 'version?',
47          'd60007fe00000500c97b'                                  => 'no tag in range',          'd60007fe00000500c97b'                                  => 'no tag in range',
# Line 182  sub update_visible_tags { Line 185  sub update_visible_tags {
185                          warn "## using cached data for $tag" if $debug;                          warn "## using cached data for $tag" if $debug;
186                  }                  }
187                  delete $last_visible_tags->{$tag}; # leave just missing tags                  delete $last_visible_tags->{$tag}; # leave just missing tags
188    
189                    if ( -e "$program_path/$tag" ) {
190                                    meteor( 'write', $tag );
191                                    write_tag( $tag );
192                    }
193          }          }
194    
195          foreach my $tag ( keys %$last_visible_tags ) {          foreach my $tag ( keys %$last_visible_tags ) {
# Line 243  sub read_tag { Line 251  sub read_tag {
251    
252  }  }
253    
254    sub write_tag {
255            my ($tag) = @_;
256    
257            my $path = "$program_path/$tag";
258    
259            my $data = read_file( $path );
260    
261            $data = substr($data,0,16);
262    
263            my $hex_data = unpack('H*', $data) . ' 00' x ( 16 - length($data) );
264    
265            print "write_tag $tag = $data ",dump( $hex_data );
266    
267            cmd(
268                    "D6 00  26  04  $tag  00 06 00  04 11 00 01  $hex_data 00 00 00 00  FD3B", "write $tag",
269                    "D6 00  0D  04 00  $tag  06  AFB1", sub { assert() },
270            ) foreach ( 1 .. 3 ); # XXX 3M software does this three times!
271    
272            my $to = $path;
273            $to .= '.' . time();
274    
275            rename $path, $to;
276            print ">> $to\n";
277    
278            delete $tags_data->{$tag};      # force re-read of tag
279    }
280    
281  exit;  exit;
282    
283  for ( 1 .. 3 ) {  for ( 1 .. 3 ) {

Legend:
Removed from v.28  
changed lines
  Added in v.30

  ViewVC Help
Powered by ViewVC 1.1.26