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 |
|
|
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', |
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 ) { |
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 |
|
print "write_tag $tag = $data\n"; |
262 |
|
|
263 |
|
cmd( |
264 |
|
"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", |
265 |
|
"D6 00 0D 04 00 $tag 06 AFB1", sub { assert() }, |
266 |
|
) foreach ( 1 .. 3 ); # XXX 3M software does this three times! |
267 |
|
|
268 |
|
my $to = $path; |
269 |
|
$to .= '.' . time(); |
270 |
|
|
271 |
|
rename $path, $to; |
272 |
|
print ">> $to\n"; |
273 |
|
|
274 |
|
} |
275 |
|
|
276 |
exit; |
exit; |
277 |
|
|
278 |
for ( 1 .. 3 ) { |
for ( 1 .. 3 ) { |