summaryrefslogtreecommitdiff
path: root/tools/iap/ipod-002-lingo0.t
diff options
context:
space:
mode:
Diffstat (limited to 'tools/iap/ipod-002-lingo0.t')
-rw-r--r--tools/iap/ipod-002-lingo0.t277
1 files changed, 277 insertions, 0 deletions
diff --git a/tools/iap/ipod-002-lingo0.t b/tools/iap/ipod-002-lingo0.t
new file mode 100644
index 0000000000..c3bb676553
--- /dev/null
+++ b/tools/iap/ipod-002-lingo0.t
@@ -0,0 +1,277 @@
1use Test::More qw( no_plan );
2use strict;
3
4BEGIN { use_ok('Device::iPod'); }
5require_ok('Device::iPod');
6
7my $ipod = Device::iPod->new();
8my $m;
9my ($l, $c, $p);
10
11isa_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
17ok($m == 1, "Wakeup sent");
18
19# Empty the buffer
20$ipod->emptyrecv();
21
22# IdentifyDeviceLingoes(lingos=0x01, options=0x00, deviceid=0x00)
23# We expect an ACK OK message as response
24$m = $ipod->sendmsg(0x00, 0x13, "\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00");
25ok($m == 1, "IdentifyDeviceLingoes(lingos=0x01, options=0x00, deviceid=0x00) sent");
26($l, $c, $p) = $ipod->recvmsg();
27subtest "ACK OK" => sub {
28 ok(defined($l), "Response received");
29 is($l, 0x00, "Response lingo");
30 is($c, 0x02, "Response command");
31 is($p, "\x00\x13", "Response payload");
32};
33
34# Empty the buffer
35$ipod->emptyrecv();
36
37# RequestRemoteUIMode
38# We expect an ACK Bad Parameter as response, as we have not
39# negotiated lingo 0x04
40$m = $ipod->sendmsg(0x00, 0x03);
41ok($m == 1, "RequestRemoteUIMode sent");
42($l, $c, $p) = $ipod->recvmsg();
43subtest "ACK Bad Parameter" => sub {
44 ok(defined($l), "Response received");
45 is($l, 0x00, "Response lingo");
46 is($c, 0x02, "Response command");
47 is($p, "\x04\x03", "Response payload");
48};
49
50# Empty the buffer
51$ipod->emptyrecv();
52
53# EnterRemoteUIMode
54# We expect an ACK Bad Parameter as response, as we have not
55# negotiated lingo 0x04
56$m = $ipod->sendmsg(0x00, 0x05);
57ok($m == 1, "EnterRemoteUIMode sent");
58($l, $c, $p) = $ipod->recvmsg();
59subtest "ACK Bad Parameter" => sub {
60 ok(defined($l), "Response received");
61 is($l, 0x00, "Response lingo");
62 is($c, 0x02, "Response command");
63 is($p, "\x04\x05", "Response payload");
64};
65
66# Empty the buffer
67$ipod->emptyrecv();
68
69# ExitRemoteUIMode
70# We expect an ACK Bad Parameter as response, as we have not
71# negotiated lingo 0x04
72$m = $ipod->sendmsg(0x00, 0x06);
73ok($m == 1, "ExitRemoteUIMode sent");
74($l, $c, $p) = $ipod->recvmsg();
75subtest "ACK Bad Parameter" => sub {
76 ok(defined($l), "Response received");
77 is($l, 0x00, "Response lingo");
78 is($c, 0x02, "Response command");
79 is($p, "\x04\x06", "Response payload");
80};
81
82# Empty the buffer
83$ipod->emptyrecv();
84
85# RequestiPodName
86# We expect a ReturniPodName packet
87$m = $ipod->sendmsg(0x00, 0x07);
88ok($m == 1, "RequestiPodName sent");
89($l, $c, $p) = $ipod->recvmsg();
90subtest "ReturniPodName" => sub {
91 ok(defined($l), "Response received");
92 is($l, 0x00, "Response lingo");
93 is($c, 0x08, "Response command");
94 like($p, "/^[^\\x00]*\\x00\$/", "Response payload");
95};
96
97# Empty the buffer
98$ipod->emptyrecv();
99
100# RequestiPodSoftwareVersion
101# We expect a ReturniPodSoftwareVersion packet
102$m = $ipod->sendmsg(0x00, 0x09);
103ok($m == 1, "RequestiPodSoftwareVersion sent");
104($l, $c, $p) = $ipod->recvmsg();
105subtest "ReturniPodSoftwareVersion" => sub {
106 ok(defined($l), "Response received");
107 is($l, 0x00, "Response lingo");
108 is($c, 0x0A, "Response command");
109 like($p, "/^...\$/", "Response payload");
110};
111
112# Empty the buffer
113$ipod->emptyrecv();
114
115# RequestiPodSerialNumber
116# We expect a ReturniPodSerialNumber packet
117$m = $ipod->sendmsg(0x00, 0x0B);
118ok($m == 1, "RequestiPodSerialNumber sent");
119($l, $c, $p) = $ipod->recvmsg();
120subtest "ReturniPodSerialNumber" => sub {
121 ok(defined($l), "Response received");
122 is($l, 0x00, "Response lingo");
123 is($c, 0x0C, "Response command");
124 like($p, "/^[^\\x00]*\\x00\$/", "Response payload");
125};
126
127# Empty the buffer
128$ipod->emptyrecv();
129
130# RequestiPodModelNum
131# We expect a ReturniPodModelNum packet
132$m = $ipod->sendmsg(0x00, 0x0D);
133ok($m == 1, "RequestiPodModelNum sent");
134($l, $c, $p) = $ipod->recvmsg();
135subtest "ReturniPodModelNum" => sub {
136 ok(defined($l), "Response received");
137 is($l, 0x00, "Response lingo");
138 is($c, 0x0E, "Response command");
139 like($p, "/^....[^\\x00]*\\x00\$/", "Response payload");
140};
141
142# Empty the buffer
143$ipod->emptyrecv();
144
145# RequestLingoProtocolVersion(lingo=0x00)
146# We expect a ReturnLingoProtocolVersion packet
147$m = $ipod->sendmsg(0x00, 0x0F, "\x00");
148ok($m == 1, "RequestLingoProtocolVersion(lingo=0x00) sent");
149($l, $c, $p) = $ipod->recvmsg();
150subtest "ReturnLingoProtocolVersion" => sub {
151 ok(defined($l), "Response received");
152 is($l, 0x00, "Response lingo");
153 is($c, 0x10, "Response command");
154 like($p, "/^\\x00..\$/", "Response payload");
155};
156
157# Empty the buffer
158$ipod->emptyrecv();
159
160# IdentifyDeviceLingoes(lingos=0x11, options=0x00, deviceid=0x00)
161# We expect an ACK OK message as response
162$m = $ipod->sendmsg(0x00, 0x13, "\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x00");
163ok($m == 1, "IdentifyDeviceLingoes(lingos=0x11, options=0x00, deviceid=0x00) sent");
164($l, $c, $p) = $ipod->recvmsg();
165subtest "ACK OK" => sub {
166 ok(defined($l), "Response received");
167 is($l, 0x00, "Response lingo");
168 is($c, 0x02, "Response command");
169 is($p, "\x00\x13", "Response payload");
170};
171
172# Empty the buffer
173$ipod->emptyrecv();
174
175# RequestRemoteUIMode
176# We expect an ReturnRemoteUIMode packet specifying standard mode
177$m = $ipod->sendmsg(0x00, 0x03);
178ok($m == 1, "RequestRemoteUIMode sent");
179($l, $c, $p) = $ipod->recvmsg();
180subtest "ReturnRemoteUIMode" => sub {
181 ok(defined($l), "Response received");
182 is($l, 0x00, "Response lingo");
183 is($c, 0x04, "Response command");
184 is($p, "\x00", "Response payload");
185};
186
187# Empty the buffer
188$ipod->emptyrecv();
189
190# EnterRemoteUIMode
191# We expect an ACK Pending packet, followed by an ACK OK packet
192$m = $ipod->sendmsg(0x00, 0x05);
193ok($m == 1, "EnterRemoteUIMode sent");
194($l, $c, $p) = $ipod->recvmsg();
195subtest "ACK Pending" => sub {
196 ok(defined($l), "Response received");
197 is($l, 0x00, "Response lingo");
198 is($c, 0x02, "Response command");
199 like($p, "/^\\x06\\x05/", "Response payload");
200};
201($l, $c, $p) = $ipod->recvmsg();
202subtest "ACK OK" => sub {
203 ok(defined($l), "Response received");
204 is($l, 0x00, "Response lingo");
205 is($c, 0x02, "Response command");
206 is($p, "\x00\x05", "Response payload");
207};
208
209# Empty the buffer
210$ipod->emptyrecv();
211
212# RequestRemoteUIMode
213# We expect an ReturnRemoteUIMode packet specifying extended mode
214$m = $ipod->sendmsg(0x00, 0x03);
215ok($m == 1, "RequestRemoteUIMode sent");
216($l, $c, $p) = $ipod->recvmsg();
217subtest "ReturnRemoteUIMode" => sub {
218 ok(defined($l), "Response received");
219 is($l, 0x00, "Response lingo");
220 is($c, 0x04, "Response command");
221 isnt($p, "\x00", "Response payload");
222};
223
224# Empty the buffer
225$ipod->emptyrecv();
226
227# ExitRemoteUIMode
228# We expect an ACK Pending packet, followed by an ACK OK packet
229$m = $ipod->sendmsg(0x00, 0x06);
230ok($m == 1, "ExitRemoteUIMode sent");
231($l, $c, $p) = $ipod->recvmsg();
232subtest "ACK Pending" => sub {
233 ok(defined($l), "Response received");
234 is($l, 0x00, "Response lingo");
235 is($c, 0x02, "Response command");
236 like($p, "/^\\x06\\x06/", "Response payload");
237};
238($l, $c, $p) = $ipod->recvmsg();
239subtest "ACK OK" => sub {
240 ok(defined($l), "Response received");
241 is($l, 0x00, "Response lingo");
242 is($c, 0x02, "Response command");
243 is($p, "\x00\x06", "Response payload");
244};
245
246# Empty the buffer
247$ipod->emptyrecv();
248
249# RequestRemoteUIMode
250# We expect an ReturnRemoteUIMode packet specifying standard mode
251$m = $ipod->sendmsg(0x00, 0x03);
252ok($m == 1, "RequestRemoteUIMode sent");
253($l, $c, $p) = $ipod->recvmsg();
254subtest "ReturnRemoteUIMode" => sub {
255 ok(defined($l), "Response received");
256 is($l, 0x00, "Response lingo");
257 is($c, 0x04, "Response command");
258 is($p, "\x00", "Response payload");
259};
260
261# Empty the buffer
262$ipod->emptyrecv();
263
264# Send an undefined command
265# We expect an ACK Bad Parameter as response
266$m = $ipod->sendmsg(0x00, 0xFF);
267ok($m == 1, "Undefined command sent");
268($l, $c, $p) = $ipod->recvmsg();
269subtest "ACK Bad Parameter" => sub {
270 ok(defined($l), "Response received");
271 is($l, 0x00, "Response lingo");
272 is($c, 0x02, "Response command");
273 is($p, "\x04\xFF", "Response payload");
274};
275
276# Empty the buffer
277$ipod->emptyrecv();