First public contribution.
1 #ifndef __CONTROL_TRANSFER_REQUESTS_H
2 #define __CONTROL_TRANSFER_REQUESTS_H
5 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
12 * Initial Contributors:
13 * Nokia Corporation - initial contribution.
18 * @file ControlTransferRequests.h
30 namespace NUnitTesting_USBDI
33 //These values MUST be kept in line with each other
34 const _LIT8(KNumberFormatString, "%08d");
35 const TUint KNumberStringLength = 8;
37 //These values MUST be kept in line with each other
38 const _LIT8(KTwoNumberFormatString, "%08d%08d");
39 const TUint KTwoNumberStringLength = 16;
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;
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;
51 const TUint KTestBufferLength = 32; //must be more than KPassFailStringLength
53 const TUint KMaxSendSize = 2048;
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);
90 const TUint8 KAudioClassSetCur(0x01);
92 // ------------- bmRequestType -----------------
94 // D7: Data phase transfer direction
95 const TUint8 KHostToDevice(0x00);
96 const TUint8 KDeviceToHost(0x80);
99 const TUint8 KTypeStandard(0x00);
100 const TUint8 KTypeClass(0x20);
101 const TUint8 KTypeVendor(0x40);
104 const TUint8 KRecipientDevice(0x00);
105 const TUint8 KRecipientInterface(0x01);
106 const TUint8 KRecipientEndpoint(0x02);
107 const TUint8 KRecipientOther(0x03);
109 // ------------------------------------------------------------------
111 // The customised requests (i.e. non standard control requests)
113 // ------------------------------------------------------------------
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'
120 class TControlSetupPacket : public ::RUsbInterface::TUsbTransferRequestDetails
123 TControlSetupPacket()
133 This class represents a control request to the client that does not request
134 data from the client. It merely instructs the client
136 class TEmptyRequest : public TControlSetupPacket
141 iRequestType |= KHostToDevice;
142 iRequestType |= KTypeVendor;
143 iRequest = KVendorEmptyRequest;
149 class TDataSendRequest : public TControlSetupPacket
151 friend class CEp0Transfer;
156 iRequestType |= KHostToDevice;
157 iRequestType |= KTypeVendor;
160 explicit TDataSendRequest(const TDesC8& aData)
162 iRequestType |= KHostToDevice;
163 iRequestType |= KTypeVendor;
164 iSendData.Copy(aData);
167 explicit TDataSendRequest(const TDesC16& aData)
169 iRequestType |= KHostToDevice;
170 iRequestType |= KTypeVendor;
171 iSendData.Copy(aData);
174 TBuf8<KMaxSendSize> iSendData;
180 class TClassDataSendRequest : public TControlSetupPacket
182 friend class CEp0Transfer;
185 explicit TClassDataSendRequest(const TDesC8& aData)
187 iRequestType |= KHostToDevice;
188 iRequestType |= KTypeClass;
189 iSendData.Copy(aData);
192 explicit TClassDataSendRequest(const TDesC16& aData)
194 iRequestType |= KHostToDevice;
195 iRequestType |= KTypeClass;
196 iSendData.Copy(aData);
199 TBuf8<KMaxSendSize> iSendData;
204 This class represents a control request to the client that requests some data
205 in response to the request
207 class TDataRecvRequest : public TControlSetupPacket
209 friend class CEp0Transfer;
212 explicit TDataRecvRequest(TDes8& aData) : iRecvData(aData)
214 iRequestType |= KDeviceToHost;
215 iRequestType |= KTypeVendor;
225 class TDescriptorGetRequest : public TDataRecvRequest
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
235 TDescriptorGetRequest(TUint16 aTypeAndIndex,TUint16 aLanguageId,TDes8& aData)
236 : TDataRecvRequest(aData)
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;
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
251 class TEmptyDeviceRequest : public TEmptyRequest
254 TEmptyDeviceRequest()
256 iRequestType |= KRecipientDevice;
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
264 class TEmptyInterfaceRequest : public TEmptyRequest
267 explicit TEmptyInterfaceRequest(TUint16 aInterfaceNumber)
269 iRequestType |= KRecipientInterface;
270 iIndex = aInterfaceNumber;
275 This class represents a device directed request that send a payload
277 class TDevicePutPayloadRequest : public TDataSendRequest
280 TDevicePutPayloadRequest(const TDesC8& aData) : TDataSendRequest(aData)
282 iRequestType |= KRecipientDevice;
283 iRequest = KVendorPutPayloadRequest;
290 This class represents a device directed request that retrieves a payload
291 from the client device
293 class TDeviceGetPayloadRequest : public TDataRecvRequest
296 explicit TDeviceGetPayloadRequest(TDes8& aData) : TDataRecvRequest(aData)
298 iRequestType |= KRecipientDevice;
299 iRequest = KVendorGetPayloadRequest;
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'.
310 class TInterfaceGetRecordedNumBytesReadInPayload : public TDataRecvRequest
313 explicit TInterfaceGetRecordedNumBytesReadInPayload(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,TDes8& aData) : TDataRecvRequest(aData)
315 iRequestType |= KRecipientInterface;
316 iRequest = KVendorGetRecordedNumBytesReadInPayloadRequest;
317 iValue = aReadEndpointNumber;
318 iIndex = aInterfaceNumber;
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'.
327 class TInterfaceGetRecordedNumBytesWrittenInPayload : public TDataRecvRequest
330 explicit TInterfaceGetRecordedNumBytesWrittenInPayload(const TUint16 aInterfaceNumber,const TUint8 aWriteEndpointNumber,TDes8& aData) : TDataRecvRequest(aData)
332 iRequestType |= KRecipientInterface;
333 iRequest = KVendorGetRecordedNumBytesWrittenInPayloadRequest;
334 iValue = aWriteEndpointNumber;
335 iIndex = aInterfaceNumber;
342 This class represents an interface directed request that sends a payload
344 class TInterfacePutPayloadRequest : public TDataSendRequest
347 TInterfacePutPayloadRequest(TUint16 aInterfaceNumber,const TDesC8& aData) : TDataSendRequest(aData)
349 iRequestType |= KRecipientInterface;
350 iRequest = KVendorPutPayloadRequest;
352 iIndex = aInterfaceNumber;
357 This class represents a device directed request that retrieves a payload
358 from the client device
360 class TInterfaceGetPayloadRequest : public TDataRecvRequest
363 explicit TInterfaceGetPayloadRequest(TUint16 aInterfaceNumber,TDes8& aData) : TDataRecvRequest(aData)
365 iRequestType |= KRecipientInterface;
366 iRequest = KVendorGetPayloadRequest;
368 iIndex = aInterfaceNumber;
373 This class represents a control request to stall a specified endpoint
375 class TInterfaceEndpointBaseRequest : public TEmptyRequest
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
384 TInterfaceEndpointBaseRequest(TUint16 aEndpointNumber,TUint16 aInterfaceNumber)
387 iRequestType |= KRecipientInterface;
388 iValue = aEndpointNumber;
389 iIndex = aInterfaceNumber;
394 This class represents a control request to stall a specified endpoint
396 class TStallEndpointRequest : public TInterfaceEndpointBaseRequest
400 Constructor, build a request to stall a specified endpoint
401 @param aEndpointNumber the endpoint to stall
404 TStallEndpointRequest(TUint16 aEndpointNumber,TUint16 aInterfaceNumber)
405 : TInterfaceEndpointBaseRequest(aEndpointNumber, aInterfaceNumber)
407 iRequest = KVendorStallRequest;
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.
415 class TRecordedValidationResultRequest : public TInterfaceEndpointBaseRequest
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
424 TRecordedValidationResultRequest(TUint16 aEndpointNumber,TUint16 aInterfaceNumber)
425 : TInterfaceEndpointBaseRequest(aEndpointNumber, aInterfaceNumber)
427 iRequest = KVendorRecordedValidationResultRequest;
432 This class represents a control request to stall a specified endpoint
434 class TEndpointCancelWriteRequest : public TInterfaceEndpointBaseRequest
438 Constructor, build a request to stall a specified endpoint
439 @param aEndpointNumber the endpoint to stall
442 TEndpointCancelWriteRequest(TUint16 aEndpointNumber,TUint16 aInterfaceNumber)
443 : TInterfaceEndpointBaseRequest(aEndpointNumber, aInterfaceNumber)
445 iRequest = KVendorCancelWriteToEndpointRequest;
450 This class represents a control request to stall a specified endpoint
452 class TEndpointCancelReadRequest : public TInterfaceEndpointBaseRequest
456 Constructor, build a request to stall a specified endpoint
457 @param aEndpointNumber the endpoint to stall
460 TEndpointCancelReadRequest(TUint16 aEndpointNumber,TUint16 aInterfaceNumber)
461 : TInterfaceEndpointBaseRequest(aEndpointNumber, aInterfaceNumber)
463 iRequest = KVendorCancelAnyReadFromEndpointRequest;
468 This class represents a control request to the device to initiate a remote
469 wake-up after the supplied interval has elapsed.
471 class TRemoteWakeupRequest : public TEmptyRequest
474 explicit TRemoteWakeupRequest(TUint16 aWakeupInterval)
476 iRequestType |= KRecipientDevice;
477 iRequest = KVendorRemoteWakeupRequest;
478 iValue = aWakeupInterval;
483 This class represents a control request to the device to reconnect to the host after
484 the supplied interval has elapsed
486 class TReconnectRequest : public TEmptyRequest
489 explicit TReconnectRequest(TUint16 aReconnectInterval)
491 iRequestType |= KRecipientDevice;
492 iRequest = KVendorReconnectRequest;
493 iValue = aReconnectInterval;
498 This class represents a control request to the device to disconnect device A and connect
501 class TDisconnectDeviceAThenConnectDeviceCRequest : public TEmptyRequest
505 Constructor, build a request that informs the client device of a successful test case status
508 TDisconnectDeviceAThenConnectDeviceCRequest()
510 iRequestType |= KRecipientDevice;
511 iRequest = KVendorDisconnectDeviceAThenConnectDeviceCRequest;
517 This class represents a control request to the device to disconnect device C and connect
520 class TDisconnectDeviceCThenConnectDeviceARequest : public TEmptyRequest
524 Constructor, build a request that informs the client device of a successful test case status
527 TDisconnectDeviceCThenConnectDeviceARequest()
529 iRequestType |= KRecipientDevice;
530 iRequest = KVendorDisconnectDeviceCThenConnectDeviceARequest;
536 This class represents an instruction to the client to write the data
537 supplied to an endpoint that is specified
539 class TEndpointWriteRequest : public TDataSendRequest
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
550 TEndpointWriteRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TDesC8& aData) : TDataSendRequest(aData)
552 iRequestType |= KRecipientInterface;
553 iRequest = KVendorWriteToEndpointRequest;
554 iValue = aEndpointNumber;
555 iIndex = aInterfaceNumber;
560 This class represents an instruction to the client to write specified data a number of times
563 class TEndpointPatternWriteRequest : public TDataSendRequest
565 friend class CEp0Transfer;
569 Constructor, build a request that instructs an interface on the client device to write specified data
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
576 TEndpointPatternWriteRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TDesC8& aData,const TUint aNumBytes)
578 iRequestType |= KRecipientInterface;
579 iRequest = KVendorPatternWriteToEndpointRequest;
580 iValue = aEndpointNumber;
581 iIndex = aInterfaceNumber;
584 iSendData.Format(KNumberFormatString, aNumBytes);
585 iSendData.Append(aData);
592 This class represents an instruction to the client to synchronously write specified data a number of times
595 class TEndpointPatternSynchronousWriteRequest : public TEndpointPatternWriteRequest
597 friend class CEp0Transfer;
601 Constructor, build a request that instructs an interface on the client device to write specified data
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
608 TEndpointPatternSynchronousWriteRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TDesC8& aData,const TUint aNumBytes)
609 : TEndpointPatternWriteRequest(aInterfaceNumber,aEndpointNumber,aData,aNumBytes)
611 iRequest = KVendorPatternWriteSynchronousToEndpointRequest;
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
621 class TEndpointPatternSynchronousWriteAndHaltRequest : public TEndpointPatternSynchronousWriteRequest
623 friend class CEp0Transfer;
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
634 TEndpointPatternSynchronousWriteAndHaltRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TDesC8& aData,const TUint aNumBytes)
635 : TEndpointPatternSynchronousWriteRequest(aInterfaceNumber, aEndpointNumber, aData, aNumBytes)
637 iRequest = KVendorPatternWriteSynchronousToAndHaltEndpointRequest;
642 This class represents an instruction to the client to validate data read on an endpoint with specified data
645 class TEndpointStringValidationRequest : public TEndpointPatternWriteRequest
647 friend class CEp0Transfer;
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)
660 iRequest = KVendorStringValidationRequest;
667 This class represents an instruction to the client to write back data just read.
669 class TWriteSynchronousCachedReadDataRequest : public TControlSetupPacket
671 friend class CEp0Transfer;
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)
681 TWriteSynchronousCachedReadDataRequest(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,const TUint8 aWriteEndpointNumber)
683 iRequestType |= KHostToDevice;
684 iRequestType |= KTypeVendor;
685 iRequestType |= KRecipientInterface;
686 iRequest = KVendorWriteSynchronousCachedReadRequest;
687 iValue = aReadEndpointNumber << 8 | aWriteEndpointNumber;
688 iIndex = aInterfaceNumber;
693 This class represents an instruction to the client to write back data just read.
695 class TWriteCachedReadDataRequest : public TWriteSynchronousCachedReadDataRequest
697 friend class CEp0Transfer;
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)
707 TWriteCachedReadDataRequest(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,const TUint8 aWriteEndpointNumber)
708 : TWriteSynchronousCachedReadDataRequest(aInterfaceNumber, aReadEndpointNumber, aWriteEndpointNumber)
710 iRequest = KVendorWriteCachedReadRequest;
716 This class represents an instruction to the client to write back data just read - in sections.
718 class TSplitWriteCachedReadDataRequest : public TDataSendRequest
720 friend class CEp0Transfer;
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)
730 TSplitWriteCachedReadDataRequest(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,const TUint8 aWriteEndpointNumber,const TUint aNumBytes[KNumSplitWriteSections])
732 iRequestType |= KHostToDevice;
733 iRequestType |= KTypeVendor;
734 iRequestType |= KRecipientInterface;
735 iRequest = KVendorSplitWriteSynchronousCachedReadRequest;
736 iValue = aReadEndpointNumber << 8 | aWriteEndpointNumber;
737 iIndex = aInterfaceNumber;
740 for(TUint i = 0; i<KNumSplitWriteSections; ++i)
742 TBuf8<KNumberStringLength> buf;
743 buf.Format(KNumberFormatString, aNumBytes[i]);
744 iSendData.Append(buf);
750 This class represents an instruction to the client to write back data just read - in sections.
752 class TRepeatedWriteDataRequest : public TDataSendRequest
754 friend class CEp0Transfer;
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)
768 TRepeatedWriteDataRequest(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,const TDesC8& aDataPattern,const TUint aNumBytesPerRead,const TUint aTotalNumBytes)
770 iRequestType |= KHostToDevice;
771 iRequestType |= KTypeVendor;
772 iRequestType |= KRecipientInterface;
773 iRequest = KVendorRepeatedPatternWriteDataRequest;
774 iValue = aReadEndpointNumber;
775 iIndex = aInterfaceNumber;
778 TBuf8<KTwoNumberStringLength> buf;
779 buf.Format(KTwoNumberFormatString, aNumBytesPerRead, aTotalNumBytes);
780 iSendData.Append(buf);
781 iSendData.Append(aDataPattern);
788 This class represents an instruction to the client to read a number of bytes of data
791 class TEndpointReadRequest : public TControlSetupPacket
793 friend class CEp0Transfer;
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
803 TEndpointReadRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TUint aNumBytes)
805 iRequestType |= KHostToDevice;
806 iRequestType |= KTypeVendor;
807 iRequestType |= KRecipientInterface;
808 iRequest = KVendorReadFromEndpointRequest;
809 iValue = aEndpointNumber;
810 iIndex = aInterfaceNumber;
812 iReadSpecificationData.Zero();
813 iReadSpecificationData.Format(KNumberFormatString, aNumBytes);
817 TBuf8<KNumberStringLength> iReadSpecificationData;
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.
824 class TEndpointReadUntilShortRequest : public TEndpointReadRequest
826 friend class CEp0Transfer;
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)
836 TEndpointReadUntilShortRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TUint aNumBytes)
837 : TEndpointReadRequest(aInterfaceNumber, aEndpointNumber, aNumBytes)
839 iRequest = KVendorReadUntilShortFromEndpointRequest;
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.
847 class TEndpointReadAndHaltRequest : public TEndpointReadRequest
849 friend class CEp0Transfer;
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)
859 TEndpointReadAndHaltRequest(TUint16 aInterfaceNumber,TUint16 aEndpointNumber,const TUint aNumBytes)
860 : TEndpointReadRequest(aInterfaceNumber, aEndpointNumber, aNumBytes)
862 iRequest = KVendorReadFromAndHaltEndpointRequest;
867 This class represents an instruction to the client to write back data just read - in sections.
869 class TRepeatedReadAndValidateDataRequest : public TRepeatedWriteDataRequest
871 friend class CEp0Transfer;
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)
883 TRepeatedReadAndValidateDataRequest(const TUint16 aInterfaceNumber,const TUint8 aReadEndpointNumber,const TDesC8& aDataPattern,const TUint aNumBytesPerRead,const TUint aTotalNumBytes)
884 : TRepeatedWriteDataRequest(aInterfaceNumber,aReadEndpointNumber,aDataPattern,aNumBytesPerRead,aTotalNumBytes)
886 iRequest = KVendorRepeatedReadAndValidateDataRequest;
892 This class represents a request that requests the client device
893 to negatively acknowledge the request
895 class TNakRequest : public TEmptyRequest
899 Constructor, build a request that instructs an interface to continually NAK the request
900 @param aInterfaceNumber the interface number
903 explicit TNakRequest(TUint16 aInterfaceNumber)
905 iRequestType |= KRecipientInterface;
906 iRequest = KVendorUnrespondRequest;
907 iIndex = aInterfaceNumber;
912 This class represents a control request to the device to indicate that test case
913 has successfully completed and to disconnect the device
915 class TTestCasePassed : public TEmptyRequest
919 Constructor, build a request that informs the client device of a successful test case status
924 iRequestType |= KRecipientDevice;
925 iRequest = KVendorTestCasePassed;
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
934 class TTestCaseFailed : public TDataSendRequest
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
943 TTestCaseFailed(TInt aError,const TDesC8& aErrorMsg) : TDataSendRequest(aErrorMsg)
945 iRequestType |= KRecipientDevice;
946 iRequest = KVendorTestCaseFailed;
947 iValue = -aError; // Invert the error as symbian system errors are negative
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
956 TTestCaseFailed(TInt aError,const TDesC16& aErrorMsg) : TDataSendRequest(aErrorMsg)
958 iRequestType |= KRecipientDevice;
959 iRequest = KVendorTestCaseFailed;
960 iValue = -aError; // Invert the error as symbian system errors are negative
966 This class represents the SET_CUR audio class control request
968 class TSetCurRequest : public TClassDataSendRequest
971 explicit TSetCurRequest(const TDesC8& aData, const TUint aEndpointAddress) : TClassDataSendRequest(aData) //TUint16 aSamplingFrequency)
973 iRequestType |= KRecipientEndpoint;
974 iRequest = KAudioClassSetCur;
976 iIndex = aEndpointAddress;
982 This class describes an observer to the Ep0 control transfer
984 class MCommandObserver
988 Called when an endpoint zero test command transfer has completed
989 @param aCompletionCode the completion code of the asynchronous transfer to Ep0
991 virtual void Ep0TransferCompleteL(TInt aCompletionCode) = 0;
995 This class represents a transfer to a control endpoint 0
997 class CEp0Transfer : public CActive
1001 Constructor, build a test command to send to the connected client
1002 @param aToken the token
1004 CEp0Transfer(RUsbInterface& aInterface0);
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
1016 void SendRequest(TEmptyRequest& aSetupPacket,MCommandObserver* aObserver);
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
1023 void SendRequest(TDataRecvRequest& aSetupPacket,MCommandObserver* aObserver);
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
1030 void SendRequest(TDataSendRequest& aSetupPacket,MCommandObserver* aObserver);
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
1037 void SendRequest(TWriteSynchronousCachedReadDataRequest& aSetupPacket,MCommandObserver* aObserver);
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
1044 void SendRequest(TEndpointReadRequest& aSetupPacket,MCommandObserver* aObserver);
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
1051 void SendRequest(TClassDataSendRequest& aSetupPacket,MCommandObserver* aObserver);
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.
1057 void CancelSendRequest();
1060 Gets the time the last SendRequest was sent.
1062 void LastRequestStartTime( TTime& aDuration);
1065 Gets the time the last SendRequest was completed in RunL.
1067 void LastRequestCompletionTime( TTime& aDuration);
1072 Currently no way to cancel a single transfer, so not going to try
1082 TInt RunError(TInt aError);
1087 The USB interface endpoint zero which receives the command
1088 For the test devices modelled
1090 RUsbInterface& iUsbInterface0;
1093 The observer of client responses to host commands (uses-a)
1095 MCommandObserver* iObserver;
1098 The actual amount of data received by the host from the client
1099 in response to a command sent by the host
1104 The flag to indicate if the request sent required the clieent device to answer with
1112 The time the last SendRequest was sent.
1117 The time the last SendRequest was completed in RunL
1119 TTime iCompletionTime;