author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 02 Sep 2010 21:54:16 +0300 | |
changeset 259 | 57b9594f5772 |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1 |
// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// @file PBASE-T_USBDI-0495.cpp |
|
15 |
// @internalComponent |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include "PBASE-T_USBDI-0495.h" |
|
20 |
#include "testpolicy.h" |
|
21 |
#include "modelleddevices.h" |
|
22 |
#include "testliterals.h" |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
23 |
#include "OstTraceDefinitions.h" |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
24 |
#ifdef OST_TRACE_COMPILER_IN_USE |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
25 |
#include "PBASE-T_USBDI-0495Traces.h" |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
26 |
#endif |
0 | 27 |
|
28 |
||
29 |
||
30 |
||
31 |
namespace NUnitTesting_USBDI |
|
32 |
{ |
|
33 |
const TUint KTotalBytesToTransfer = 2*1024*1024+511; //2MB + 511 bytes |
|
34 |
const TUint KHostNumWriteBytes = 1024*256; |
|
35 |
const TInt KBulkMaxTransferSize = KHostNumWriteBytes + 1000; |
|
36 |
const TInt KDeviceNumReadBytes = 1024; |
|
37 |
||
38 |
||
39 |
//Make these single bit values ... |
|
40 |
// ... so that their completion can be easily recorded in a bit mask! |
|
41 |
const TUint32 KBulkTransferOutId[KMaxNumOutTransfers] = {1<<0, 1<<1}; |
|
42 |
const TUint32 KBulkTransferIdMask = KBulkTransferOutId[0] | KBulkTransferOutId[1]; |
|
43 |
||
44 |
const TInt KUndefinedStep = -102; |
|
45 |
const TInt KUnexpectedTransferID = -103; |
|
46 |
||
47 |
||
48 |
||
49 |
_LIT(KTestCaseId,"PBASE-T_USBDI-0495"); |
|
50 |
const TFunctorTestCase<CUT_PBASE_T_USBDI_0495,TBool> CUT_PBASE_T_USBDI_0495::iFunctor(KTestCaseId); |
|
51 |
||
52 |
CUT_PBASE_T_USBDI_0495* CUT_PBASE_T_USBDI_0495::NewL(TBool aHostRole) |
|
53 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
54 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0495_NEWL_ENTRY, aHostRole ); |
0 | 55 |
CUT_PBASE_T_USBDI_0495* self = new (ELeave) CUT_PBASE_T_USBDI_0495(aHostRole); |
56 |
CleanupStack::PushL(self); |
|
57 |
self->ConstructL(); |
|
58 |
CleanupStack::Pop(self); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0495_NEWL_EXIT, ( TUint )( self ) ); |
0 | 60 |
return self; |
61 |
} |
|
62 |
||
63 |
||
64 |
CUT_PBASE_T_USBDI_0495::CUT_PBASE_T_USBDI_0495(TBool aHostRole) |
|
65 |
: CBaseBulkTestCase(KTestCaseId,aHostRole), |
|
66 |
iCaseStep(EInProgress), |
|
67 |
iRequestValidationResultPtr(NULL,0) |
|
68 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
69 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0495_CUT_PBASE_T_USBDI_0495_ENTRY, this ); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0495_CUT_PBASE_T_USBDI_0495_EXIT, this ); |
0 | 71 |
} |
72 |
||
73 |
||
74 |
void CUT_PBASE_T_USBDI_0495::ConstructL() |
|
75 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
76 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0495_CONSTRUCTL_ENTRY, this ); |
0 | 77 |
BaseBulkConstructL(); |
78 |
||
79 |
iInBuffer = HBufC8::NewL(KTestBufferLength); |
|
80 |
||
81 |
//Create buffer to contain sufficient repeats of the payload pattern |
|
82 |
//..so that we may grab cyclic chunks of said payload pattern for OUT transfers |
|
83 |
TInt repeats = KHostNumWriteBytes / (KLiteralEnglish5().Length()) + 1 + 1; //1 extra to accommodate start point plus 1 to accomodate remainder in division |
|
84 |
iOutBuffer = HBufC8::NewL(KLiteralEnglish5().Length() * repeats); |
|
85 |
iOutBufferPtr.Set(iOutBuffer->Des()); |
|
86 |
iOutBufferPtr.Zero(); |
|
87 |
for(TInt i=0;i<repeats;i++) |
|
88 |
{ |
|
89 |
iOutBufferPtr.Append(KLiteralEnglish5()); |
|
90 |
} |
|
91 |
||
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
92 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_CONSTRUCTL, "CUT_PBASE_T_USBDI_0495::ConstructL(): buffer created"); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0495_CONSTRUCTL_EXIT, this ); |
0 | 94 |
} |
95 |
||
96 |
||
97 |
CUT_PBASE_T_USBDI_0495::~CUT_PBASE_T_USBDI_0495() |
|
98 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
99 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0495_CUT_PBASE_T_USBDI_0495_ENTRY_DUP01, this ); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0495_CUT_PBASE_T_USBDI_0495_EXIT_DUP01, this ); |
0 | 101 |
} |
102 |
||
103 |
void CUT_PBASE_T_USBDI_0495::KillTransfers() |
|
104 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
105 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0495_KILLTRANSFERS_ENTRY, this ); |
0 | 106 |
|
107 |
iOutTransfer[0]->Cancel(); |
|
108 |
iOutTransfer[1]->Cancel(); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
109 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0495_KILLTRANSFERS_EXIT, this ); |
0 | 110 |
} |
111 |
||
112 |
||
113 |
||
114 |
void CUT_PBASE_T_USBDI_0495::Ep0TransferCompleteL(TInt aCompletionCode) |
|
115 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_ENTRY, this ); |
0 | 117 |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d", aCompletionCode); |
0 | 119 |
|
120 |
if(aCompletionCode != KErrNone) |
|
121 |
{ |
|
122 |
if(iCaseStep == EFailed) |
|
123 |
{// ignore error, nad catch the TestFailed method called further down. |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP01, "***Failure sending FAIL message to client on endpoint 0***"); |
0 | 125 |
} |
126 |
else |
|
127 |
{ |
|
128 |
TBuf<256> msg; |
|
129 |
KillTransfers(); |
|
130 |
_LIT(lit, "<Error %d> Transfer to control endpoint 0 was not successful"); |
|
131 |
msg.Format(lit,aCompletionCode); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP02, msg); |
0 | 133 |
iCaseStep = EFailed; |
134 |
TTestCaseFailed request(aCompletionCode,msg); |
|
135 |
iControlEp0->SendRequest(request,this); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
136 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_EXIT, this ); |
0 | 137 |
return; |
138 |
} |
|
139 |
} |
|
140 |
||
141 |
switch(iCaseStep) |
|
142 |
{ |
|
143 |
// Test case passed |
|
144 |
case EPassed: |
|
145 |
TestPassed(); |
|
146 |
break; |
|
147 |
||
148 |
// Test case failed |
|
149 |
case EFailed: |
|
150 |
TestFailed(KErrCompletion); |
|
151 |
break; |
|
152 |
||
153 |
case ERequestRepeatedReadAndValidate: |
|
154 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
155 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP03, "Try to perform ALL transfers"); |
0 | 156 |
|
157 |
iCaseStep = ETransfer; |
|
158 |
||
159 |
iTransferComplete |= PerformNextTransfer(KBulkTransferOutId[0]); //should not validate - just perform necessary transfers |
|
160 |
iTransferComplete |= PerformNextTransfer(KBulkTransferOutId[1]); //should not validate - just perform necessary transfers |
|
161 |
if((iTransferComplete & KBulkTransferIdMask) == KBulkTransferIdMask) |
|
162 |
{ |
|
163 |
_LIT(lit, "TEST FAILURE: No data to send!!"); |
|
164 |
TBuf<40> msg(lit); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP04, msg); |
0 | 166 |
iCaseStep = EFailed; |
167 |
TTestCaseFailed request(KErrAbort,msg); |
|
168 |
return iControlEp0->SendRequest(request,this); |
|
169 |
} |
|
170 |
} |
|
171 |
break; |
|
172 |
||
173 |
case ERequestPrepareEndpointValidationResult: |
|
174 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
175 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP05, "Asking client to prepare the result of its continuous validation"); |
0 | 176 |
iCaseStep = ERequestValidationResult; |
177 |
iRequestValidationResultPtr.Set( iInBuffer->Des()); |
|
178 |
iRequestValidationResultPtr.Zero(); //reset |
|
179 |
iRequestValidationResultPtr.SetLength(KPassFailStringLength); |
|
180 |
TInterfaceGetPayloadRequest request(1,iRequestValidationResultPtr); |
|
181 |
iControlEp0->SendRequest(request,this); |
|
182 |
} |
|
183 |
break; |
|
184 |
||
185 |
case ERequestValidationResult: |
|
186 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
187 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP06, "Collect client's return validation result in a pass or fail string ..."); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
188 |
OstTraceData(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP56, "", iInBuffer->Ptr(), iInBuffer->Length()); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP07, "\n"); |
0 | 190 |
TPtr8 ptr(iInBuffer->Des()); |
191 |
if(ptr.Compare(KClientPassString) == 0) |
|
192 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
193 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP08, "Client Validation Result is a PASS"); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP09, "This is the FINAL check - the whole test has a PASSED"); |
0 | 195 |
iCaseStep = EPassed; |
196 |
TTestCasePassed request; |
|
197 |
iControlEp0->SendRequest(request,this); |
|
198 |
} |
|
199 |
else |
|
200 |
{ |
|
201 |
TBuf<256> msg; |
|
202 |
_LIT(lit, "<Error> Bulk data VALIDATION check was NOT successful"); |
|
203 |
msg.Format(lit); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP10, msg); |
0 | 205 |
iCaseStep = EFailed; |
206 |
TTestCaseFailed request(KErrCorrupt,msg); |
|
207 |
iControlEp0->SendRequest(request,this); |
|
208 |
} |
|
209 |
} |
|
210 |
break; |
|
211 |
||
212 |
default: |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_DUP11, "<Error> Unknown test step"); |
0 | 214 |
TestFailed(KErrUnknown); |
215 |
break; |
|
216 |
} |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0495_EP0TRANSFERCOMPLETEL_EXIT_DUP01, this ); |
0 | 218 |
} |
219 |
||
220 |
void CUT_PBASE_T_USBDI_0495::TransferCompleteL(TInt aTransferId,TInt aCompletionCode) |
|
221 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0495_TRANSFERCOMPLETEL_ENTRY, this ); |
0 | 223 |
Cancel(); |
224 |
||
225 |
TInt err(KErrNone); |
|
226 |
TBuf<256> msg; |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
227 |
OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_TRANSFERCOMPLETEL, "Transfer completed (id=%d), aCompletionCode = %d, test step = %d",aTransferId, aCompletionCode, iCaseStep); |
0 | 228 |
|
229 |
||
230 |
switch(iCaseStep) |
|
231 |
{ |
|
232 |
case ETransfer: |
|
233 |
{ |
|
234 |
if(aCompletionCode != KErrNone) |
|
235 |
{ |
|
236 |
KillTransfers(); |
|
237 |
err = KErrCorrupt; |
|
238 |
_LIT(lit, "<Error %d> The transfer completed with an error."); |
|
239 |
msg.Format(lit, aCompletionCode); |
|
240 |
break; |
|
241 |
} |
|
242 |
||
243 |
if(aTransferId != KBulkTransferOutId[0] && aTransferId != KBulkTransferOutId[1]) |
|
244 |
{ |
|
245 |
iTransferComplete = 0; //reset |
|
246 |
err = KUnexpectedTransferID; |
|
247 |
_LIT(lit, "<Error %d> Unexpected transfer ID, wanted %d or %d, got %d"); |
|
248 |
msg.Format(lit, err, KBulkTransferOutId[0], KBulkTransferOutId[1], aTransferId); |
|
249 |
break; |
|
250 |
} |
|
251 |
||
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
252 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_TRANSFERCOMPLETEL_DUP01, "Transfer OUT %d completed - num bytes sent = %u", aTransferId, iNumWriteBytesRequested); |
0 | 253 |
|
254 |
iTransferComplete |= PerformNextTransfer(aTransferId); |
|
255 |
||
256 |
if(err==KErrNone && (iTransferComplete & KBulkTransferIdMask) == KBulkTransferIdMask) |
|
257 |
{ |
|
258 |
/* |
|
259 |
Transfers all complete - now ask device to validate first interface's transfer OUT |
|
260 |
*/ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
261 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_TRANSFERCOMPLETEL_DUP02, "All Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete); |
0 | 262 |
if(err==KErrNone) |
263 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
264 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_TRANSFERCOMPLETEL_DUP03, "Asking client to post validation recorded on the endpoint on its interface - ready for collection"); |
0 | 265 |
iCaseStep = ERequestPrepareEndpointValidationResult; |
266 |
TRecordedValidationResultRequest request(1,1); |
|
267 |
iControlEp0->SendRequest(request,this); |
|
268 |
} |
|
269 |
} |
|
270 |
} |
|
271 |
break; |
|
272 |
default: |
|
273 |
err = KUndefinedStep; |
|
274 |
_LIT(lit, "<Error %d> Undefined case step %d reached"); |
|
275 |
msg.Format(lit,KUndefinedStep, iCaseStep); |
|
276 |
break; |
|
277 |
} |
|
278 |
||
279 |
||
280 |
if(err == KErrCompletion) |
|
281 |
//indicates data validation failure |
|
282 |
{ |
|
283 |
_LIT(lit, "<Error %d> Client has posted an error discovered in validation"); |
|
284 |
msg.Format(lit, err); |
|
285 |
} |
|
286 |
||
287 |
if(err!=KErrNone) |
|
288 |
{ |
|
289 |
KillTransfers(); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
290 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_TRANSFERCOMPLETEL_DUP04, msg); |
0 | 291 |
iCaseStep = EFailed; |
292 |
TTestCaseFailed request(err,msg); |
|
293 |
return iControlEp0->SendRequest(request,this); |
|
294 |
} |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
295 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0495_TRANSFERCOMPLETEL_EXIT, this ); |
0 | 296 |
} |
297 |
||
298 |
void CUT_PBASE_T_USBDI_0495::DeviceInsertedL(TUint aDeviceHandle) |
|
299 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0495_DEVICEINSERTEDL_ENTRY, this ); |
0 | 301 |
|
302 |
Cancel(); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
303 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_DEVICEINSERTEDL, "this - %08x", this); |
0 | 304 |
|
305 |
TBuf<256> msg; |
|
306 |
TInt err = KErrNone; |
|
307 |
if(BaseBulkDeviceInsertedL(aDeviceHandle, EFalse) == EDeviceConfigurationError) |
|
308 |
// Prepare for response from control transfer to client |
|
309 |
{ |
|
310 |
err = KErrGeneral; |
|
311 |
_LIT(lit, "Base class DeviceInsertedL failed"); |
|
312 |
msg.Format(lit); |
|
313 |
} |
|
314 |
else |
|
315 |
{ |
|
316 |
if(SetUpInterfaceAndPipesL(aDeviceHandle, 2) == EDeviceConfigurationError) |
|
317 |
// Prepare for response from control transfer to client |
|
318 |
{ |
|
319 |
err = KErrGeneral; |
|
320 |
_LIT(lit, "Base class SetUpInterfaceAndPipes for Interface 2 failed"); |
|
321 |
msg.Format(lit); |
|
322 |
} |
|
323 |
else |
|
324 |
{ |
|
325 |
||
326 |
iOutTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferOutId[0]); |
|
327 |
iOutTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferOutId[1]); |
|
328 |
||
329 |
// Initialise the descriptors for transfer |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
330 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_DEVICEINSERTEDL_DUP01, "Initialising the transfer descriptors - interface 1"); |
0 | 331 |
err = iUsbInterface1.InitialiseTransferDescriptors(); |
332 |
if(err != KErrNone) |
|
333 |
{ |
|
334 |
_LIT(lit, "<Error %d> Unable to initialise transfer descriptors"); |
|
335 |
msg.Format(lit,err); |
|
336 |
} |
|
337 |
} |
|
338 |
} |
|
339 |
if(err != KErrNone) |
|
340 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
341 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_DEVICEINSERTEDL_DUP02, msg); |
0 | 342 |
iCaseStep = EFailed; |
343 |
TTestCaseFailed request(err,msg); |
|
344 |
iControlEp0->SendRequest(request,this); |
|
345 |
} |
|
346 |
else |
|
347 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
348 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_DEVICEINSERTEDL_DUP03, "Asking client for continuous 'Read' and 'Validate'"); |
0 | 349 |
iCaseStep = ERequestRepeatedReadAndValidate; |
350 |
TRepeatedReadAndValidateDataRequest request(1,1,KLiteralEnglish5,KDeviceNumReadBytes,KTotalBytesToTransfer);// EP2 means endpoint index 2 not the actual endpoint number, here the ep with 32 byte max packet size |
|
351 |
iControlEp0->SendRequest(request,this); |
|
352 |
} |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
353 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0495_DEVICEINSERTEDL_EXIT, this ); |
0 | 354 |
} |
355 |
||
356 |
TInt CUT_PBASE_T_USBDI_0495::PerformNextTransfer(TInt aTransferId) |
|
357 |
/** |
|
358 |
@param aTransferId - specifies trasnfer to use |
|
359 |
@return zero UNLESS no more trasnfers have been queued for the specified ID in which case return the transfer ID |
|
360 |
Note: This return value allows the caller to respond easily if no more transfers are required for the specified |
|
361 |
transfer ID. |
|
362 |
*/ |
|
363 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
364 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0495_PERFORMNEXTTRANSFER_ENTRY, this ); |
0 | 365 |
|
366 |
if(iNumWriteBytesRequested >= KTotalBytesToTransfer) |
|
367 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
368 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_PERFORMNEXTTRANSFER, "****ALL DONE for Transfer using ID %d****", aTransferId); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
369 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0495_PERFORMNEXTTRANSFER_DUP01, "Num bytes actually written = %u, num bytes required to be written = %u", iNumWriteBytesRequested, KTotalBytesToTransfer); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
370 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0495_PERFORMNEXTTRANSFER_EXIT, this, aTransferId ); |
0 | 371 |
return aTransferId; //Not writing any more - signal to user that no more transfers are required on this transfer ID |
372 |
} |
|
373 |
TUint bytesToWrite = KTotalBytesToTransfer - iNumWriteBytesRequested; |
|
374 |
TUint numWriteBytes = bytesToWrite < KHostNumWriteBytes ? bytesToWrite : KHostNumWriteBytes; |
|
375 |
||
376 |
_LITDBG("PerformNextTransfer: None existant transfer ID requested"); |
|
377 |
__ASSERT_DEBUG(aTransferId==KBulkTransferOutId[0] || aTransferId==KBulkTransferOutId[1], User::Panic(lit, KErrArgument)); |
|
378 |
CBulkTransfer& bulkTransfer = aTransferId==KBulkTransferOutId[0]?*iOutTransfer[0]:*iOutTransfer[1]; |
|
379 |
bulkTransfer.TransferOut(iOutBufferPtr.Mid(iNumWriteBytesRequested%(KLiteralEnglish5().Length()), numWriteBytes), EFalse); |
|
380 |
iNumWriteBytesRequested += numWriteBytes; |
|
381 |
||
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
382 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0495_PERFORMNEXTTRANSFER_EXIT_DUP01, this ); |
0 | 383 |
return 0; //Signal to the user that another transfer is queued on the specified transfer ID |
384 |
} |
|
385 |
||
386 |
||
387 |
} //end namespace |