101 |
my $tags_data; |
my $tags_data; |
102 |
my $visible_tags; |
my $visible_tags; |
103 |
|
|
104 |
|
my $item_type = { |
105 |
|
1 => 'Book', |
106 |
|
6 => 'CD/CD ROM', |
107 |
|
2 => 'Magazine', |
108 |
|
13 => 'Book with Audio Tape', |
109 |
|
9 => 'Book with CD/CD ROM', |
110 |
|
0 => 'Other', |
111 |
|
|
112 |
|
5 => 'Video', |
113 |
|
4 => 'Audio Tape', |
114 |
|
3 => 'Bound Journal', |
115 |
|
8 => 'Book with Diskette', |
116 |
|
7 => 'Diskette', |
117 |
|
}; |
118 |
|
|
119 |
|
warn "## known item type: ",dump( $item_type ) if $debug; |
120 |
|
|
121 |
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"; |
122 |
warn "using $device $handshake $baudrate $databits $parity $stopbits" if $debug; |
warn "using $device $handshake $baudrate $databits $parity $stopbits" if $debug; |
123 |
$handshake=$port->handshake($handshake); |
$handshake=$port->handshake($handshake); |
239 |
$tag_data_block->{$tag}->[ $ord ] = $data; |
$tag_data_block->{$tag}->[ $ord ] = $data; |
240 |
} |
} |
241 |
$tags_data->{ $tag } = join('', @{ $tag_data_block->{$tag} }); |
$tags_data->{ $tag } = join('', @{ $tag_data_block->{$tag} }); |
242 |
print "DATA $tag ",dump( $tags_data ), "\n"; |
|
243 |
|
my $item_type_nr = ord(substr( $tags_data->{$tag}, 3, 1 )); |
244 |
|
print "DATA $tag ",dump( $tags_data ), " item type: ", ( $item_type->{ $item_type_nr } || "UNKWOWN '$item_type_nr' in " . dump( $item_type ) ), "\n"; |
245 |
} |
} |
246 |
|
|
247 |
sub read_tag { |
sub read_tag { |
277 |
|
|
278 |
my $data = read_file( $path ); |
my $data = read_file( $path ); |
279 |
|
|
280 |
print "write_tag $tag = $data\n"; |
$data = substr($data,0,16); |
281 |
|
|
282 |
|
my $hex_data = unpack('H*', $data) . ' 00' x ( 16 - length($data) ); |
283 |
|
|
284 |
|
print "write_tag $tag = $data ",dump( $hex_data ); |
285 |
|
|
286 |
cmd( |
cmd( |
287 |
"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 26 04 $tag 00 06 00 04 11 00 01 $hex_data 00 00 00 00 FD3B", "write $tag", |
288 |
"D6 00 0D 04 00 $tag 06 AFB1", sub { assert() }, |
"D6 00 0D 04 00 $tag 06 AFB1", sub { assert() }, |
289 |
) foreach ( 1 .. 3 ); # XXX 3M software does this three times! |
) foreach ( 1 .. 3 ); # XXX 3M software does this three times! |
290 |
|
|
294 |
rename $path, $to; |
rename $path, $to; |
295 |
print ">> $to\n"; |
print ">> $to\n"; |
296 |
|
|
297 |
|
delete $tags_data->{$tag}; # force re-read of tag |
298 |
} |
} |
299 |
|
|
300 |
exit; |
exit; |