forked from memeruiz/usbtv007
-
Notifications
You must be signed in to change notification settings - Fork 1
/
protocol.py
417 lines (391 loc) · 16.5 KB
/
protocol.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# Copyright (c) 2013 Federico Ruiz Ugalde
# Author: Federico Ruiz-Ugalde <memeruiz at gmail dot com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
p4a=[
['cwvd', 0x0c, 0x0010, 0xf891, '', 0]
]
p4=[
['cwvd', 0x0c, 0x00a6, 0xc27d, '', 0],
['cwvd', 0x0c, 0x0011, 0xc280, '', 0],
['cwvd', 0x0c, 0x0040, 0xc281, '', 0],
['cwvd', 0x0c, 0x0011, 0xc282, '', 0],
['cwvd', 0x0c, 0x0040, 0xc283, '', 0],
['crvd', 0x0b, 0x0000, 0xf891, '', 1, [(0x10, p4a), (0x30, p4a)]]
]
p3a=[
['cwvd', 0x0c, 0x0002, 0xc27d, '', 0],
['cwvd', 0x0c, 0x0006, 0xc27d, '', 0],
['cwvd', 0x0c, 0x0026, 0xc27d, '', 0],
['cwvd', 0x0c, 0x0026, 0xc27d, '', 0]
]+p4
p3b=[
['cwvd', 0x0c, 0x00a6, 0xc27d, '', 0],
['cwvd', 0x0c, 0x00a6, 0xc27d, '', 0],
['cwvd', 0x0c, 0x00a6, 0xc27d, '', 0],
['cwvd', 0x0c, 0x00a6, 0xc27d, '', 0]
]+p4
p2c=[
['cwvd', 0x0c, 0x0086, 0xf894, '', 0],
['cwvd', 0x0c, 0x00c0, 0xc0ac, '', 0],
['cwvd', 0x0c, 0x0000, 0xc0ad, '', 0],
['cwvd', 0x0c, 0x0012, 0xc0a2, '', 0],
['cwvd', 0x0c, 0x00e0, 0xc0a3, '', 0],
['cwvd', 0x0c, 0x0028, 0xc0a4, '', 0],
['cwvd', 0x0c, 0x0082, 0xc0a5, '', 0],
['cwvd', 0x0c, 0x0080, 0xc0a7, '', 0],
['cwvd', 0x0c, 0x0014, 0xc000, '', 0],
['cwvd', 0x0c, 0x0003, 0xc006, '', 0],
['cwvd', 0x0c, 0x0099, 0xc090, '', 0],
['cwvd', 0x0c, 0x0090, 0xc091, '', 0],
['cwvd', 0x0c, 0x0068, 0xc094, '', 0],
['cwvd', 0x0c, 0x0070, 0xc095, '', 0],
['cwvd', 0x0c, 0x0030, 0xc09c, '', 0],
['cwvd', 0x0c, 0x00c0, 0xc09d, '', 0],
['cwvd', 0x0c, 0x00e0, 0xc09e, '', 0],
['cwvd', 0x0c, 0x0006, 0xc019, '', 0],
['cwvd', 0x0c, 0x00ba, 0xc08c, '', 0],
['cwvd', 0x0c, 0x00ff, 0xc101, '', 0],
['cwvd', 0x0c, 0x00b3, 0xc10c, '', 0],
['cwvd', 0x0c, 0x0080, 0xc1b2, '', 0],
['cwvd', 0x0c, 0x00a0, 0xc1b4, '', 0],
['cwvd', 0x0c, 0x00ff, 0xc14c, '', 0],
['cwvd', 0x0c, 0x00ca, 0xc14d, '', 0],
['cwvd', 0x0c, 0x0053, 0xc113, '', 0],
['cwvd', 0x0c, 0x008a, 0xc119, '', 0],
['cwvd', 0x0c, 0x0003, 0xc13c, '', 0],
['cwvd', 0x0c, 0x009c, 0xc150, '', 0],
['cwvd', 0x0c, 0x0071, 0xc151, '', 0],
['cwvd', 0x0c, 0x00c6, 0xc152, '', 0],
['cwvd', 0x0c, 0x0084, 0xc153, '', 0],
['cwvd', 0x0c, 0x00bc, 0xc154, '', 0],
['cwvd', 0x0c, 0x00a0, 0xc155, '', 0],
['cwvd', 0x0c, 0x00a0, 0xc156, '', 0],
['cwvd', 0x0c, 0x009c, 0xc157, '', 0],
['cwvd', 0x0c, 0x001f, 0xc158, '', 0],
['cwvd', 0x0c, 0x0006, 0xc159, '', 0],
['cwvd', 0x0c, 0x0000, 0xc15d, '', 0],
['crvd', 0x0b, 0x0000, 0xc27d, '', 1, [(0x00,p3a),(0xa6,p3b)]]
]
p2a=[
['cwvd', 0x0c, 0x000c, 0xf890, '', 0],
['crvd', 0x0b, 0x0000, 0xf894, '', 1, 0x86]
]+p2c
p2b=[
['cwvd', 0x0c, 0x000c, 0xf890, '', 0],
['crvd', 0x0b, 0x0000, 0xf894, '', 1, 0x87]
]+p2c
p2=[
['cwvd', 0x0c, 0x0032, 0xc27a, '', 0],
['crvd', 0x0b, 0x0000, 0xf890, '', 1, [(0x0c, p2a), (0x8c, p2b)]]
]
p1aa=[
['cwvd', 0x0c, 0x0030, 0xc27a, '', 0],
['cwvd', 0x0c, 0x0030, 0xc27a, '', 0],
['cwvd', 0x0c, 0x0032, 0xc27a, '', 0],
]+p2
p1ab=[
['cwvd', 0x0c, 0x0000, 0xc27a, '', 0],
['cwvd', 0x0c, 0x0010, 0xc27a, '', 0],
['cwvd', 0x0c, 0x0012, 0xc27a, '', 0]
]+p2
p1a=[
['cwvd', 0x0c, 0x0009, 0xc278, '', 0],
['cwvd', 0x0c, 0x000d, 0xc278, '', 0],
['cwvd', 0x0c, 0x002d, 0xc278, '', 0],
['crvd', 0x0b, 0x0000, 0xc279, '', 1, 0x00],
['cwvd', 0x0c, 0x0002, 0xc279, '', 0],
['cwvd', 0x0c, 0x000a, 0xc279, '', 0],
['crvd', 0x0b, 0x0000, 0xc27a, '', 1, [(0x30, p1aa), (0x00, p1ab)]]
]
p1b=[
['cwvd', 0x0c, 0x002d, 0xc278, '', 0],
['cwvd', 0x0c, 0x002d, 0xc278, '', 0],
['cwvd', 0x0c, 0x002d, 0xc278, '', 0],
['crvd', 0x0b, 0x0000, 0xc279, '', 1, 0x0a],
['cwvd', 0x0c, 0x000a, 0xc279, '', 0],
['cwvd', 0x0c, 0x000a, 0xc279, '', 0],
['crvd', 0x0b, 0x0000, 0xc27a, '', 1, 0x32],
['cwvd', 0x0c, 0x0032, 0xc27a, '', 0],
['cwvd', 0x0c, 0x0032, 0xc27a, '', 0]
]+p2
p_init=[
['crvd', 0x0b, 0x0000, 0xc278, '', 1, [(0x08, p1a), (0x2d, p1b)]]
]
p_preinit=[ #done during attachment in windows (most probably in the utv driver)
['crvd', 0x02, 0x00a0, 0x00f0, '', 2, (0x01, 0xdb), (True, False)], #0x15 0x9b 0xdb 0xd9
['crvd', 0x07, 0x00a0, 0x0015, '', 2, (0x00, 0x31)],
['crvd', 0x07, 0x00a2, 0x0000, '', 33, (0x00, 0x66, 0x01, 0x01, 0x68, 0x14, 0x14, 0x1f, 0x1f, 0x02, 0x40, 0x09, 0x04, 0x0d, 0x00, 0x00, 0x00, 0x71, 0x1b, 0x01, 0x30, 0x10, 0x31, 0x30, 0x6d, 0x6f, 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x00), [False]*33],
['crvd', 0x07, 0x00a2, 0x0020, '', 33, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x26, 0x55, 0x53, 0x42, 0x20, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x20), [False]*33],
['crvd', 0x07, 0x00a2, 0x0040, '', 33, (0, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1a, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x00), [False]*33],
['crvd', 0x07, 0x00a2, 0x0060, '', 33, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d, 0x71, 0x1b, 0x02, 0x30, 0x12, 0x66, 0x75, 0x73, 0x68, 0x69, 0x63, 0x61, 0x69, 0x00), [False]*33],
['crvd', 0x07, 0x00a2, 0x0080, '', 33, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x12, 0x75, 0x73, 0x62, 0x74, 0x76, 0x30, 0x30, 0x37, 0x00, 0x00), [False]*33],
['crvd', 0x07, 0x00a2, 0x00a0, '', 33, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1a, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30), [False]*33],
['crvd', 0x07, 0x00a2, 0x00c0, '', 33, (0, 0x32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x58, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa3, 0xf8, 0x33, 0x94), [False]*33],
['crvd', 0x07, 0x00a2, 0x00e0, '', 33, (0x00, 0xf8, 0x87, 0x7a, 0xc2, 0x00, 0x7b, 0xc2, 0x02, 0x7e, 0xc2, 0x01, 0x7f, 0xc2, 0x0b, 0xdc, 0xc1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), [False]*33],
# an interrupt in
['cwvd', 0x0c, 0x0001, 0xc008, '', 0],
['cwvd', 0x0c, 0x00ff, 0xc1d0, '', 0],
['cwvd', 0x0c, 0x0002, 0xc1d9, '', 0],
['cwvd', 0x0c, 0x0013, 0xc1da, '', 0],
['cwvd', 0x0c, 0x0012, 0xc1db, '', 0],
['cwvd', 0x0c, 0x0002, 0xc1e9, '', 0],
['cwvd', 0x0c, 0x006c, 0xc1ec, '', 0],
['cwvd', 0x0c, 0x0030, 0xc25b, '', 0],
['cwvd', 0x0c, 0x0073, 0xc254, '', 0],
['cwvd', 0x0c, 0x0020, 0xc294, '', 0],
['cwvd', 0x0c, 0x00cf, 0xc255, '', 0],
['cwvd', 0x0c, 0x0020, 0xc256, '', 0],
['cwvd', 0x0c, 0x0030, 0xc1eb, '', 0],
['cwvd', 0x0c, 0x0060, 0xc105, '', 0],
['cwvd', 0x0c, 0x00f2, 0xc11f, '', 0],
['cwvd', 0x0c, 0x0060, 0xc127, '', 0],
['cwvd', 0x0c, 0x0010, 0xc0ae, '', 0],
['cwvd', 0x0c, 0x00aa, 0xc284, '', 0],
['cwvd', 0x0c, 0x0004, 0xc003, '', 0],
['cwvd', 0x0c, 0x0068, 0xc01a, '', 0],
['cwvd', 0x0c, 0x00d3, 0xc100, '', 0],
['cwvd', 0x0c, 0x0072, 0xc10e, '', 0],
['cwvd', 0x0c, 0x00a2, 0xc10f, '', 0],
['cwvd', 0x0c, 0x00b0, 0xc112, '', 0],
['cwvd', 0x0c, 0x0015, 0xc115, '', 0],
['cwvd', 0x0c, 0x0001, 0xc117, '', 0],
['cwvd', 0x0c, 0x002c, 0xc118, '', 0],
['cwvd', 0x0c, 0x0010, 0xc12d, '', 0],
['cwvd', 0x0c, 0x0020, 0xc12f, '', 0],
['cwvd', 0x0c, 0x002e, 0xc220, '', 0],
['cwvd', 0x0c, 0x0008, 0xc225, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24e, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24f, '', 0],
['cwvd', 0x0c, 0x0059, 0xc254, '', 0],
['cwvd', 0x0c, 0x0016, 0xc25a, '', 0],
['cwvd', 0x0c, 0x0035, 0xc25b, '', 0],
['cwvd', 0x0c, 0x0017, 0xc263, '', 0],
['cwvd', 0x0c, 0x0016, 0xc266, '', 0],
['cwvd', 0x0c, 0x0036, 0xc267, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24e, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24f, '', 0],
['cwvd', 0x0c, 0x0040, 0xc239, '', 0],
['cwvd', 0x0c, 0x0000, 0xc240, '', 0],
['cwvd', 0x0c, 0x0000, 0xc241, '', 0],
['cwvd', 0x0c, 0x0002, 0xc242, '', 0],
['cwvd', 0x0c, 0x0080, 0xc243, '', 0],
['cwvd', 0x0c, 0x0012, 0xc244, '', 0],
['cwvd', 0x0c, 0x0090, 0xc245, '', 0],
['cwvd', 0x0c, 0x0000, 0xc246, '', 0],
]
p7=[
['crvd', 0x0b, 0x0000, 0xc245, '', 1, 0x90], #third call 4265f5
['crvd', 0x0b, 0x0000, 0xc242, '', 1, 0x02],
['crvd', 0x0b, 0x0000, 0xc243, '', 1, 0x80], #4 call 4265f5
['crvd', 0x0b, 0x0000, 0xc240, '', 1, 0x00],
['crvd', 0x0b, 0x0000, 0xc241, '', 1, 0x00], #5 call 4265f5
['cwvd', 0x0c, 0x0004, 0xc003, '', 0],
['cwvd', 0x0c, 0x0079, 0xc01a, '', 0],
['cwvd', 0x0c, 0x00d3, 0xc100, '', 0],
['cwvd', 0x0c, 0x0068, 0xc10e, '', 0], #new
['cwvd', 0x0c, 0x009c, 0xc10f, '', 0],
['cwvd', 0x0c, 0x00f0, 0xc112, '', 0],
['cwvd', 0x0c, 0x0015, 0xc115, '', 0],
['cwvd', 0x0c, 0x0000, 0xc117, '', 0],
['cwvd', 0x0c, 0x00fc, 0xc118, '', 0],
['cwvd', 0x0c, 0x0004, 0xc12d, '', 0],
['cwvd', 0x0c, 0x0008, 0xc12f, '', 0],
['cwvd', 0x0c, 0x002e, 0xc220, '', 0],
['cwvd', 0x0c, 0x0008, 0xc225, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24e, '', 0],
['cwvd', 0x0c, 0x0001, 0xc24f, '', 0],
['cwvd', 0x0c, 0x005f, 0xc254, '', 0],
['cwvd', 0x0c, 0x0012, 0xc25a, '', 0],
['cwvd', 0x0c, 0x0001, 0xc25b, '', 0],
['cwvd', 0x0c, 0x001c, 0xc263, '', 0],
['cwvd', 0x0c, 0x0011, 0xc266, '', 0],
#['cwvd', 0x0c, 0x0005, 0xc24e, '', 0],
['cwvd', 0x0c, 0x0005, 0xc267, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24e, '', 0],
['cwvd', 0x0c, 0x0002, 0xc24f, '', 0],
['cwvd', 0x0c, 0x00b8, 0xc16f, '', 0],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10], # 6 call
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88], # 7 call
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88],
['cwvd', 0x0c, 0x0060, 0xc105, '', 0],
['cwvd', 0x0c, 0x00f2, 0xc11f, '', 0],
['cwvd', 0x0c, 0x0060, 0xc127, '', 0],
['cwvd', 0x0c, 0x0010, 0xc0ae, '', 0],
['cwvd', 0x0c, 0x00aa, 0xc284, '', 0],
['cwvd', 0x0c, 0x0060, 0xc105, '', 0],
['cwvd', 0x0c, 0x00f2, 0xc11f, '', 0],
['cwvd', 0x0c, 0x0060, 0xc127, '', 0],
['cwvd', 0x0c, 0x0010, 0xc0ae, '', 0],
['cwvd', 0x0c, 0x00aa, 0xc284, '', 0]
]
p6b=[
['cwvd', 0x0c, 0x0060, 0xc105, '', 0],
['cwvd', 0x0c, 0x00f2, 0xc11f, '', 0],
['cwvd', 0x0c, 0x0060, 0xc127, '', 0],
['cwvd', 0x0c, 0x0010, 0xc0ae, '', 0],
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0xaa],
['cwvd', 0x0c, 0x0088, 0xc284, '', 0],
['crvd', 0x0b, 0x0000, 0xc244, '', 1, 0x12],
['crvd', 0x0b, 0x0000, 0xc246, '', 1, 0x00],
['crvd', 0x0b, 0x0000, 0xc244, '', 1, 0x12]
]+p7
p6a=[
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, 0x88], #first call gets to here 42b300
['crvd', 0x0b, 0x0000, 0xc244, '', 1, 0x11],
['crvd', 0x0b, 0x0000, 0xc246, '', 1, 0xcd], #second call 4265f5
['crvd', 0x0b, 0x0000, 0xc244, '', 1, 0x11]
]+p7
p5=[
['crvd', 0x0b, 0x0000, 0xc0ae, '', 1, 0x10],
['crvd', 0x0b, 0x0000, 0xc284, '', 1, [(0x88, p6a), (0xaa, p6b)]]
]
import usb1 as usb
def variable_for_value(value):
for n,v in globals().items():
if v == value:
return n
return None
def run_protocol(prot, devh):
print "TESTST"
for req_num, req in enumerate(prot):
print "line", req[0], hex(req[1]), hex(req[2]), hex(req[3]), req[4], req[5],
if len(req)>6:
if type(req[6])==list:
for i,j in req[6]:
print hex(i), variable_for_value(j),
elif type(req[6])==tuple:
print [hex(i) for i in req[6]],
else:
print hex(req[6]),
# print "req num", req_num
if req[0][0]=='c':
if req[0][2:]=='vd':
# print "Control request"
if req[0][1]=='r':
# print "Read"
reply=devh.controlRead(
usb.libusb1.LIBUSB_TYPE_VENDOR|usb.libusb1.LIBUSB_RECIPIENT_DEVICE,
req[1], req[2], req[3], req[5])
# if len(reply)==1:
# print "Reply:", hex(ord(reply))
# else:
# print "Reply:", [hex(ord(i)) for i in reply]
# print "Reply char:", reply
if type(req[6])==list:
# print " Multiply options"
found_prot=False
for resp, next_prot in req[6]:
if resp==ord(reply):
print "Found response in multiple options, running recursively"
print "Jumping to:" , variable_for_value(next_prot)
run_protocol(next_prot, devh)
found_prot=True
break
if not found_prot:
print "Unknown response!! Exiting!"
exit()
elif type(req[6])==tuple:
# print "Long answer"
#raw_input()
if len(req)==7:
if list(req[6])==[ord(i) for i in reply]:
# print " All fine"
pass
else:
print "Response incorrect!!! Exiting"
exit()
elif len(req)==8:
# print "Some reply may be ignored"
for reply, exp_reply, check in zip([ord(i) for i in reply], req[6], req[7]):
# print "Reply", reply, exp_reply, check
if check:
if reply==exp_reply:
# print "All fine"
pass
else:
print "Problems with reply!", reply, exp_reply, check
exit()
# else:
# print "Ignored reply"
#raw_input()
else:
if ord(reply)==req[6]:
# print "All fine!"
pass
else:
print "Error: Different reply"
exit()
elif req[0][1]=='w':
# print "Write"
reply=devh.controlWrite(
usb.libusb1.LIBUSB_TYPE_VENDOR|usb.libusb1.LIBUSB_RECIPIENT_DEVICE,
req[1], req[2], req[3], req[4])
print "Reply:", reply
if reply==req[5]:
# print "All fine!"
pass
else:
print "Error: More data send!"
exit()
else:
print "Not supported"