|
1 #ifndef __CONTROL_TRANSFER_REQUESTS_H |
|
2 #define __CONTROL_TRANSFER_REQUESTS_H |
|
3 |
|
4 /* |
|
5 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
6 * All rights reserved. |
|
7 * This component and the accompanying materials are made available |
|
8 * under the terms of the License "Eclipse Public License v1.0" |
|
9 * which accompanies this distribution, and is available |
|
10 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
11 * |
|
12 * Initial Contributors: |
|
13 * Nokia Corporation - initial contribution. |
|
14 * |
|
15 * Contributors: |
|
16 * |
|
17 * Description: |
|
18 * @file ControlTransferRequests.h |
|
19 * @internalComponent |
|
20 * |
|
21 * |
|
22 */ |
|
23 |
|
24 |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <e32ver.h> |
|
28 #include <d32usbdi.h> |
|
29 |
|
30 namespace NUnitTesting_USBDI |
|
31 { |
|
32 |
|
33 //These values MUST be kept in line with each other |
|
34 const _LIT8(KNumberFormatString, "%08d"); |
|
35 const TUint KNumberStringLength = 8; |
|
36 |
|
37 //These values MUST be kept in line with each other |
|
38 const _LIT8(KTwoNumberFormatString, "%08d%08d"); |
|
39 const TUint KTwoNumberStringLength = 16; |
|
40 |
|
41 //These values MUST be kept in line with each other |
|
42 const _LIT8(KSplitWriteNumberFormatString, "%08d%08d%08d"); |
|
43 const TUint KSplitWriteNumberStringLength = 24; |
|
44 const TUint KNumSplitWriteSections = 3; |
|
45 |
|
46 //These values MUST be kept in line with each other |
|
47 const _LIT8(KClientPassString, "PASS"); |
|
48 const _LIT8(KClientFailString, "FAIL"); |
|
49 const TUint KPassFailStringLength = 4; |
|
50 |
|
51 const TUint KTestBufferLength = 32; //must be more than KPassFailStringLength |
|
52 |
|
53 const TUint KMaxSendSize = 2048; |
|
54 |
|
55 |
|
56 |
|
57 // ------------- bRequest ----------------- |
|
58 const TUint8 KVendorEmptyRequest(0x00); |
|
59 const TUint8 KVendorPutPayloadRequest(0x01); |
|
60 const TUint8 KVendorGetPayloadRequest(0x02); |
|
61 const TUint8 KVendorGetRecordedNumBytesReadInPayloadRequest (0x03); |
|
62 const TUint8 KVendorGetRecordedNumBytesWrittenInPayloadRequest (0x04); |
|
63 const TUint8 KVendorStallRequest(0x05); |
|
64 const TUint8 KVendorRemoteWakeupRequest(0x06); |
|
65 const TUint8 KVendorReconnectRequest(0x07); |
|
66 const TUint8 KVendorWriteToEndpointRequest(0x08); |
|
67 const TUint8 KVendorPatternWriteToEndpointRequest(0x09); |
|
68 const TUint8 KVendorCancelWriteToEndpointRequest(0x0a); |
|
69 const TUint8 KVendorPatternWriteSynchronousToEndpointRequest(0x0b); |
|
70 const TUint8 KVendorPatternWriteSynchronousToAndHaltEndpointRequest(0x0c); |
|
71 const TUint8 KVendorStringValidationRequest(0x0d); |
|
72 const TUint8 KVendorWriteSynchronousCachedReadRequest(0x0e); |
|
73 const TUint8 KVendorWriteCachedReadRequest(0x0f); |
|
74 const TUint8 KVendorRepeatedPatternWriteDataRequest (0x10); |
|
75 const TUint8 KVendorSplitWriteSynchronousCachedReadRequest(0x11); |
|
76 const TUint8 KVendorReadFromEndpointRequest(0x12); |
|
77 const TUint8 KVendorReadUntilShortFromEndpointRequest(0x13); |
|
78 const TUint8 KVendorReadFromAndHaltEndpointRequest(0x14); |
|
79 const TUint8 KVendorRepeatedReadAndValidateDataRequest(0x15); |
|
80 const TUint8 KVendorRecordedValidationResultRequest (0x16); |
|
81 const TUint8 KVendorCancelAnyReadFromEndpointRequest (0x17); |
|
82 const TUint8 KVendorTestCasePassed(0x20); |
|
83 const TUint8 KVendorTestCaseFailed(0x21); |
|
84 const TUint8 KVendorUnrespondRequest(0x22); |
|
85 const TUint8 KVendorDisconnectDeviceAThenConnectDeviceCRequest(0x23); |
|
86 const TUint8 KVendorDisconnectDeviceCThenConnectDeviceARequest(0x24); |
|
87 |
|
88 // class specific |
|
89 // audio |
|
90 const TUint8 KAudioClassSetCur(0x01); |
|
91 |
|
92 // ------------- bmRequestType ----------------- |
|
93 |
|
94 // D7: Data phase transfer direction |
|
95 const TUint8 KHostToDevice(0x00); |
|
96 const TUint8 KDeviceToHost(0x80); |
|
97 |
|
98 // D6..5: Type |
|
99 const TUint8 KTypeStandard(0x00); |
|
100 const TUint8 KTypeClass(0x20); |
|
101 const TUint8 KTypeVendor(0x40); |
|
102 |
|
103 // D4..0: Recipient |
|
104 const TUint8 KRecipientDevice(0x00); |
|
105 const TUint8 KRecipientInterface(0x01); |
|
106 const TUint8 KRecipientEndpoint(0x02); |
|
107 const TUint8 KRecipientOther(0x03); |
|
108 |
|
109 // ------------------------------------------------------------------ |
|
110 |
|
111 // The customised requests (i.e. non standard control requests) |
|
112 |
|
113 // ------------------------------------------------------------------ |
|
114 |
|
115 /** |
|
116 This policy class represents the basic control request setup packet |
|
117 that the user will derive from and customise to describe usable control requests |
|
118 otherwise with the default values it represents a 'standard device request' |
|
119 */ |
|
120 class TControlSetupPacket : public ::RUsbInterface::TUsbTransferRequestDetails |
|
121 { |
|
122 protected: |
|
123 TControlSetupPacket() |
|
124 { |
|
125 iRequestType = 0; |
|
126 iRequest = 0; |
|
127 iValue = 0; |
|
128 iIndex = 0; |
|
129 } |
|
130 }; |
|
131 |
|
132 /** |
|
133 This class represents a control request to the client that does not request |
|
134 data from the client. It merely instructs the client |
|
135 */ |
|
136 class TEmptyRequest : public TControlSetupPacket |
|
137 { |
|
138 protected: |
|
139 TEmptyRequest() |
|
140 { |
|
141 iRequestType |= KHostToDevice; |
|
142 iRequestType |= KTypeVendor; |
|
143 iRequest = KVendorEmptyRequest; |
|
144 } |
|
145 }; |
|
146 |
|
147 /** |
|
148 */ |
|
149 class TDataSendRequest : public TControlSetupPacket |
|
150 { |
|
151 friend class CEp0Transfer; |
|
152 |
|
153 protected: |
|
154 TDataSendRequest() |
|
155 { |
|
156 iRequestType |= KHostToDevice; |
|
157 iRequestType |= KTypeVendor; |
|
158 } |
|
159 |
|
160 explicit TDataSendRequest(const TDesC8& aData) |
|
161 { |
|
162 iRequestType |= KHostToDevice; |
|
163 iRequestType |= KTypeVendor; |
|
164 iSendData.Copy(aData); |
|
165 } |
|
166 |
|
167 explicit TDataSendRequest(const TDesC16& aData) |
|
168 { |
|
169 iRequestType |= KHostToDevice; |
|
170 iRequestType |= KTypeVendor; |
|
171 iSendData.Copy(aData); |
|
172 } |
|
173 protected: |
|
174 TBuf8<KMaxSendSize> iSendData; |
|
175 }; |
|
176 |
|
177 |
|
178 /** |
|
179 */ |
|
180 class TClassDataSendRequest : public TControlSetupPacket |
|
181 { |
|
182 friend class CEp0Transfer; |
|
183 |
|
184 protected: |
|
185 explicit TClassDataSendRequest(const TDesC8& aData) |
|
186 { |
|
187 iRequestType |= KHostToDevice; |
|
188 iRequestType |= KTypeClass; |
|
189 iSendData.Copy(aData); |
|
190 } |
|
191 |
|
192 explicit TClassDataSendRequest(const TDesC16& aData) |
|
193 { |
|
194 iRequestType |= KHostToDevice; |
|
195 iRequestType |= KTypeClass; |
|
196 iSendData.Copy(aData); |
|
197 } |
|
198 protected: |
|
199 TBuf8<KMaxSendSize> iSendData; |
|
200 }; |
|
201 |
|
202 |
|
203 /** |
|
204 This class represents a control request to the client that requests some data |
|
205 in response to the request |
|
206 */ |
|
207 class TDataRecvRequest : public TControlSetupPacket |
|
208 { |
|
209 friend class CEp0Transfer; |
|
210 |
|
211 protected: |
|
212 explicit TDataRecvRequest(TDes8& aData) : iRecvData(aData) |
|
213 { |
|
214 iRequestType |= KDeviceToHost; |
|
215 iRequestType |= KTypeVendor; |
|
216 } |
|
217 |
|
218 protected: |
|
219 TDes8& iRecvData; |
|
220 }; |
|
221 |
|
222 |
|
223 /** |
|
224 */ |
|
225 class TDescriptorGetRequest : public TDataRecvRequest |
|
226 { |
|
227 public: |
|
228 /** |
|
229 Constructor, build a request to fetch a descriptor from the device |
|
230 @param aTypeAndIndex the type of the descriptor and the index |
|
231 @param aLanguage Id the identity of the language |
|
232 @param aData the symbian descriptor to hold the usb descriptor data |
|
233 */ |
|
234 |
|
235 TDescriptorGetRequest(TUint16 aTypeAndIndex,TUint16 aLanguageId,TDes8& aData) |
|
236 : TDataRecvRequest(aData) |
|
237 { |
|
238 iRequestType = 0; // Will overwrite KTypeVendor in base class |
|
239 iRequestType |= KDeviceToHost; |
|
240 iRequest = 0x06; // Standard device GET_DESCRIPTOR |
|
241 iValue = aTypeAndIndex; |
|
242 iIndex = aLanguageId; |
|
243 } |
|
244 }; |
|
245 |
|
246 |
|
247 /** |
|
248 This class represents an empty request that is directed at the device. |
|
249 i.e. a request that does not require data from the client device |
|
250 */ |
|
251 class TEmptyDeviceRequest : public TEmptyRequest |
|
252 { |
|
253 public: |
|
254 TEmptyDeviceRequest() |
|
255 { |
|
256 iRequestType |= KRecipientDevice; |
|
257 } |
|
258 }; |
|
259 |
|
260 /** |
|
261 This class represents an empty request that is directed at the interface. |
|
262 i.e. a request that does not require data from the client interface |
|
263 */ |
|
264 class TEmptyInterfaceRequest : public TEmptyRequest |
|
265 { |
|
266 public: |
|
267 explicit TEmptyInterfaceRequest(TUint16 aInterfaceNumber) |
|
268 { |
|
269 iRequestType |= KRecipientInterface; |
|
270 iIndex = aInterfaceNumber; |
|
271 } |
|
272 }; |
|
273 |
|
274 /** |
|
275 This class represents a device directed request that send a payload |
|
276 */ |
|
277 class TDevicePutPayloadRequest : public TDataSendRequest |
|
278 { |
|
279 public: |
|
280 TDevicePutPayloadRequest(const TDesC8& aData) : TDataSendRequest(aData) |
|
281 { |
|
282 iRequestType |= KRecipientDevice; |
|
283 iRequest = KVendorPutPayloadRequest; |
|
284 iValue = 0; |
|
285 iIndex = 0; |
|
286 } |
|
287 }; |
|
288 |
|
289 /** |
|
290 This class represents a device directed request that retrieves a payload |
|
291 from the client device |
|
292 */ |
|
293 class TDeviceGetPayloadRequest : public TDataRecvRequest |
|
294 { |
|
295 public: |
|
296 explicit TDeviceGetPayloadRequest(TDes8& aData) : TDataRecvRequest(aData) |
|
297 { |
|
298 iRequestType |= KRecipientDevice; |
|
299 iRequest = KVendorGetPayloadRequest; |
|
300 iValue = 0; |
|
301 iIndex = 0; |
|
302 } |
|
303 }; |
|
304 |
|
305 /** |
|
306 This class represents a device directed request that retrieves a payload |
|
307 from the client device containing the number of bytes read on an endpoint |
|
308 performing a 'Repeated Read'. |
|
309 */ |
|
310 class TInterfaceGetRecordedNumBytesReadInPayload : public TDataRecvRequest |
|
311 { |
|
312 public: |
|
313 explicit TInterfaceGetRecordedNumBytesReadInPayload(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,TDes8& aData) : TDataRecvRequest(aData) |
|
314 { |
|
315 iRequestType |= KRecipientInterface; |
|
316 iRequest = KVendorGetRecordedNumBytesReadInPayloadRequest; |
|
317 iValue = aReadEndpointNumber; |
|
318 iIndex = aInterfaceNumber; |
|
319 } |
|
320 }; |
|
321 |
|
322 /** |
|
323 This class represents a device directed request that retrieves a payload |
|
324 from the client device containing the number of bytes written on an endpoint |
|
325 performing a 'Repeated Write'. |
|
326 */ |
|
327 class TInterfaceGetRecordedNumBytesWrittenInPayload : public TDataRecvRequest |
|
328 { |
|
329 public: |
|
330 explicit TInterfaceGetRecordedNumBytesWrittenInPayload(const TUint16 aInterfaceNumber,const TUint8 aWriteEndpointNumber,TDes8& aData) : TDataRecvRequest(aData) |
|
331 { |
|
332 iRequestType |= KRecipientInterface; |
|
333 iRequest = KVendorGetRecordedNumBytesWrittenInPayloadRequest; |
|
334 iValue = aWriteEndpointNumber; |
|
335 iIndex = aInterfaceNumber; |
|
336 } |
|
337 }; |
|
338 |
|
339 |
|
340 |
|
341 /** |
|
342 This class represents an interface directed request that sends a payload |
|
343 */ |
|
344 class TInterfacePutPayloadRequest : public TDataSendRequest |
|
345 { |
|
346 public: |
|
347 TInterfacePutPayloadRequest(TUint16 aInterfaceNumber,const TDesC8& aData) : TDataSendRequest(aData) |
|
348 { |
|
349 iRequestType |= KRecipientInterface; |
|
350 iRequest = KVendorPutPayloadRequest; |
|
351 iValue = 0; |
|
352 iIndex = aInterfaceNumber; |
|
353 } |
|
354 }; |
|
355 |
|
356 /** |
|
357 This class represents a device directed request that retrieves a payload |
|
358 from the client device |
|
359 */ |
|
360 class TInterfaceGetPayloadRequest : public TDataRecvRequest |
|
361 { |
|
362 public: |
|
363 explicit TInterfaceGetPayloadRequest(TUint16 aInterfaceNumber,TDes8& aData) : TDataRecvRequest(aData) |
|
364 { |
|
365 iRequestType |= KRecipientInterface; |
|
366 iRequest = KVendorGetPayloadRequest; |
|
367 iValue = 0; |
|
368 iIndex = aInterfaceNumber; |
|
369 } |
|
370 }; |
|
371 |
|
372 /** |
|
373 This class represents a control request to stall a specified endpoint |
|
374 */ |
|
375 class TInterfaceEndpointBaseRequest : public TEmptyRequest |
|
376 { |
|
377 public: |
|
378 /** |
|
379 Constructor, build a request containing a specified endpoint and a specified interface |
|
380 @param aEndpointNumber the endpoint to use |
|
381 @param aInterfaceNumber the interface to use |
|
382 */ |
|
383 |
|
384 TInterfaceEndpointBaseRequest(TUint16 aEndpointNumber,TUint16 aInterfaceNumber) |
|
385 : TEmptyRequest() |
|
386 { |
|
387 iRequestType |= KRecipientInterface; |
|
388 iValue = aEndpointNumber; |
|
389 iIndex = aInterfaceNumber; |
|
390 } |
|
391 }; |
|
392 |
|
393 /** |
|
394 This class represents a control request to stall a specified endpoint |
|
395 */ |
|
396 class TStallEndpointRequest : public TInterfaceEndpointBaseRequest |
|
397 { |
|
398 public: |
|
399 /** |
|
400 Constructor, build a request to stall a specified endpoint |
|
401 @param aEndpointNumber the endpoint to stall |
|
402 */ |
|
403 |
|
404 TStallEndpointRequest(TUint16 aEndpointNumber,TUint16 aInterfaceNumber) |
|
405 : TInterfaceEndpointBaseRequest(aEndpointNumber, aInterfaceNumber) |
|
406 { |
|
407 iRequest = KVendorStallRequest; |
|
408 } |
|
409 }; |
|
410 |
|
411 /** |
|
412 This class represents a control request to use a validation previously recorded in the endpoint |
|
413 to update the interface's PASS\FAIL string. |
|
414 */ |
|
415 class TRecordedValidationResultRequest : public TInterfaceEndpointBaseRequest |
|
416 { |
|
417 public: |
|
418 /** |
|
419 Constructor, build a request to update the interface's PASS\FAIL |
|
420 string using a previously recorded validation. |
|
421 @param aEndpointNumber the endpoint to from which to retrieve the previously recorded validation |
|
422 */ |
|
423 |
|
424 TRecordedValidationResultRequest(TUint16 aEndpointNumber,TUint16 aInterfaceNumber) |
|
425 : TInterfaceEndpointBaseRequest(aEndpointNumber, aInterfaceNumber) |
|
426 { |
|
427 iRequest = KVendorRecordedValidationResultRequest; |
|
428 } |
|
429 }; |
|
430 |
|
431 /** |
|
432 This class represents a control request to stall a specified endpoint |
|
433 */ |
|
434 class TEndpointCancelWriteRequest : public TInterfaceEndpointBaseRequest |
|
435 { |
|
436 public: |
|
437 /** |
|
438 Constructor, build a request to stall a specified endpoint |
|
439 @param aEndpointNumber the endpoint to stall |
|
440 */ |
|
441 |
|
442 TEndpointCancelWriteRequest(TUint16 aEndpointNumber,TUint16 aInterfaceNumber) |
|
443 : TInterfaceEndpointBaseRequest(aEndpointNumber, aInterfaceNumber) |
|
444 { |
|
445 iRequest = KVendorCancelWriteToEndpointRequest; |
|
446 } |
|
447 }; |
|
448 |
|
449 /** |
|
450 This class represents a control request to stall a specified endpoint |
|
451 */ |
|
452 class TEndpointCancelReadRequest : public TInterfaceEndpointBaseRequest |
|
453 { |
|
454 public: |
|
455 /** |
|
456 Constructor, build a request to stall a specified endpoint |
|
457 @param aEndpointNumber the endpoint to stall |
|
458 */ |
|
459 |
|
460 TEndpointCancelReadRequest(TUint16 aEndpointNumber,TUint16 aInterfaceNumber) |
|
461 : TInterfaceEndpointBaseRequest(aEndpointNumber, aInterfaceNumber) |
|
462 { |
|
463 iRequest = KVendorCancelAnyReadFromEndpointRequest; |
|
464 } |
|
465 }; |
|
466 |
|
467 /** |
|
468 This class represents a control request to the device to initiate a remote |
|
469 wake-up after the supplied interval has elapsed. |
|
470 */ |
|
471 class TRemoteWakeupRequest : public TEmptyRequest |
|
472 { |
|
473 public: |
|
474 explicit TRemoteWakeupRequest(TUint16 aWakeupInterval) |
|
475 { |
|
476 iRequestType |= KRecipientDevice; |
|
477 iRequest = KVendorRemoteWakeupRequest; |
|
478 iValue = aWakeupInterval; |
|
479 } |
|
480 }; |
|
481 |
|
482 /** |
|
483 This class represents a control request to the device to reconnect to the host after |
|
484 the supplied interval has elapsed |
|
485 */ |
|
486 class TReconnectRequest : public TEmptyRequest |
|
487 { |
|
488 public: |
|
489 explicit TReconnectRequest(TUint16 aReconnectInterval) |
|
490 { |
|
491 iRequestType |= KRecipientDevice; |
|
492 iRequest = KVendorReconnectRequest; |
|
493 iValue = aReconnectInterval; |
|
494 } |
|
495 }; |
|
496 |
|
497 /** |
|
498 This class represents a control request to the device to disconnect device A and connect |
|
499 device C to the host |
|
500 */ |
|
501 class TDisconnectDeviceAThenConnectDeviceCRequest : public TEmptyRequest |
|
502 { |
|
503 public: |
|
504 /** |
|
505 Constructor, build a request that informs the client device of a successful test case status |
|
506 */ |
|
507 |
|
508 TDisconnectDeviceAThenConnectDeviceCRequest() |
|
509 { |
|
510 iRequestType |= KRecipientDevice; |
|
511 iRequest = KVendorDisconnectDeviceAThenConnectDeviceCRequest; |
|
512 iValue = KErrNone; |
|
513 } |
|
514 }; |
|
515 |
|
516 /** |
|
517 This class represents a control request to the device to disconnect device C and connect |
|
518 device A to the host |
|
519 */ |
|
520 class TDisconnectDeviceCThenConnectDeviceARequest : public TEmptyRequest |
|
521 { |
|
522 public: |
|
523 /** |
|
524 Constructor, build a request that informs the client device of a successful test case status |
|
525 */ |
|
526 |
|
527 TDisconnectDeviceCThenConnectDeviceARequest() |
|
528 { |
|
529 iRequestType |= KRecipientDevice; |
|
530 iRequest = KVendorDisconnectDeviceCThenConnectDeviceARequest; |
|
531 iValue = KErrNone; |
|
532 } |
|
533 }; |
|
534 |
|
535 /** |
|
536 This class represents an instruction to the client to write the data |
|
537 supplied to an endpoint that is specified |
|
538 */ |
|
539 class TEndpointWriteRequest : public TDataSendRequest |
|
540 { |
|
541 public: |
|
542 /** |
|
543 Constructor, build a request that instructs an interface on the client device to write data |
|
544 to a specified endpoint |
|
545 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
546 @param aEndpointNumber the number of the endpoint to write to (a pipe must be open on this endpoint) |
|
547 @param aData the data to write to that endpoint |
|
548 */ |
|
549 |
|
550 TEndpointWriteRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TDesC8& aData) : TDataSendRequest(aData) |
|
551 { |
|
552 iRequestType |= KRecipientInterface; |
|
553 iRequest = KVendorWriteToEndpointRequest; |
|
554 iValue = aEndpointNumber; |
|
555 iIndex = aInterfaceNumber; |
|
556 } |
|
557 }; |
|
558 |
|
559 /** |
|
560 This class represents an instruction to the client to write specified data a number of times |
|
561 on a given endpoint |
|
562 */ |
|
563 class TEndpointPatternWriteRequest : public TDataSendRequest |
|
564 { |
|
565 friend class CEp0Transfer; |
|
566 |
|
567 public: |
|
568 /** |
|
569 Constructor, build a request that instructs an interface on the client device to write specified data |
|
570 to an endpoint |
|
571 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
572 @param aEndpointNumber the number of the endpoint to write to (a pipe must be open on this endpoint) |
|
573 @param aData the data pattern to use when writing to that endpoint |
|
574 @param aNumBytes the number of bytes to write using that data pattern |
|
575 */ |
|
576 TEndpointPatternWriteRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TDesC8& aData,const TUint aNumBytes) |
|
577 { |
|
578 iRequestType |= KRecipientInterface; |
|
579 iRequest = KVendorPatternWriteToEndpointRequest; |
|
580 iValue = aEndpointNumber; |
|
581 iIndex = aInterfaceNumber; |
|
582 |
|
583 iSendData.Zero(); |
|
584 iSendData.Format(KNumberFormatString, aNumBytes); |
|
585 iSendData.Append(aData); |
|
586 } |
|
587 }; |
|
588 |
|
589 |
|
590 |
|
591 /** |
|
592 This class represents an instruction to the client to synchronously write specified data a number of times |
|
593 on a given endpoint |
|
594 */ |
|
595 class TEndpointPatternSynchronousWriteRequest : public TEndpointPatternWriteRequest |
|
596 { |
|
597 friend class CEp0Transfer; |
|
598 |
|
599 public: |
|
600 /** |
|
601 Constructor, build a request that instructs an interface on the client device to write specified data |
|
602 to an endpoint |
|
603 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
604 @param aEndpointNumber the number of the endpoint to write to (a pipe must be open on this endpoint) |
|
605 @param aData the data pattern to use when writing to that endpoint |
|
606 @param aNumBytes the number of bytes to write using that data pattern |
|
607 */ |
|
608 TEndpointPatternSynchronousWriteRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TDesC8& aData,const TUint aNumBytes) |
|
609 : TEndpointPatternWriteRequest(aInterfaceNumber,aEndpointNumber,aData,aNumBytes) |
|
610 { |
|
611 iRequest = KVendorPatternWriteSynchronousToEndpointRequest; |
|
612 } |
|
613 }; |
|
614 |
|
615 |
|
616 |
|
617 /** |
|
618 This class represents an instruction to the client synchronously to write specified data a number of times |
|
619 on a given endpoint and then halt that endpoint |
|
620 */ |
|
621 class TEndpointPatternSynchronousWriteAndHaltRequest : public TEndpointPatternSynchronousWriteRequest |
|
622 { |
|
623 friend class CEp0Transfer; |
|
624 |
|
625 public: |
|
626 /** |
|
627 Constructor, build a request that instructs an interface on the client device to write specified data |
|
628 to an endpoint and then halt that endpoint |
|
629 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
630 @param aEndpointNumber the number of the endpoint to write to (a pipe must be open on this endpoint) |
|
631 @param aData the data pattern to use when writing to that endpoint |
|
632 @param aNumBytes the number of bytes to write using that data pattern |
|
633 */ |
|
634 TEndpointPatternSynchronousWriteAndHaltRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TDesC8& aData,const TUint aNumBytes) |
|
635 : TEndpointPatternSynchronousWriteRequest(aInterfaceNumber, aEndpointNumber, aData, aNumBytes) |
|
636 { |
|
637 iRequest = KVendorPatternWriteSynchronousToAndHaltEndpointRequest; |
|
638 } |
|
639 }; |
|
640 |
|
641 /** |
|
642 This class represents an instruction to the client to validate data read on an endpoint with specified data |
|
643 on a given endpoint |
|
644 */ |
|
645 class TEndpointStringValidationRequest : public TEndpointPatternWriteRequest |
|
646 { |
|
647 friend class CEp0Transfer; |
|
648 |
|
649 public: |
|
650 /** |
|
651 Constructor, build a request that instructs an interface on the client device to |
|
652 verify data on an endpoint using the data pattern provided |
|
653 @param aInterfaceNumber the number of the interface which has this endpoint |
|
654 @param aEndpointNumber the number of the endpoint to use (a pipe must be open on this endpoint) |
|
655 @param aData the data pattern to use when verifying on that endpoint |
|
656 @param aNumBytes the number of bytes to write using that data pattern */ |
|
657 TEndpointStringValidationRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TDesC8& aData,const TUint aNumBytes) |
|
658 : TEndpointPatternWriteRequest(aInterfaceNumber,aEndpointNumber,aData,aNumBytes) |
|
659 { |
|
660 iRequest = KVendorStringValidationRequest; |
|
661 } |
|
662 }; |
|
663 |
|
664 |
|
665 |
|
666 /** |
|
667 This class represents an instruction to the client to write back data just read. |
|
668 */ |
|
669 class TWriteSynchronousCachedReadDataRequest : public TControlSetupPacket |
|
670 { |
|
671 friend class CEp0Transfer; |
|
672 |
|
673 public: |
|
674 /** |
|
675 Constructor, build a request that instructs an interface on the client device to use the data |
|
676 just read on one endpoint to send back on another. |
|
677 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
678 @param aReadEndpointNumber the number of the endpoint that has just been read from (a pipe must be open on this endpoint) |
|
679 @param aWriteEndpointNumber the number of the endpoint to write to (a pipe must be open on this endpoint) |
|
680 */ |
|
681 TWriteSynchronousCachedReadDataRequest(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,const TUint8 aWriteEndpointNumber) |
|
682 { |
|
683 iRequestType |= KHostToDevice; |
|
684 iRequestType |= KTypeVendor; |
|
685 iRequestType |= KRecipientInterface; |
|
686 iRequest = KVendorWriteSynchronousCachedReadRequest; |
|
687 iValue = aReadEndpointNumber << 8 | aWriteEndpointNumber; |
|
688 iIndex = aInterfaceNumber; |
|
689 } |
|
690 }; |
|
691 |
|
692 /** |
|
693 This class represents an instruction to the client to write back data just read. |
|
694 */ |
|
695 class TWriteCachedReadDataRequest : public TWriteSynchronousCachedReadDataRequest |
|
696 { |
|
697 friend class CEp0Transfer; |
|
698 |
|
699 public: |
|
700 /** |
|
701 Constructor, build a request that instructs an interface on the client device to use the data |
|
702 just read on one endpoint to send back on another. |
|
703 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
704 @param aReadEndpointNumber the number of the endpoint that has just been read from (a pipe must be open on this endpoint) |
|
705 @param aWriteEndpointNumber the number of the endpoint to write to (a pipe must be open on this endpoint) |
|
706 */ |
|
707 TWriteCachedReadDataRequest(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,const TUint8 aWriteEndpointNumber) |
|
708 : TWriteSynchronousCachedReadDataRequest(aInterfaceNumber, aReadEndpointNumber, aWriteEndpointNumber) |
|
709 { |
|
710 iRequest = KVendorWriteCachedReadRequest; |
|
711 } |
|
712 }; |
|
713 |
|
714 |
|
715 /** |
|
716 This class represents an instruction to the client to write back data just read - in sections. |
|
717 */ |
|
718 class TSplitWriteCachedReadDataRequest : public TDataSendRequest |
|
719 { |
|
720 friend class CEp0Transfer; |
|
721 |
|
722 public: |
|
723 /** |
|
724 Constructor, build a request that instructs an interface on the client device to use the data |
|
725 just read on one endpoint to send back on another. |
|
726 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
727 @param aReadEndpointNumber the number of the endpoint that has just been read from (a pipe must be open on this endpoint) |
|
728 @param aWriteEndpointNumber the number of the endpoint to write to (a pipe must be open on this endpoint) |
|
729 */ |
|
730 TSplitWriteCachedReadDataRequest(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,const TUint8 aWriteEndpointNumber,const TUint aNumBytes[KNumSplitWriteSections]) |
|
731 { |
|
732 iRequestType |= KHostToDevice; |
|
733 iRequestType |= KTypeVendor; |
|
734 iRequestType |= KRecipientInterface; |
|
735 iRequest = KVendorSplitWriteSynchronousCachedReadRequest; |
|
736 iValue = aReadEndpointNumber << 8 | aWriteEndpointNumber; |
|
737 iIndex = aInterfaceNumber; |
|
738 |
|
739 iSendData.Zero(); |
|
740 for(TUint i = 0; i<KNumSplitWriteSections; ++i) |
|
741 { |
|
742 TBuf8<KNumberStringLength> buf; |
|
743 buf.Format(KNumberFormatString, aNumBytes[i]); |
|
744 iSendData.Append(buf); |
|
745 } |
|
746 } |
|
747 }; |
|
748 |
|
749 /** |
|
750 This class represents an instruction to the client to write back data just read - in sections. |
|
751 */ |
|
752 class TRepeatedWriteDataRequest : public TDataSendRequest |
|
753 { |
|
754 friend class CEp0Transfer; |
|
755 |
|
756 public: |
|
757 /** |
|
758 Constructor, build a request that instructs an interface on the client device to perform |
|
759 a repeated read using the data as a pattern to validate the data as it arrives. |
|
760 Constructor, build a request that instructs an interface on the client device to perform |
|
761 a repeated write using the data as a pattern. |
|
762 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
763 @param aReadEndpointNumber the number of the endpoint that has just been read from (a pipe must be open on this endpoint) |
|
764 @param aData the data pattern to be used for validation |
|
765 @param aNumBytesPerRead the number of bytes to read at each 'Read' |
|
766 @param aTotalNumBytes the total number of bytes to read (over all 'Read's) |
|
767 */ |
|
768 TRepeatedWriteDataRequest(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,const TDesC8& aDataPattern,const TUint aNumBytesPerRead,const TUint aTotalNumBytes) |
|
769 { |
|
770 iRequestType |= KHostToDevice; |
|
771 iRequestType |= KTypeVendor; |
|
772 iRequestType |= KRecipientInterface; |
|
773 iRequest = KVendorRepeatedPatternWriteDataRequest; |
|
774 iValue = aReadEndpointNumber; |
|
775 iIndex = aInterfaceNumber; |
|
776 |
|
777 iSendData.Zero(); |
|
778 TBuf8<KTwoNumberStringLength> buf; |
|
779 buf.Format(KTwoNumberFormatString, aNumBytesPerRead, aTotalNumBytes); |
|
780 iSendData.Append(buf); |
|
781 iSendData.Append(aDataPattern); |
|
782 } |
|
783 }; |
|
784 |
|
785 |
|
786 |
|
787 /** |
|
788 This class represents an instruction to the client to read a number of bytes of data |
|
789 on an the endpoint. |
|
790 */ |
|
791 class TEndpointReadRequest : public TControlSetupPacket |
|
792 { |
|
793 friend class CEp0Transfer; |
|
794 |
|
795 public: |
|
796 /** |
|
797 Constructor, build a request that instructs an interface on the client device to read a specified amount data |
|
798 on the specified endpoint |
|
799 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
800 @param aEndpointNumber the number of the endpoint to write to (a pipe must be open on this endpoint) |
|
801 @param aNumBytes the amount of data to read on that endpoint |
|
802 */ |
|
803 TEndpointReadRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TUint aNumBytes) |
|
804 { |
|
805 iRequestType |= KHostToDevice; |
|
806 iRequestType |= KTypeVendor; |
|
807 iRequestType |= KRecipientInterface; |
|
808 iRequest = KVendorReadFromEndpointRequest; |
|
809 iValue = aEndpointNumber; |
|
810 iIndex = aInterfaceNumber; |
|
811 |
|
812 iReadSpecificationData.Zero(); |
|
813 iReadSpecificationData.Format(KNumberFormatString, aNumBytes); |
|
814 } |
|
815 |
|
816 protected: |
|
817 TBuf8<KNumberStringLength> iReadSpecificationData; |
|
818 }; |
|
819 |
|
820 /** |
|
821 This class represents an instruction to the client to read a number of bytes of data |
|
822 on an the endpoint. Reading will complete early if a short packet is detected. |
|
823 */ |
|
824 class TEndpointReadUntilShortRequest : public TEndpointReadRequest |
|
825 { |
|
826 friend class CEp0Transfer; |
|
827 |
|
828 public: |
|
829 /** |
|
830 Constructor, build a request that instructs an interface on the client device to read the data |
|
831 on the specified endpoint |
|
832 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
833 @param aEndpointNumber the number of the endpoint to write to (a pipe must be open on this endpoint) |
|
834 @param aNumBytes the amount of data to read on that endpoint (if a short packet does not arrive sooner) |
|
835 */ |
|
836 TEndpointReadUntilShortRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TUint aNumBytes) |
|
837 : TEndpointReadRequest(aInterfaceNumber, aEndpointNumber, aNumBytes) |
|
838 { |
|
839 iRequest = KVendorReadUntilShortFromEndpointRequest; |
|
840 } |
|
841 }; |
|
842 |
|
843 /** |
|
844 This class represents an instruction to the client to read a number of bytes of data |
|
845 on an the endpoint, and then, when the specified number of bytes have been read, to stall the endpoint. |
|
846 */ |
|
847 class TEndpointReadAndHaltRequest : public TEndpointReadRequest |
|
848 { |
|
849 friend class CEp0Transfer; |
|
850 |
|
851 public: |
|
852 /** |
|
853 Constructor, build a request that instructs an interface on the client device to read the data |
|
854 on the specified endpoint |
|
855 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
856 @param aEndpointNumber the number of the endpoint to write to (a pipe must be open on this endpoint) |
|
857 @param aNumBytes the amount of data to read on that endpoint (if a short packet does not arrive sooner) |
|
858 */ |
|
859 TEndpointReadAndHaltRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TUint aNumBytes) |
|
860 : TEndpointReadRequest(aInterfaceNumber, aEndpointNumber, aNumBytes) |
|
861 { |
|
862 iRequest = KVendorReadFromAndHaltEndpointRequest; |
|
863 } |
|
864 }; |
|
865 |
|
866 /** |
|
867 This class represents an instruction to the client to write back data just read - in sections. |
|
868 */ |
|
869 class TRepeatedReadAndValidateDataRequest : public TRepeatedWriteDataRequest |
|
870 { |
|
871 friend class CEp0Transfer; |
|
872 |
|
873 public: |
|
874 /** |
|
875 Constructor, build a request that instructs an interface on the client device to perform |
|
876 a repeated read using the data as a pattern to validate the data as it arrives. |
|
877 @param aInterfaceNumber the number of the interface which has this endpoint to write to |
|
878 @param aReadEndpointNumber the number of the endpoint that has just been read from (a pipe must be open on this endpoint) |
|
879 @param aData the data pattern to be used for validation |
|
880 @param aNumBytesPerRead the number of bytes to read at each 'Read' |
|
881 @param aTotalNumBytes the total number of bytes to read (over all 'Read's) |
|
882 */ |
|
883 TRepeatedReadAndValidateDataRequest(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,const TDesC8& aDataPattern,const TUint aNumBytesPerRead,const TUint aTotalNumBytes) |
|
884 : TRepeatedWriteDataRequest(aInterfaceNumber,aReadEndpointNumber,aDataPattern,aNumBytesPerRead,aTotalNumBytes) |
|
885 { |
|
886 iRequest = KVendorRepeatedReadAndValidateDataRequest; |
|
887 } |
|
888 }; |
|
889 |
|
890 |
|
891 /** |
|
892 This class represents a request that requests the client device |
|
893 to negatively acknowledge the request |
|
894 */ |
|
895 class TNakRequest : public TEmptyRequest |
|
896 { |
|
897 public: |
|
898 /** |
|
899 Constructor, build a request that instructs an interface to continually NAK the request |
|
900 @param aInterfaceNumber the interface number |
|
901 */ |
|
902 |
|
903 explicit TNakRequest(TUint16 aInterfaceNumber) |
|
904 { |
|
905 iRequestType |= KRecipientInterface; |
|
906 iRequest = KVendorUnrespondRequest; |
|
907 iIndex = aInterfaceNumber; |
|
908 } |
|
909 }; |
|
910 |
|
911 /** |
|
912 This class represents a control request to the device to indicate that test case |
|
913 has successfully completed and to disconnect the device |
|
914 */ |
|
915 class TTestCasePassed : public TEmptyRequest |
|
916 { |
|
917 public: |
|
918 /** |
|
919 Constructor, build a request that informs the client device of a successful test case status |
|
920 */ |
|
921 |
|
922 TTestCasePassed() |
|
923 { |
|
924 iRequestType |= KRecipientDevice; |
|
925 iRequest = KVendorTestCasePassed; |
|
926 iValue = KErrNone; |
|
927 } |
|
928 }; |
|
929 |
|
930 /** |
|
931 This class represents a control request to the device of an unsuccessful test case execution |
|
932 and to complete the device side test case with the supplied error and error message |
|
933 */ |
|
934 class TTestCaseFailed : public TDataSendRequest |
|
935 { |
|
936 public: |
|
937 /** |
|
938 Constructor, build a request that informs the client device of an unsuccessful test case status |
|
939 @param aError the error that the host side test case reports |
|
940 @param aErrorMsg the message text (non-unicode) for the client to display when this request has been received |
|
941 */ |
|
942 |
|
943 TTestCaseFailed(TInt aError,const TDesC8& aErrorMsg) : TDataSendRequest(aErrorMsg) |
|
944 { |
|
945 iRequestType |= KRecipientDevice; |
|
946 iRequest = KVendorTestCaseFailed; |
|
947 iValue = -aError; // Invert the error as symbian system errors are negative |
|
948 } |
|
949 |
|
950 /** |
|
951 Constructor, build a request that informs the client device of an unsuccessful test case status |
|
952 @param aError the error that the host side test case reports |
|
953 @param aErrorMsg the message text (unicode) for the client to display when this request has been received |
|
954 */ |
|
955 |
|
956 TTestCaseFailed(TInt aError,const TDesC16& aErrorMsg) : TDataSendRequest(aErrorMsg) |
|
957 { |
|
958 iRequestType |= KRecipientDevice; |
|
959 iRequest = KVendorTestCaseFailed; |
|
960 iValue = -aError; // Invert the error as symbian system errors are negative |
|
961 } |
|
962 }; |
|
963 |
|
964 |
|
965 /** |
|
966 This class represents the SET_CUR audio class control request |
|
967 */ |
|
968 class TSetCurRequest : public TClassDataSendRequest |
|
969 { |
|
970 public: |
|
971 explicit TSetCurRequest(const TDesC8& aData, const TUint aEndpointAddress) : TClassDataSendRequest(aData) //TUint16 aSamplingFrequency) |
|
972 { |
|
973 iRequestType |= KRecipientEndpoint; |
|
974 iRequest = KAudioClassSetCur; |
|
975 iValue = 0x0100; |
|
976 iIndex = aEndpointAddress; |
|
977 } |
|
978 }; |
|
979 |
|
980 |
|
981 /** |
|
982 This class describes an observer to the Ep0 control transfer |
|
983 */ |
|
984 class MCommandObserver |
|
985 { |
|
986 public: |
|
987 /** |
|
988 Called when an endpoint zero test command transfer has completed |
|
989 @param aCompletionCode the completion code of the asynchronous transfer to Ep0 |
|
990 */ |
|
991 virtual void Ep0TransferCompleteL(TInt aCompletionCode) = 0; |
|
992 }; |
|
993 |
|
994 /** |
|
995 This class represents a transfer to a control endpoint 0 |
|
996 */ |
|
997 class CEp0Transfer : public CActive |
|
998 { |
|
999 public: |
|
1000 /** |
|
1001 Constructor, build a test command to send to the connected client |
|
1002 @param aToken the token |
|
1003 */ |
|
1004 CEp0Transfer(RUsbInterface& aInterface0); |
|
1005 |
|
1006 /** |
|
1007 Destructor |
|
1008 */ |
|
1009 ~CEp0Transfer(); |
|
1010 |
|
1011 /** |
|
1012 Send a control transfer request to endpoint zero of the client |
|
1013 @param aSetupPacket a control request |
|
1014 @param aObserver the observer that will be notified of transfer completion |
|
1015 */ |
|
1016 void SendRequest(TEmptyRequest& aSetupPacket,MCommandObserver* aObserver); |
|
1017 |
|
1018 /** |
|
1019 Send a control transfer request to endpoint zero of the client |
|
1020 @param aSetupPacket a control request |
|
1021 @param aObserver the observer that will be notified of transfer completion |
|
1022 */ |
|
1023 void SendRequest(TDataRecvRequest& aSetupPacket,MCommandObserver* aObserver); |
|
1024 |
|
1025 /** |
|
1026 Send a control transfer request to endpoint zero of the client that will also send a payload in data packets |
|
1027 @param aSetupPacket a control request |
|
1028 @param aObserver the observer that will be notified of transfer completion |
|
1029 */ |
|
1030 void SendRequest(TDataSendRequest& aSetupPacket,MCommandObserver* aObserver); |
|
1031 |
|
1032 /** |
|
1033 Send a control transfer request to endpoint zero of the client |
|
1034 @param aSetupPacket a control request |
|
1035 @param aObserver the observer that will be notified of transfer completion |
|
1036 */ |
|
1037 void SendRequest(TWriteSynchronousCachedReadDataRequest& aSetupPacket,MCommandObserver* aObserver); |
|
1038 |
|
1039 /** |
|
1040 Send a control transfer request to endpoint zero of the client that will also send a payload in data packets |
|
1041 @param aSetupPacket a control request |
|
1042 @param aObserver the observer that will be notified of transfer completion |
|
1043 */ |
|
1044 void SendRequest(TEndpointReadRequest& aSetupPacket,MCommandObserver* aObserver); |
|
1045 |
|
1046 /** |
|
1047 Send a class control transfer request to endpoint zero of the client that will also send a payload in data packets |
|
1048 @param aSetupPacket a class control request |
|
1049 @param aObserver the observer that will be notified of transfer completion |
|
1050 */ |
|
1051 void SendRequest(TClassDataSendRequest& aSetupPacket,MCommandObserver* aObserver); |
|
1052 |
|
1053 /** |
|
1054 Cancel last SendRequest if still active. This does NOT cancel the active object |
|
1055 which must be done separately using the normal 'Cancel' function. |
|
1056 */ |
|
1057 void CancelSendRequest(); |
|
1058 |
|
1059 /** |
|
1060 Gets the time the last SendRequest was sent. |
|
1061 */ |
|
1062 void LastRequestStartTime( TTime& aDuration); |
|
1063 |
|
1064 /** |
|
1065 Gets the time the last SendRequest was completed in RunL. |
|
1066 */ |
|
1067 void LastRequestCompletionTime( TTime& aDuration); |
|
1068 |
|
1069 private: |
|
1070 |
|
1071 /** |
|
1072 Currently no way to cancel a single transfer, so not going to try |
|
1073 */ |
|
1074 void DoCancel(); |
|
1075 |
|
1076 /** |
|
1077 */ |
|
1078 void RunL(); |
|
1079 |
|
1080 /** |
|
1081 */ |
|
1082 TInt RunError(TInt aError); |
|
1083 |
|
1084 private: |
|
1085 |
|
1086 /** |
|
1087 The USB interface endpoint zero which receives the command |
|
1088 For the test devices modelled |
|
1089 */ |
|
1090 RUsbInterface& iUsbInterface0; |
|
1091 |
|
1092 /** |
|
1093 The observer of client responses to host commands (uses-a) |
|
1094 */ |
|
1095 MCommandObserver* iObserver; |
|
1096 |
|
1097 /** |
|
1098 The actual amount of data received by the host from the client |
|
1099 in response to a command sent by the host |
|
1100 */ |
|
1101 TInt iActualLength; |
|
1102 |
|
1103 /** |
|
1104 The flag to indicate if the request sent required the clieent device to answer with |
|
1105 some data |
|
1106 */ |
|
1107 TBool iDataRequest; |
|
1108 |
|
1109 TBuf8<1> iTemp; |
|
1110 |
|
1111 /** |
|
1112 The time the last SendRequest was sent. |
|
1113 */ |
|
1114 TTime iRequestTime; |
|
1115 |
|
1116 /** |
|
1117 The time the last SendRequest was completed in RunL |
|
1118 */ |
|
1119 TTime iCompletionTime; |
|
1120 }; |
|
1121 |
|
1122 |
|
1123 } |
|
1124 |
|
1125 |
|
1126 #endif |
|
1127 |