--- 3m-810.pl 2009/04/06 12:36:22 28 +++ 3m-810.pl 2009/04/06 13:10:40 29 @@ -7,6 +7,7 @@ use Data::Dump qw/dump/; use Carp qw/confess/; use Getopt::Long; +use File::Slurp; use IO::Socket::INET; @@ -39,6 +40,8 @@ my $stopbits = "1"; my $handshake = "none"; +my $program_path = './program/'; + my $response = { 'd500090400110a0500027250' => 'version?', 'd60007fe00000500c97b' => 'no tag in range', @@ -182,6 +185,11 @@ warn "## using cached data for $tag" if $debug; } delete $last_visible_tags->{$tag}; # leave just missing tags + + if ( -e "$program_path/$tag" ) { + meteor( 'write', $tag ); + write_tag( $tag ); + } } foreach my $tag ( keys %$last_visible_tags ) { @@ -243,6 +251,28 @@ } +sub write_tag { + my ($tag) = @_; + + my $path = "$program_path/$tag"; + + my $data = read_file( $path ); + + print "write_tag $tag = $data\n"; + + cmd( + "D6 00 26 04 $tag 00 06 00 04 11 00 01 61 61 61 61 62 62 62 62 63 63 63 63 64 64 64 64 00 00 00 00 FD3B", "write $tag", + "D6 00 0D 04 00 $tag 06 AFB1", sub { assert() }, + ) foreach ( 1 .. 3 ); # XXX 3M software does this three times! + + my $to = $path; + $to .= '.' . time(); + + rename $path, $to; + print ">> $to\n"; + +} + exit; for ( 1 .. 3 ) {