diff options
author | Ralf Ertzinger <rockbox@camperquake.de> | 2013-06-22 10:08:23 +0100 |
---|---|---|
committer | Frank Gevaerts <frank@gevaerts.be> | 2013-11-10 18:41:24 +0100 |
commit | b170c73f922e3457b923b4e7fcbec794a8885c77 (patch) | |
tree | 89fbdbd8c25af5101a29a1ede3b896332a4e205c /tools/iap/ipod-001-general.t | |
parent | 500b137308a6ee5c2aba873734a8956d70472f56 (diff) | |
download | rockbox-b170c73f922e3457b923b4e7fcbec794a8885c77.tar.gz rockbox-b170c73f922e3457b923b4e7fcbec794a8885c77.zip |
Updated IAP commands.
Originally written and uploaded by Lalufu (Ralf Ertzinger) in Feb 2012.
They have been condensed into a single patch and some further additions
by Andy Potter.
Currently includes Authentication V2 support from iPod to Accessory,
RF/BlueTooth transmitter support, selecting a playlist and selecting a
track from the current playlist. Does not support uploading Album Art
or podcasts. Has been tested on the following iPods,
4th Gen Grayscale, 4th Gen Color/Photo, Mini 2nd Gen, Nano 1st Gen and
Video 5.5Gen.
Change-Id: Ie8fc098361844132f0228ecbe3c48da948726f5e
Co-Authored by: Andy Potter <liveboxandy@gmail.com>
Reviewed-on: http://gerrit.rockbox.org/533
Reviewed-by: Frank Gevaerts <frank@gevaerts.be>
Diffstat (limited to 'tools/iap/ipod-001-general.t')
-rw-r--r-- | tools/iap/ipod-001-general.t | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/tools/iap/ipod-001-general.t b/tools/iap/ipod-001-general.t new file mode 100644 index 0000000000..f2b5451dbc --- /dev/null +++ b/tools/iap/ipod-001-general.t | |||
@@ -0,0 +1,133 @@ | |||
1 | use Test::More qw( no_plan ); | ||
2 | use strict; | ||
3 | |||
4 | BEGIN { use_ok('Device::iPod'); } | ||
5 | require_ok('Device::iPod'); | ||
6 | |||
7 | my $ipod = Device::iPod->new(); | ||
8 | my $m; | ||
9 | my ($l, $c, $p); | ||
10 | |||
11 | isa_ok($ipod, 'Device::iPod'); | ||
12 | |||
13 | $ipod->{-debug} = 1; | ||
14 | $ipod->open("/dev/ttyUSB0"); | ||
15 | |||
16 | $m = $ipod->sendraw("\xFF" x 16); # Wake up and sync | ||
17 | ok($m == 1, "Wakeup sent"); | ||
18 | |||
19 | # Empty the buffer | ||
20 | $ipod->emptyrecv(); | ||
21 | |||
22 | # Send a command with wrong checksum | ||
23 | # We expect no response (Timeout) | ||
24 | $m = $ipod->sendraw("\xff\x55\x02\x00\x03\x00"); | ||
25 | ok($m == 1, "Broken checksum sent"); | ||
26 | ($l, $c, $p) = $ipod->recvmsg(); | ||
27 | subtest "Timeout" => sub { | ||
28 | ok(!defined($l), "No response received"); | ||
29 | like($ipod->error(), '/Timeout/', "Timeout reading response"); | ||
30 | }; | ||
31 | |||
32 | # Empty the buffer | ||
33 | $ipod->emptyrecv(); | ||
34 | |||
35 | # Send a too short command | ||
36 | # We expect an ACK Bad Parameter as response | ||
37 | $m = $ipod->sendmsg(0x00, 0x13, ""); | ||
38 | ok($m == 1, "Short command sent"); | ||
39 | ($l, $c, $p) = $ipod->recvmsg(); | ||
40 | subtest "ACK Bad Parameter" => sub { | ||
41 | ok(defined($l), "Response received"); | ||
42 | is($l, 0x00, "Response lingo"); | ||
43 | is($c, 0x02, "Response command"); | ||
44 | is($p, "\x04\x13", "Response payload"); | ||
45 | }; | ||
46 | |||
47 | # Empty the buffer | ||
48 | $ipod->emptyrecv(); | ||
49 | |||
50 | # Send an undefined lingo | ||
51 | # We expect a timeout | ||
52 | $m = $ipod->sendmsg(0x1F, 0x00); | ||
53 | ok($m == 1, "Undefined lingo sent"); | ||
54 | ($l, $c, $p) = $ipod->recvmsg(); | ||
55 | subtest "Timeout" => sub { | ||
56 | ok(!defined($l), "No response received"); | ||
57 | like($ipod->error(), '/Timeout/', "Timeout reading response"); | ||
58 | }; | ||
59 | |||
60 | # Empty the buffer | ||
61 | $ipod->emptyrecv(); | ||
62 | |||
63 | # IdentifyDeviceLingoes(lingos=0x80000011, options=0x00, deviceid=0x00) | ||
64 | # We expect an ACK Command Failed message as response | ||
65 | $m = $ipod->sendmsg(0x00, 0x13, "\x80\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x00"); | ||
66 | ok($m == 1, "IdentifyDeviceLingoes(lingos=0x80000011, options=0x00, deviceid=0x00) sent"); | ||
67 | ($l, $c, $p) = $ipod->recvmsg(); | ||
68 | subtest "ACK Command Failed" => sub { | ||
69 | ok(defined($l), "Response received"); | ||
70 | is($l, 0x00, "Response lingo"); | ||
71 | is($c, 0x02, "Response command"); | ||
72 | is($p, "\x02\x13", "Response payload"); | ||
73 | }; | ||
74 | |||
75 | # Empty the buffer | ||
76 | $ipod->emptyrecv(); | ||
77 | |||
78 | # Identify(lingo=0xFF) | ||
79 | # We expect no response (timeout) | ||
80 | $m = $ipod->sendmsg(0x00, 0x01, "\xFF"); | ||
81 | ok($m == 1, "Identify(lingo=0xFF) sent"); | ||
82 | ($l, $c, $p) = $ipod->recvmsg(); | ||
83 | subtest "Timeout" => sub { | ||
84 | ok(!defined($l), "No response received"); | ||
85 | like($ipod->error(), '/Timeout/', "Timeout reading response"); | ||
86 | }; | ||
87 | |||
88 | # Empty the buffer | ||
89 | $ipod->emptyrecv(); | ||
90 | |||
91 | # IdentifyDeviceLingoes(lingos=0x10, options=0x00, deviceid=0x00) | ||
92 | # We expect an ACK Command Failed message as response | ||
93 | $m = $ipod->sendmsg(0x00, 0x13, "\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00"); | ||
94 | ok($m == 1, "IdentifyDeviceLingoes(lingos=0x10, options=0x00, deviceid=0x00) sent"); | ||
95 | ($l, $c, $p) = $ipod->recvmsg(); | ||
96 | subtest "ACK Command Failed" => sub { | ||
97 | ok(defined($l), "Response received"); | ||
98 | is($l, 0x00, "Response lingo"); | ||
99 | is($c, 0x02, "Response command"); | ||
100 | is($p, "\x02\x13", "Response payload"); | ||
101 | }; | ||
102 | |||
103 | # Empty the buffer | ||
104 | $ipod->emptyrecv(); | ||
105 | # IdentifyDeviceLingoes(lingos=0x00, options=0x00, deviceid=0x00) | ||
106 | # We expect an ACK Command Failed message as response | ||
107 | $m = $ipod->sendmsg(0x00, 0x13, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"); | ||
108 | ok($m == 1, "IdentifyDeviceLingoes(lingos=0x00, options=0x00, deviceid=0x00) sent"); | ||
109 | ($l, $c, $p) = $ipod->recvmsg(); | ||
110 | subtest "ACK Command Failed" => sub { | ||
111 | ok(defined($l), "Response received"); | ||
112 | is($l, 0x00, "Response lingo"); | ||
113 | is($c, 0x02, "Response command"); | ||
114 | is($p, "\x02\x13", "Response payload"); | ||
115 | }; | ||
116 | |||
117 | # Empty the buffer | ||
118 | $ipod->emptyrecv(); | ||
119 | |||
120 | # RequestLingoProtocolVersion(lingo=0xFF) | ||
121 | # We expect an ACK Bad Parameter message as response | ||
122 | $m = $ipod->sendmsg(0x00, 0x0F, "\xFF"); | ||
123 | ok($m == 1, "RequestLingoProtocolVersion(lingo=0xFF) sent"); | ||
124 | ($l, $c, $p) = $ipod->recvmsg(); | ||
125 | subtest "ACK Bad Parameter" => sub { | ||
126 | ok(defined($l), "Response received"); | ||
127 | is($l, 0x00, "Response lingo"); | ||
128 | is($c, 0x02, "Response command"); | ||
129 | is($p, "\x04\x0F", "Response payload"); | ||
130 | }; | ||
131 | |||
132 | # Empty the buffer | ||
133 | $ipod->emptyrecv(); | ||