DN1400F.pm

filter: Statementstmt 15.0% 38 / 252 Branchbran 0.0% 0 / 90 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 20.5% 8 / 39 Podpod 0.0% 0 / 26 totaltotal 11.2% 46 / 410 CC 52 SCAR 40.8
CC
52
Cov
11%
_cmd
272.0
_dscpn
42.0
new
30.0
CRAP 59.4
↑ Summary play.pl »
1 package Device::Denon::DN1400F;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use vars qw(@ISA $VERSION @EXPORT_OK %EXPORT_TAGS %COMMANDS);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Device::SerialPort qw(:PARAM :STAT);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Time::HiRes qw(usleep time);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 @ISA = qw(Exporter);
13 1 @EXPORT_OK = qw();
14 1 %EXPORT_TAGS = ('all' => \@EXPORT_OK);
15 1 $VERSION = '0.02';
16  
17 %COMMANDS = (
18 MOVE_FRONT => {
19 Command => [ qw(ID 0xb2) ],
20 Answer => [ qw(0x80 ID) ],
21 Busy => [ qw(INVD ID) ],
22 },
23 CLEAR_CHANGER_BUFFER => {
24 Command => [ qw(ID 0xC0) ],
25 Answer => [ qw(0x80 ID) ],
26 Busy => [ qw(INVD ID) ],
27 },
28 _1BYTE_ERROR_CODE => {
29 Command => [ qw(ID 0xC1) ],
30 Answer => [ qw(ERR0 ID) ],
31 Busy => [ qw(INVD ID) ],
32 },
33 _2BYTE_ERROR_CODE => {
34 Command => [ qw(ID 0xC2) ],
35 Answer => [ qw(ERR0 ERR1 ID) ],
36 Busy => [ qw(INVD ID) ],
37 },
38 DISC_NUMBER => {
39 Command => [ qw(ID 0xC3) ],
40 Answer => [ qw(DNO_F DNO_R ID) ],
41 Busy => [ qw(INVD ID) ],
42 },
43 SELECT_A_DISC => {
44 Command => [ qw(ID 0xC4 DSCP DSCN DID) ],
45 Answer => [ qw(CST0 ID DID) ],
46 Busy => [ qw(INVD ID DID) ],
47 },
48 RETURN_A_DISC => {
49 Command => [ qw(ID 0xC5 DSCP DSCN DID) ],
50 Answer => [ qw(CST0 ID DID) ],
51 Busy => [ qw(INVD ID DID) ],
52 },
53 RETURN_ALL_DISC => {
54 Command => [ qw(ID 0xC6) ],
55 Answer => [ qw(CST0 ID) ],
56 Busy => [ qw(INVD ID) ],
57 },
58 RESET_DN_1400F => {
59 Command => [ qw(ID 0xCA) ],
60 Answer => [ qw() ],
61 Busy => [ qw(INVD ID) ],
62 },
63 CHANGER_MICON_VERSION => {
64 Command => [ qw(ID 0xCB 0x00) ],
65 Answer => [ qw(VER0 VER1 ID) ],
66 Busy => [ qw(INVD ID) ],
67 },
68 DISCNUMBER_CHANGER_STATUS=>{
69 Command => [ qw(ID 0xCC) ],
70 Answer => [ qw(DSCP_0 DSCN_0 CST0_0
71 DSCP_1 DSCN_1 CST0_1 CST1 ID)],
72 Busy => [ qw(INVD ID) ],
73 },
74 DRIVE_STATUS => {
75 Command => [ qw(ID 0xCB DID) ],
76 Answer => [ qw(DST0 ID DID) ],
77 Busy => [ qw(INVD ID DID) ],
78 },
79 DRIVE_MICON_VERSION => {
80 Command => [ qw(ID 0xD1 DID) ],
81 Answer => [ qw(VER0 VER1 ID DID) ],
82 Busy => [ qw(INVD ID DID) ],
83 },
84 DRIVE_STATUS_SERVOONOFF => {
85 Command => [ qw(ID 0xD2 DID) ],
86 Answer => [ qw(DST0 DST1 ID DID) ],
87 Busy => [ qw(INVD ID DID) ],
88 },
89 SUB_CODE_QMODE3 => {
90 Command => [ qw(ID 0xD6 DID) ],
91 Answer => [ qw(DST0 CTR_L),
92 11 map{"ISRC_$_"}(0..7),
93 qw(AFR_M ID DID)],
94 Busy => [ qw(INVD ID DID) ],
95 },
96 SUB_CODE_QMODE2 => {
97 Command => [ qw(ID 0xD7 DID) ],
98 Answer => [ qw(DST0 CTR_L),
99 1 map{"UPC_$_"}(0..7),
100 qw(AFR_M ID DID)],
101 Busy => [ qw(INVD ID DID) ],
102 },
103 SUB_CODE_QCHANNEL => {
104 Command => [ qw(ID 0xD9 DID) ],
105 Answer => [ qw(DST0 CTRL TNO INX MIN SEC FRM 0x00
106 AMIN ASEC AFRM ID DID) ],
107 Busy => [ qw(INVD ID DID) ],
108 },
109 ALL_TOC_DATA => {
110 Command => [ qw(ID 0xDA DID) ],
111 Answer => [ qw(0xA0 PMIN 0x00 0x00 CTRL
112 YADDA EOT 0x00
113 YADDA DST0 ID DID) ],
114 Busy => [ qw(INVD ID DID) ],
115 Variable=> 1,
116 },
117 SHORT_TOC_DATA => {
118 Command => [ qw(ID 0xDB DID) ],
119 Answer => [ qw(0xA0 PMIN 0x00 0x00
120 CTRL YADDA EOT DST0 ID DID) ],
121 Busy => [ qw(INVD ID DID) ],
122 Variable=> 1,
123 },
124 PLAY_AUDIO => {
125 Command => [ qw(ID 0xE2 AMIN ASEC AFRM TNO INX MODE DID) ],
126 Answer => [ qw(DST0 ID DID) ],
127 Busy => [ qw(INVD ID DID) ],
128 },
129 AUDIO_SCAN => {
130 Command => [ qw(ID 0xE3 AMIN ASEC AFRM TNO INX MODE DID) ],
131 Answer => [ qw(DST0 ID DID) ],
132 Busy => [ qw(INVD ID DID) ],
133 },
134 PAUSE => {
135 Command => [ qw(ID 0xE5 MODE DID) ], # Docs are buggy
136 Answer => [ qw(DST0 ID DID) ],
137 Busy => [ qw(INVD ID DID) ],
138 },
139 SEEK => {
140 Command => [ qw(ID 0xE6 AMIN ASEC AFRM DID) ],
141 Answer => [ qw(DST0 ID DID) ],
142 Busy => [ qw(INVD ID DID) ],
143 },
144 STOP => {
145 Command => [ qw(ID 0xE7 DID) ],
146 Answer => [ qw(DST0 ID DID) ],
147 Busy => [ qw(INVD ID DID) ],
148 },
149 # 25-26 reserved
150 TRACK_SEARCH => {
151 Command => [ qw(ID 0xEC AMIN ASEC AFRM TNO INX MODE DID) ],
152 Answer => [ qw(DST0 ID DID) ],
153 Busy => [ qw(INVD ID DID) ],
154 },
155 AUDIO_CHANNEL_CONTROL => {
156 Command => [ qw(ID 0xED) ],
157 Answer => [ qw(CST0 ID) ],
158 Busy => [ qw(INVD ID DID) ],
159 },
160 # 29 reserved
161 FADE_INOUT_PLAY => {
162 Command => [ qw(ID 0xF2 AMIN ASEC AFRM TNO INX MODE DID) ],
163 Answer => [ qw(DST0 ID DID) ],
164 Busy => [ qw(INVD ID DID) ],
165 },
166 SYSTEM_MICON_VERSION => {
167 Command => [ qw(ID 0xF3) ],
168 Answer => [ qw(VER0 VER1 ID) ],
169 Busy => [ qw(INVD ID DID) ],
170 },
171 );
172  
173  
174 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod undocumented
175 0 my $class = shift;
176 0 ▶ my $self = ($#_ == 0) ? { %{ (shift) } } : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
$#_ == 0 ? : 0 0 0
177  
178 0 ▶ die "No SerialPort specified" unless $self->{SerialPort};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"SerialPort"} 0 0 0
179  
180 # Device::SerialPort->debug(1);
181  
182 my $port = new Device::SerialPort(
183 $self->{SerialPort},
184 0 0,
185 undef);
186 0 ▶ die "Failed to open device $self->{SerialPort}" unless $port;
Branch: 1 branch
BranchTrueFalseTotal
unless $port 0 0 0
187  
188 0 $port->user_msg(1);
189 0 $port->error_msg(1);
190 # $port->debug(1);
191  
192 0 $port->baudrate(19200);
193 0 $port->parity("even");
194 0 $port->parity_enable("yes");
195 0 $port->databits(8);
196 0 $port->stopbits(1);
197 0 $port->handshake("none");
198  
199 0 ▶ $port->write_settings or die "Failed to write settings\n";
Branch: 1 branch
BranchTrueFalseTotal
$port->write_settings or die "Failed to write settings\n" 0 0 0
200  
201 0 $port->status;
202  
203 0 $self->{Port} = $port;
204  
205 0 $self->{LastCommand} = time;
206  
207 0 return bless $self, $class;
208 }
209  
210 0 ▶sub commands {
Subroutine commands: not called CC=1 SCAR=6.9
Pod undocumented
211 0 return keys(%COMMANDS);
212 }
213  
214 0 ▶sub _cmd {
Subroutine _cmd: not called CC=16 SCAR=56.1
215 0 my $self = shift;
216 0 my $command = shift;
217 0 ▶ my $args = ($#_ == 0) ? { %{ (shift) } } : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
$#_ == 0 ? : 0 0 0
218  
219 # We can't send the commands to it too fast. It confuses it.
220 0 ▶ while (time - $self->{LastCommand} < 0.2) {
Branch: 1 branch
BranchTrueFalseTotal
if (&Device::Denon::DN1400F::time() - $self->{"LastCommand"} < "0.2") 0 0 0
221 0 usleep(50);
222 }
223 0 $self->{LastCommand} = time;
224  
225 0 my $data = $COMMANDS{$command};
226 0 ▶ die "No such command $command" unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
227  
228 0 print "Executing command $command\n";
229  
230 0 my @template = @{ $data->{Command} };
231 0 my @bytes = ();
232 0 foreach (@template) {
233 0 ▶ if ($_ =~ /^0x[[:xdigit:]]+$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_ =~ /^0x[[:xdigit:]]+$/) { } 0 0 0
elsif ($_ eq 'ID') { } 0 0 0
234 0 push(@bytes, hex($_));
235 }
236 elsif ($_ eq 'ID') {
237 0 push(@bytes, $self->{Id} + 0x50);
238 }
239 else {
240 die "No value for required parameter $_"
241 0 ▶ unless exists $args->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args->{$_} 0 0 0
242 0 print "$_ = $args->{$_}\n";
243 0 push(@bytes, $args->{$_});
244 }
245 }
246  
247 0 my @hex = map { sprintf("%2.2x", $_) } @bytes;
248 0 my $string = pack("C*", @bytes);
249 0 my $count = $self->{Port}->write($string);
250 0 print "<< @hex\n";
251 0 ▶ die "Wrote only $count bytes" unless $count == length $string;
Branch: 1 branch
BranchTrueFalseTotal
unless $count == length $string 0 0 0
252  
253 0 ▶ return { } if $command eq 'RESET_DN_1400F';
Branch: 1 branch
BranchTrueFalseTotal
if $command eq "RESET_DN_1400F" 0 0 0
254  
255 0 my $prefix;
256 0 my $timer = 0;
257 0 while (1) {
258 0 usleep(10);
259 0 ($count, $prefix) = $self->{Port}->read(1);
260 0 ▶ last if $count;
Branch: 1 branch
BranchTrueFalseTotal
if $count 0 0 0
261 0 ▶ die "Got no response to command!" if ++$timer > 100;
Branch: 1 branch
BranchTrueFalseTotal
if ++$timer > 100 0 0 0
262 }
263  
264 0 ▶ if ($prefix eq "\xdd") {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix eq "\335") { } 0 0 0
265 0 print "Response is an error code.\n";
266 0 @template = @{ $data->{Busy} };
267 }
268 else {
269 0 @template = @{ $data->{Answer} };
270 }
271  
272 0 my $readlength;
273 0 ▶ if ($data->{Variable}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{'Variable'}) { } 0 0 0
274 # Wait long enough for the data to come down the line.
275 0 usleep(400000);
276 # Long enough for ALL_TOC_DATA. In theory we should read
277 # and lex, rather than trying to slurp, then we would know
278 # when the end of the data is.
279 0 $readlength = 1000;
280 }
281 else {
282 0 $readlength = scalar(@template) - 1;
283 }
284  
285 0 ($count, $string) = $self->{Port}->read($readlength);
286 0 my @response = unpack("C*", $prefix . $string);
287  
288 0 @hex = map { sprintf("%2.2x", $_) } @response;
289 0 print ">> @hex\n";
290  
291 # A slight kludge to get this out of the system.
292 0 ▶ return { Data => \@response } if $data->{Variable};
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"Variable"} 0 0 0
293  
294 0 ▶ die "Reponse template not same size as response"
Branch: 1 branch
BranchTrueFalseTotal
unless @template == @response 0 0 0
295 unless @template == @response;
296  
297 0 my %out = map { $template[$_] => $response[$_] } (0..$#template);
298 0 return \%out;
299 }
300  
301 0 ▶sub command {
Subroutine command: not called CC=1 SCAR=6.9
Pod undocumented
302 0 my $self = shift;
303 0 my $response = $self->_cmd(@_);
304 0 $self->print_response($response);
305 0 return $response;
306 }
307  
308 1 my %ID = map { $_ + 0x50 => "Unit $_" } (0..15);
309  
310 1 my %CST0 = (
311 0x80 => "Command complete, reception normally completed.",
312 0x81 => "No Disc",
313 0x82 => "Busy, Disc transport section is in disc transport processing",
314 0x83 => "Completed Disc Set with No Error",
315 0x84 => "Reserved",
316 0x85 => "Reserved",
317 0x86 => "Reserved",
318 0x8A => "Initial Busy, After power on and Reset DN-1400F",
319 0x8B => "Changer Error",
320 0x8C => "Disc Rack in not set",
321 0x8E => "Wait transportation",
322 0x8F => "Changer Error",
323 0xDD => "INVD, Command Busy or Invalid Command",
324 );
325  
326 1 my %DST0 = (
327 0xB0 => "Ready, Reception normally completed.",
328 0xB1 => "Fade In / Out Play, In the process of fade in/out play",
329 0xB2 => "Seek, In the process of search.",
330 0xB3 => "Reserved",
331 0xB4 => "Pause, Pause condition during audio play.",
332 0xB5 => "Scan, In the process of scan play execution.",
333 0xB6 => "Play, In the process of audio play.",
334 0xB7 => "Reserved",
335 0xB8 => "Disc Change. Disc has been changed.",
336 0xB9 => "No Disc, Disc is not set in the disc loading section.",
337 0xBA => "Reserved",
338 0xBB => "Seek Error",
339 0xBC => "EOT: End of TOC",
340 0xBF => "CD-ROM Data Area",
341 0xD0 => "RAM Error (CD-DRIVE Hardware Error)",
342 0xD1 => "FOK Error (CD-DRIVE Hardware Error)",
343 0xD2 => "FZC Error (CD-DRIVE Hardware Error)",
344 0xD3 => "GFS Error (CD-DRIVE Hardware Error)",
345 0xD5 => "Slide Error (CD-DRIVE Hardware Error)",
346 0xD6 => "Eject Sequence Error (CD-DRIVE Hardware Error)",
347 0xD7 => "Gain Control Error (CD-DRIVE Hardware Error)",
348 0xD8 => "Reserved",
349 0xD9 => "Reserved",
350 0xDA => "Reserved",
351 0xDB => "Invalid Command or Invalid Parameter",
352 0xDC => "Invalid Parameter",
353 0xDD => "INVD: Command busy or Invalid Command.",
354 );
355  
356 1 my %DST1 = (
357 0x00 => "Servo off",
358 0x01 => "Servo on",
359 );
360  
361 1 my %DID = (
362 0x00 => "Drive 1: Front",
363 0x01 => "Drive 2: Rear",
364 );
365  
366 1 my %ERR = (
367 0x00 => "No error",
368 );
369  
370 0 ▶sub print_response_item {
Subroutine print_response_item: not called CC=4 SCAR=30.0
Pod undocumented
371 0 my ($self, $response, $key, $values) = @_;
372 0 ▶ if (exists $response->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $response->{$key}) 0 0 0
373 my $value = $values
374 ? ($values->{$response->{$key}} || "VALUE UNKNOWN!")
375 0 ▶ : $response->{$key};
Branch: 1 branch
BranchTrueFalseTotal
$values ? : 0 0 0
Condition0%0/2
$$values{$response->{$key}} or "VALUE UNKNOWN!"
l!l
00
MC/DC0%0/1
$$values{$response->{$key}} or "VALUE UNKNOWN!"
$$values{$response->{$key}}
Truth table0%0/2
A
A= $$values{$response->{$key}}
Aresult
11
00
376 print "* $key: " .
377 0 sprintf("%x", $response->{$key}) . " : $value\n";
378 0 delete $response->{$key};
379 }
380 }
381  
382 0 ▶sub print_response {
Subroutine print_response: not called CC=4 SCAR=30.0
Pod undocumented
383 0 my ($self, $response) = @_;
384  
385 0 my %copy = %$response;
386 0 $self->print_response_item(\%copy, "ID", \%ID);
387 0 $self->print_response_item(\%copy, "DID", \%DID);
388 0 $self->print_response_item(\%copy, "CST0", \%CST0);
389 0 $self->print_response_item(\%copy, "DST0", \%DST0);
390 0 $self->print_response_item(\%copy, "DST1", \%DST1);
391 0 $self->print_response_item(\%copy, "DID", \%DID);
392 0 $self->print_response_item(\%copy, "ERR0", \%ERR);
393 0 $self->print_response_item(\%copy, "ERR1", \%ERR);
394 0 foreach (keys %copy) {
395 0 ▶ if ($_ =~ /^0x/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^0x/) { } 0 0 0
396 0 ▶ if (hex($_) != $response->{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (hex $_ != $response->{$_}) 0 0 0
397 print "Expected $_, got " .
398 0 sprintf("%2.2x\n", $response->{$_});
399 }
400 }
401 else {
402 0 $self->print_response_item(\%copy, $_, undef);
403 }
404 }
405 }
406  
407 0 ▶sub _dscpn {
Subroutine _dscpn: not called CC=6 SCAR=37.4
408 0 my $discno = shift;
409  
410 0 my ($dscp, $dscn);
411  
412 0 ▶ if ($discno < 0) {
Branch: 5 branches
BranchTrueFalseTotal
if ($discno < 0) { } 0 0 0
elsif ($discno <= 50) { } 0 0 0
elsif ($discno <= 100) { } 0 0 0
elsif ($discno <= 150) { } 0 0 0
elsif ($discno <= 200) { } 0 0 0
413 0 die "Invalid disc number $discno\n";
414 }
415 elsif ($discno <= 50) {
416 0 $dscp = 0;
417 0 $dscn = $discno - 1;
418 }
419 elsif ($discno <= 100) {
420 0 $dscp = 1;
421 0 $dscn = $discno - 51;
422 }
423 elsif ($discno <= 150) {
424 0 $dscp = 2;
425 0 $dscn = $discno - 101;
426 }
427 elsif ($discno <= 200) {
428 0 $dscp = 3;
429 0 $dscn = $discno - 151;
430 }
431 else {
432 0 die "Invalid disc number $discno\n";
433 }
434  
435 0 return ($dscp, $dscn);
436 }
437  
438 0 ▶sub _discno {
Subroutine _discno: not called CC=2 SCAR=17.9
439 0 my ($dscp, $dscn) = @_;
440 0 ▶ return -1 if $dscp == 255;
Branch: 1 branch
BranchTrueFalseTotal
if $dscp == 255 0 0 0
441 0 return $dscp * 50 + $dscn + 1;
442 }
443  
444 0 ▶sub _from_bcd {
Subroutine _from_bcd: not called CC=1 SCAR=6.9
445 0 my $val = shift;
446 0 return 0+ sprintf("%x", $val);
447 }
448  
449 # Interpreting a number as hex essentially codes it as BCD.
450 0 ▶sub _to_bcd {
Subroutine _to_bcd: not called CC=1 SCAR=6.9
451 0 my $val = shift;
452 0 return hex($val);
453 }
454  
455 0 ▶sub move_front {
Subroutine move_front: not called CC=1 SCAR=6.9
Pod undocumented
456 0 my ($self) = @_;
457 0 return $self->command('MOVE_FRONT');
458 }
459  
460 0 ▶sub clear_changer_buffer {
Subroutine clear_changer_buffer: not called CC=1 SCAR=6.9
Pod undocumented
461 0 my ($self) = @_;
462 0 return $self->command('CLEAR_CHANGER_BUFFER');
463 }
464  
465 0 ▶sub debug {
Subroutine debug: not called CC=1 SCAR=6.9
Pod undocumented
466 0 my ($self) = @_;
467 0 $self->command('_1BYTE_ERROR_CODE');
468 0 $self->command('_2BYTE_ERROR_CODE');
469 }
470  
471 0 ▶sub loaded_discs {
Subroutine loaded_discs: not called CC=1 SCAR=6.9
Pod undocumented
472 0 my ($self) = @_;
473 0 my $response = $self->command('DISC_NUMBER');
474 0 return ($response->{DNO_F}, $response->{DNO_R});
475 }
476  
477 0 ▶sub load_disc {
Subroutine load_disc: not called CC=2 SCAR=17.9
Pod undocumented
478 0 my ($self, $drive, $discno, $args) = @_;
479 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
480 0 $args->{DID} = $drive;
481 0 ($args->{DSCP}, $args->{DSCN}) = _dscpn($discno);
482 0 return $self->command('SELECT_A_DISC', $args);
483 }
484  
485 0 ▶sub unload_disc {
Subroutine unload_disc: not called CC=2 SCAR=17.9
Pod undocumented
486 0 my ($self, $drive, $discno, $args) = @_;
487 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
488 0 $args->{DID} = $drive;
489 0 ($args->{DSCP}, $args->{DSCN}) = _dscpn($discno);
490 0 return $self->command('RETURN_A_DISC', $args);
491 }
492  
493 0 ▶sub unload_discs {
Subroutine unload_discs: not called CC=1 SCAR=6.9
Pod undocumented
494 0 my ($self) = @_;
495 0 return $self->command('RETURN_ALL_DISC');
496 }
497  
498 0 ▶sub reset {
Subroutine reset: not called CC=1 SCAR=6.9
Pod undocumented
499 0 my ($self) = @_;
500 0 return $self->command('RESET_DN_1400F');
501 }
502  
503 # Calling this immediately after loaded_discs barfs. Firmware bug?
504 0 ▶sub changer_version {
Subroutine changer_version: not called CC=1 SCAR=6.9
Pod undocumented
505 0 my ($self) = @_;
506 # This command seems to be broken on mine.
507 0 my $response = $self->command('CHANGER_MICON_VERSION');
508 return ($response->{VER0}, $response->{VER1})
509 0 }
510  
511 0 ▶sub status {
Subroutine status: not called CC=1 SCAR=6.9
Pod undocumented
512 0 my ($self) = @_;
513 # This command seems to be broken on mine.
514 0 my $response = $self->command('DISCNUMBER_CHANGER_STATUS');
515 return {
516 Disc0 => _discno($response->{DSCP_0},
517 $response->{DSCN_0}),
518 Disc1 => _discno($response->{DSCP_1},
519 $response->{DSCN_1}),
520 Status0 => $CST0{$response->{CST0_0}},
521 Status1 => $CST0{$response->{CST0_1}},
522 0 };
523 }
524  
525 # As far as I can work out, the firmware on this one is buggy too.
526 0 ▶sub drive_status {
Subroutine drive_status: not called CC=2 SCAR=17.9
Pod undocumented
527 0 my ($self, $drive, $args) = @_;
528 0 die "Buggy firmware in the drive_status command.";
529 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
530 0 $args->{DID} = $drive;
531 0 my $response = $self->command('DRIVE_STATUS', $args);
532 }
533  
534 0 ▶sub drive_version {
Subroutine drive_version: not called CC=2 SCAR=17.9
Pod undocumented
535 0 my ($self, $drive, $args) = @_;
536 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
537 0 $args->{DID} = $drive;
538 0 my $response = $self->command('DRIVE_MICON_VERSION', $args);
539 }
540  
541 0 ▶sub drive_status_servo_onoff {
Subroutine drive_status_servo_onoff: not called CC=2 SCAR=17.9
Pod undocumented
542 0 my ($self, $drive, $args) = @_;
543 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
544 0 $args->{DID} = $drive;
545 0 my $response = $self->command('DRIVE_STATUS_SERVOONOFF', $args);
546 }
547  
548 0 ▶sub drive_subcode_qchannel {
Subroutine drive_subcode_qchannel: not called CC=2 SCAR=17.9
Pod undocumented
549 0 my ($self, $drive, $args) = @_;
550 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
551 0 $args->{DID} = $drive;
552 0 my $response = $self->command('SUB_CODE_QCHANNEL', $args);
553 return {
554 Status => $DST0{$response->{DST0}},
555 QControl => $response->{CTRL} >> 4,
556 QAddress => $response->{CTRL} & 0xf,
557 Track => _from_bcd($response->{TNO}),
558 Index => _from_bcd($response->{INX}),
559 Minute => _from_bcd($response->{MIN}),
560 Second => _from_bcd($response->{SEC}),
561 Frame => _from_bcd($response->{FRM}),
562 AbsoluteMinute => _from_bcd($response->{AMIN}),
563 AbsoluteSecond => _from_bcd($response->{ASEC}),
564 0 AbsoluteFrame => _from_bcd($response->{AFRM}),
565 };
566 }
567  
568 0 ▶sub toc_data_long {
Subroutine toc_data_long: not called CC=2 SCAR=17.9
Pod undocumented
569 0 my ($self, $drive, $args) = @_;
570 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
571 0 $args->{DID} = $drive;
572 0 my $response = $self->command('ALL_TOC_DATA', $args);
573 0 return $response->{Data};
574 }
575  
576 0 ▶sub toc_data_short {
Subroutine toc_data_short: not called CC=2 SCAR=17.9
Pod undocumented
577 0 my ($self, $drive, $args) = @_;
578 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
579 0 $args->{DID} = $drive;
580 0 my $response = $self->command('SHORT_TOC_DATA', $args);
581 0 return $response->{Data};
582 }
583  
584 0 ▶sub drive_play {
Subroutine drive_play: not called CC=4 SCAR=30.0
Pod undocumented
585 0 my ($self, $drive, $track, $args) = @_;
586 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
587 0 $args->{DID} = $drive;
588 0 $args->{TNO} = _to_bcd($track);
589 0 $args->{MODE} = 0x29;
590 0 $args->{INX} = 1; # What is this?
591 0 foreach (qw(AMIN ASEC AFRM)) {
592 0 ▶ $args->{$_} = 0 unless exists $args->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args->{$_} 0 0 0
593 }
594 0 return $self->command('PLAY_AUDIO', $args);
595 }
596  
597 0 ▶sub drive_scan {
Subroutine drive_scan: not called CC=4 SCAR=30.0
Pod undocumented
598 0 my ($self, $drive, $track, $args) = @_;
599 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
600 0 $args->{DID} = $drive;
601 0 $args->{TNO} = _to_bcd($track);
602 0 $args->{MODE} = 0x29;
603 0 $args->{INX} = 1; # What is this?
604 0 foreach (qw(AMIN ASEC AFRM)) {
605 0 ▶ $args->{$_} = 0 unless exists $args->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args->{$_} 0 0 0
606 }
607 0 return $self->command('AUDIO_SCAN', $args);
608 }
609  
610 0 ▶sub drive_pause {
Subroutine drive_pause: not called CC=3 SCAR=24.8
Pod undocumented
611 0 my ($self, $drive, $mode, $args) = @_;
612 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
613 0 $args->{DID} = $drive;
614 0 ▶ $args->{MODE} = $mode ? 0x01 : 0x00;
Branch: 1 branch
BranchTrueFalseTotal
$mode ? : 0 0 0
615 0 return $self->command('PAUSE', $args);
616 }
617  
618 0 ▶sub drive_stop {
Subroutine drive_stop: not called CC=2 SCAR=17.9
Pod undocumented
619 0 my ($self, $drive, $args) = @_;
620 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
621 0 $args->{DID} = $drive;
622 0 return $self->command('STOP', $args);
623 }
624  
625 0 ▶sub drive_search {
Subroutine drive_search: not called CC=4 SCAR=30.0
Pod undocumented
626 0 my ($self, $drive, $track, $args) = @_;
627 0 ▶ $args = {} unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
628 0 $args->{DID} = $drive;
629 0 $args->{TNO} = _to_bcd($track);
630 0 $args->{MODE} = 0x29;
631 0 $args->{INX} = 1; # What is this?
632 0 foreach (qw(AMIN ASEC AFRM)) {
633 0 ▶ $args->{$_} = 0 unless exists $args->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args->{$_} 0 0 0
634 }
635 0 return $self->command('TRACK_SEARCH', $args);
636 }
637  
638 1 1;
639  
640 __END__
↑ Summary play.pl »