diff options
Diffstat (limited to 'tools/iap/ipod-003-lingo2.t')
-rw-r--r-- | tools/iap/ipod-003-lingo2.t | 220 |
1 files changed, 220 insertions, 0 deletions
diff --git a/tools/iap/ipod-003-lingo2.t b/tools/iap/ipod-003-lingo2.t new file mode 100644 index 0000000000..ee0bd6972e --- /dev/null +++ b/tools/iap/ipod-003-lingo2.t | |||
@@ -0,0 +1,220 @@ | |||
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 | # 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"); | ||
25 | ok($m == 1, "IdentifyDeviceLingoes(lingos=0x01, options=0x00, deviceid=0x00) sent"); | ||
26 | ($l, $c, $p) = $ipod->recvmsg(); | ||
27 | subtest "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 | # ContextButtonStatus(0x00) | ||
38 | # We expect an ACK Bad Parameter message as response | ||
39 | $m = $ipod->sendmsg(0x02, 0x00, "\x00"); | ||
40 | ok($m == 1, "ContextButtonStatus(0x00)"); | ||
41 | ($l, $c, $p) = $ipod->recvmsg(); | ||
42 | subtest "ACK Bad Parameter" => sub { | ||
43 | ok(defined($l), "Response received"); | ||
44 | is($l, 0x02, "Response lingo"); | ||
45 | is($c, 0x01, "Response command"); | ||
46 | is($p, "\x04\x00", "Response payload"); | ||
47 | }; | ||
48 | |||
49 | # Empty the buffer | ||
50 | $ipod->emptyrecv(); | ||
51 | |||
52 | # Identify(lingo=0x00) | ||
53 | # We expect no response (timeout) | ||
54 | $m = $ipod->sendmsg(0x00, 0x01, "\x00"); | ||
55 | ok($m == 1, "Identify(lingo=0x00) sent"); | ||
56 | ($l, $c, $p) = $ipod->recvmsg(); | ||
57 | subtest "Timeout" => sub { | ||
58 | ok(!defined($l), "No response received"); | ||
59 | like($ipod->error(), '/Timeout/', "Timeout reading response"); | ||
60 | }; | ||
61 | |||
62 | # Empty the buffer | ||
63 | $ipod->emptyrecv(); | ||
64 | |||
65 | # ContextButtonStatus(0x00) | ||
66 | # We expect a timeout as response | ||
67 | $m = $ipod->sendmsg(0x02, 0x00, "\x00"); | ||
68 | ok($m == 1, "ContextButtonStatus(0x00)"); | ||
69 | ($l, $c, $p) = $ipod->recvmsg(); | ||
70 | subtest "Timeout" => sub { | ||
71 | ok(!defined($l), "Response received"); | ||
72 | like($ipod->error(), '/Timeout/', "Timeout reading response"); | ||
73 | }; | ||
74 | |||
75 | # Empty the buffer | ||
76 | $ipod->emptyrecv(); | ||
77 | |||
78 | # Identify(lingo=0x02) | ||
79 | # We expect no response (timeout) | ||
80 | $m = $ipod->sendmsg(0x00, 0x01, "\x02"); | ||
81 | ok($m == 1, "Identify(lingo=0x02) 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 | # ContextButtonStatus(0x00) | ||
92 | # We expect a timeout as response | ||
93 | $m = $ipod->sendmsg(0x02, 0x00, "\x00"); | ||
94 | ok($m == 1, "ContextButtonStatus(0x00)"); | ||
95 | ($l, $c, $p) = $ipod->recvmsg(); | ||
96 | subtest "Timeout" => sub { | ||
97 | ok(!defined($l), "Response received"); | ||
98 | like($ipod->error(), '/Timeout/', "Timeout reading response"); | ||
99 | }; | ||
100 | |||
101 | # Empty the buffer | ||
102 | $ipod->emptyrecv(); | ||
103 | |||
104 | # IdentifyDeviceLingoes(lingos=0x05, options=0x00, deviceid=0x00) | ||
105 | # We expect an ACK OK message as response | ||
106 | $m = $ipod->sendmsg(0x00, 0x13, "\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00"); | ||
107 | ok($m == 1, "IdentifyDeviceLingoes(lingos=0x05, options=0x00, deviceid=0x00) sent"); | ||
108 | ($l, $c, $p) = $ipod->recvmsg(); | ||
109 | subtest "ACK OK" => sub { | ||
110 | ok(defined($l), "Response received"); | ||
111 | is($l, 0x00, "Response lingo"); | ||
112 | is($c, 0x02, "Response command"); | ||
113 | is($p, "\x00\x13", "Response payload"); | ||
114 | }; | ||
115 | |||
116 | # Empty the buffer | ||
117 | $ipod->emptyrecv(); | ||
118 | |||
119 | # RequestLingoProtocolVersion(lingo=0x02) | ||
120 | # We expect a ReturnLingoProtocolVersion packet | ||
121 | $m = $ipod->sendmsg(0x00, 0x0F, "\x02"); | ||
122 | ok($m == 1, "RequestLingoProtocolVersion(lingo=0x02) sent"); | ||
123 | ($l, $c, $p) = $ipod->recvmsg(); | ||
124 | subtest "ReturnLingoProtocolVersion" => sub { | ||
125 | ok(defined($l), "Response received"); | ||
126 | is($l, 0x00, "Response lingo"); | ||
127 | is($c, 0x10, "Response command"); | ||
128 | like($p, "/^\\x02..\$/", "Response payload"); | ||
129 | }; | ||
130 | |||
131 | # Empty the buffer | ||
132 | $ipod->emptyrecv(); | ||
133 | |||
134 | # Send an undefined command | ||
135 | # We expect an ACK Bad Parameter as response | ||
136 | $m = $ipod->sendmsg(0x02, 0xFF); | ||
137 | ok($m == 1, "Undefined command sent"); | ||
138 | ($l, $c, $p) = $ipod->recvmsg(); | ||
139 | subtest "ACK Bad Parameter" => sub { | ||
140 | ok(defined($l), "Response received"); | ||
141 | is($l, 0x02, "Response lingo"); | ||
142 | is($c, 0x01, "Response command"); | ||
143 | is($p, "\x04\xFF", "Response payload"); | ||
144 | }; | ||
145 | |||
146 | # Empty the buffer | ||
147 | $ipod->emptyrecv(); | ||
148 | |||
149 | # ContextButtonStatus(0x00) | ||
150 | # We expect a timeout as response | ||
151 | $m = $ipod->sendmsg(0x02, 0x00, "\x00"); | ||
152 | ok($m == 1, "ContextButtonStatus(0x00)"); | ||
153 | ($l, $c, $p) = $ipod->recvmsg(); | ||
154 | subtest "Timeout" => sub { | ||
155 | ok(!defined($l), "Response received"); | ||
156 | like($ipod->error(), '/Timeout/', "Timeout reading response"); | ||
157 | }; | ||
158 | |||
159 | # Empty the buffer | ||
160 | $ipod->emptyrecv(); | ||
161 | |||
162 | # Send a too short command | ||
163 | # We expect an ACK Bad Parameter as response | ||
164 | $m = $ipod->sendmsg(0x02, 0x00, ""); | ||
165 | ok($m == 1, "Short command sent"); | ||
166 | ($l, $c, $p) = $ipod->recvmsg(); | ||
167 | subtest "ACK Bad Parameter" => sub { | ||
168 | ok(defined($l), "Response received"); | ||
169 | is($l, 0x02, "Response lingo"); | ||
170 | is($c, 0x01, "Response command"); | ||
171 | is($p, "\x04\x00", "Response payload"); | ||
172 | }; | ||
173 | |||
174 | # Empty the buffer | ||
175 | $ipod->emptyrecv(); | ||
176 | |||
177 | # ImageButtonStatus(0x00) | ||
178 | # We expect an ACK Not Authenticated as response | ||
179 | $m = $ipod->sendmsg(0x02, 0x02, "\x00"); | ||
180 | ok($m == 1, "ImageButtonStatus(0x00)"); | ||
181 | ($l, $c, $p) = $ipod->recvmsg(); | ||
182 | subtest "ACK Not Authenticated" => sub { | ||
183 | ok(defined($l), "Response received"); | ||
184 | is($l, 0x02, "Response lingo"); | ||
185 | is($c, 0x01, "Response command"); | ||
186 | is($p, "\x07\x02", "Response payload"); | ||
187 | }; | ||
188 | |||
189 | # Empty the buffer | ||
190 | $ipod->emptyrecv(); | ||
191 | |||
192 | # VideoButtonStatus(0x00) | ||
193 | # We expect an ACK Not Authenticated as response | ||
194 | $m = $ipod->sendmsg(0x02, 0x03, "\x00"); | ||
195 | ok($m == 1, "VideoButtonStatus(0x00)"); | ||
196 | ($l, $c, $p) = $ipod->recvmsg(); | ||
197 | subtest "ACK Not Authenticated" => sub { | ||
198 | ok(defined($l), "Response received"); | ||
199 | is($l, 0x02, "Response lingo"); | ||
200 | is($c, 0x01, "Response command"); | ||
201 | is($p, "\x07\x03", "Response payload"); | ||
202 | }; | ||
203 | |||
204 | # Empty the buffer | ||
205 | $ipod->emptyrecv(); | ||
206 | |||
207 | # AudioButtonStatus(0x00) | ||
208 | # We expect an ACK Not Authenticated as response | ||
209 | $m = $ipod->sendmsg(0x02, 0x04, "\x00"); | ||
210 | ok($m == 1, "AudioButtonStatus(0x00)"); | ||
211 | ($l, $c, $p) = $ipod->recvmsg(); | ||
212 | subtest "ACK Not Authenticated" => sub { | ||
213 | ok(defined($l), "Response received"); | ||
214 | is($l, 0x02, "Response lingo"); | ||
215 | is($c, 0x01, "Response command"); | ||
216 | is($p, "\x07\x04", "Response payload"); | ||
217 | }; | ||
218 | |||
219 | # Empty the buffer | ||
220 | $ipod->emptyrecv(); | ||