253
|
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-1229.cpp
|
|
15 |
// @internalComponent
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "PBASE-T_USBDI-1229.h"
|
|
20 |
#include "testpolicy.h"
|
|
21 |
#include "modelleddevices.h"
|
|
22 |
#include "testliterals.h"
|
253
|
23 |
#include "OstTraceDefinitions.h"
|
|
24 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
25 |
#include "PBASE-T_USBDI-1229Traces.h"
|
|
26 |
#endif
|
0
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
namespace NUnitTesting_USBDI
|
|
32 |
{
|
|
33 |
const TUint KTotalBytesToTransfer = 1024*64+511; //64kB + 511 bytes
|
|
34 |
const TUint KHostNumWriteBytes = 1024*16;
|
|
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 |
const TInt KErrReturnedDeviceReadBytesTooVariable = -140;
|
|
47 |
const TInt KTransferSuccess = +100;
|
|
48 |
|
|
49 |
const TUint KRepeatedTimerInterval = 10000; //10ms
|
|
50 |
const TUint KBaseTimer = 0;
|
|
51 |
const TUint KTestTimer = 1;
|
|
52 |
const TUint KMaxTimeDiffPercentage = 60; //on inspection worst result was just under 70%
|
|
53 |
const TUint KMaxBytesReadDiffPercentage = 50;
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
_LIT(KTestCaseId,"PBASE-T_USBDI-1229");
|
|
59 |
const TFunctorTestCase<CUT_PBASE_T_USBDI_1229,TBool> CUT_PBASE_T_USBDI_1229::iFunctor(KTestCaseId);
|
|
60 |
|
|
61 |
CUT_PBASE_T_USBDI_1229* CUT_PBASE_T_USBDI_1229::NewL(TBool aHostRole)
|
|
62 |
{
|
253
|
63 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_NEWL_ENTRY, aHostRole );
|
0
|
64 |
CUT_PBASE_T_USBDI_1229* self = new (ELeave) CUT_PBASE_T_USBDI_1229(aHostRole);
|
|
65 |
CleanupStack::PushL(self);
|
|
66 |
self->ConstructL();
|
|
67 |
CleanupStack::Pop(self);
|
253
|
68 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_NEWL_EXIT, ( TUint )( self ) );
|
0
|
69 |
return self;
|
|
70 |
}
|
|
71 |
|
|
72 |
|
|
73 |
CUT_PBASE_T_USBDI_1229::CUT_PBASE_T_USBDI_1229(TBool aHostRole)
|
|
74 |
: CBaseBulkTestCase(KTestCaseId,aHostRole),
|
|
75 |
iCaseStep(EInProgress)
|
|
76 |
{
|
253
|
77 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_CUT_PBASE_T_USBDI_1229_ENTRY, this );
|
|
78 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_CUT_PBASE_T_USBDI_1229_EXIT, this );
|
0
|
79 |
}
|
|
80 |
|
|
81 |
|
|
82 |
void CUT_PBASE_T_USBDI_1229::ConstructL()
|
|
83 |
{
|
253
|
84 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_CONSTRUCTL_ENTRY, this );
|
0
|
85 |
BaseBulkConstructL();
|
|
86 |
|
|
87 |
iInBuffer = HBufC8::NewL(KTestBufferLength);
|
|
88 |
|
|
89 |
iBulkTestTimer = CBulkTestTimer::NewL(*this);
|
|
90 |
|
|
91 |
//Create buffer to contain multiple lots of the payload pattern
|
|
92 |
//..so that we may grab cyclic chunks of said payload pattern
|
|
93 |
//..this is used to send to the client for validation purposes
|
|
94 |
//..AND for the host to send data
|
|
95 |
TInt repeats = KHostNumWriteBytes / (KLiteralEnglish5().Length()) + 1 + 1; //1 extra to accommodate start point plus 1 to accomodate remainder in division
|
|
96 |
iOutBuffer = HBufC8::NewL(KLiteralEnglish5().Length() * repeats);
|
|
97 |
iOutBufferPtr.Set(iOutBuffer->Des());
|
|
98 |
iOutBufferPtr.Zero();
|
|
99 |
for(TInt i=0;i<repeats;i++)
|
|
100 |
{
|
|
101 |
iOutBufferPtr.Append(KLiteralEnglish5());
|
|
102 |
}
|
|
103 |
|
253
|
104 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_CONSTRUCTL, "CUT_PBASE_T_USBDI_1229::ConstructL(): buffer created");
|
|
105 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_CONSTRUCTL_EXIT, this );
|
0
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
CUT_PBASE_T_USBDI_1229::~CUT_PBASE_T_USBDI_1229()
|
|
110 |
{
|
253
|
111 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_CUT_PBASE_T_USBDI_1229_ENTRY_DUP01, this );
|
|
112 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_CUT_PBASE_T_USBDI_1229_EXIT_DUP01, this );
|
0
|
113 |
}
|
|
114 |
|
|
115 |
void CUT_PBASE_T_USBDI_1229::KillTransfers()
|
|
116 |
{
|
253
|
117 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_KILLTRANSFERS_ENTRY, this );
|
0
|
118 |
|
|
119 |
iOutTransfer[0]->Cancel();
|
|
120 |
iOutTransfer[1]->Cancel();
|
253
|
121 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_KILLTRANSFERS_EXIT, this );
|
0
|
122 |
}
|
|
123 |
|
|
124 |
void CUT_PBASE_T_USBDI_1229::ExtractDeviceReadBytes()
|
|
125 |
{
|
253
|
126 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_EXTRACTDEVICEREADBYTES_ENTRY, this );
|
0
|
127 |
|
|
128 |
iControlEp0->LastRequestCompletionTime( iEndTime[KTestTimer]);
|
|
129 |
iTimingError = iTimingError == KErrNone ? CheckTimes(KBaseTimer, KTestTimer, KMaxTimeDiffPercentage) : iTimingError;
|
|
130 |
ResetTimes(KTestTimer);
|
|
131 |
|
253
|
132 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EXTRACTDEVICEREADBYTES, "Collect client's return of the number of bytes read on its bulk out endpoint ...");
|
0
|
133 |
TLex8 lex(iInBufferPtr.Left(KNumberStringLength));
|
|
134 |
TUint32 numBytes = 0;
|
|
135 |
User::LeaveIfError(lex.Val(numBytes, EDecimal));
|
253
|
136 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EXTRACTDEVICEREADBYTES_DUP01, "********************NUM*BYTES****************************");
|
|
137 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EXTRACTDEVICEREADBYTES_DUP02, " NUM BYTES READ BY CLIENT ==== %d ==== ", numBytes);
|
|
138 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EXTRACTDEVICEREADBYTES_DUP03, "********************NUM*BYTES****************************");
|
|
139 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EXTRACTDEVICEREADBYTES_DUP04, "\n");
|
0
|
140 |
|
|
141 |
if(numBytes != 0)
|
|
142 |
//Do not count this case - it may result from the remote resetting when all bulk transfers have completed
|
|
143 |
{
|
|
144 |
TUint numBytesSinceLast = numBytes - iDeviceNumBytesReadInTotal;
|
|
145 |
iDeviceNumBytesReadInTotal = numBytes;
|
|
146 |
iDeviceMinTimedNumBytesRead = numBytesSinceLast < iDeviceMinTimedNumBytesRead ? numBytesSinceLast : iDeviceMinTimedNumBytesRead ;
|
|
147 |
iDeviceMaxTimedNumBytesRead = numBytesSinceLast > iDeviceMaxTimedNumBytesRead ? numBytesSinceLast : iDeviceMaxTimedNumBytesRead ;;
|
|
148 |
}
|
253
|
149 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_EXTRACTDEVICEREADBYTES_EXIT, this );
|
0
|
150 |
}
|
|
151 |
|
|
152 |
|
|
153 |
void CUT_PBASE_T_USBDI_1229::PostTransferAction()
|
|
154 |
{
|
253
|
155 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_POSTTRANSFERACTION_ENTRY, this );
|
0
|
156 |
switch(iTransferResult)
|
|
157 |
{
|
|
158 |
case KErrNone:
|
|
159 |
//do nothing
|
|
160 |
return;
|
|
161 |
|
|
162 |
case KTransferSuccess:
|
|
163 |
//indicates data validation failure
|
|
164 |
{
|
253
|
165 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_POSTTRANSFERACTION, "Asking client to post validation recorded on the endpoint on its interface - ready for collection");
|
0
|
166 |
iCaseStep = ERequestPrepareEndpointValidationResult;
|
|
167 |
TRecordedValidationResultRequest request(1,1);
|
|
168 |
iControlEp0->SendRequest(request,this);
|
|
169 |
}
|
253
|
170 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_POSTTRANSFERACTION_EXIT, this );
|
0
|
171 |
return;
|
|
172 |
|
|
173 |
default:
|
|
174 |
{
|
|
175 |
iCaseStep = EFailed;
|
253
|
176 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_POSTTRANSFERACTION_DUP01, iMsg);
|
0
|
177 |
TTestCaseFailed request(iTransferResult,iMsg);
|
|
178 |
iControlEp0->SendRequest(request,this);
|
|
179 |
}
|
253
|
180 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_POSTTRANSFERACTION_EXIT_DUP01, this );
|
0
|
181 |
return;
|
|
182 |
}
|
|
183 |
}
|
|
184 |
|
|
185 |
|
|
186 |
TBool CUT_PBASE_T_USBDI_1229::PerformNextTransfer(TInt aTransferId)
|
|
187 |
{
|
253
|
188 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_PERFORMNEXTTRANSFER_ENTRY, this );
|
0
|
189 |
|
|
190 |
if(iNumWriteBytesRequested >= KTotalBytesToTransfer)
|
|
191 |
{
|
253
|
192 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_PERFORMNEXTTRANSFER, "All transfers sent - num bytes actually written = %u, num bytes required to be written = %u", iNumWriteBytesRequested, KTotalBytesToTransfer);
|
|
193 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1229_PERFORMNEXTTRANSFER_EXIT, this, EFalse );
|
0
|
194 |
return EFalse; //Not writing any more - signal to user that no more transfers are required
|
|
195 |
}
|
|
196 |
TUint bytesToWrite = KTotalBytesToTransfer - iNumWriteBytesRequested;
|
|
197 |
TUint numWriteBytes = bytesToWrite < KHostNumWriteBytes ? bytesToWrite : KHostNumWriteBytes;
|
|
198 |
|
|
199 |
_LITDBG("PerformNextTransfer: None existant transfer ID requested");
|
|
200 |
__ASSERT_DEBUG(aTransferId==KBulkTransferOutId[0] || aTransferId==KBulkTransferOutId[1], User::Panic(lit, KErrArgument));
|
|
201 |
CBulkTransfer& bulkTransfer = aTransferId==KBulkTransferOutId[0]?*iOutTransfer[0]:*iOutTransfer[1];
|
|
202 |
bulkTransfer.TransferOut(iOutBufferPtr.Mid(iNumWriteBytesRequested%(KLiteralEnglish5().Length()), numWriteBytes), EFalse);
|
|
203 |
iNumWriteBytesRequested += numWriteBytes;
|
|
204 |
|
253
|
205 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1229_PERFORMNEXTTRANSFER_EXIT_DUP01, this, ETrue );
|
0
|
206 |
return ETrue;
|
|
207 |
}
|
|
208 |
|
|
209 |
|
|
210 |
void CUT_PBASE_T_USBDI_1229::RequestNumBytesSent(TUint8 aTimerIndex)
|
|
211 |
{
|
253
|
212 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_REQUESTNUMBYTESSENT_ENTRY, this );
|
0
|
213 |
iInBufferPtr.Set(iInBuffer->Des());
|
|
214 |
iInBufferPtr.Zero(); //reset
|
|
215 |
iInBufferPtr.SetLength(KNumberStringLength);
|
|
216 |
TInterfaceGetRecordedNumBytesReadInPayload request(1,1,iInBufferPtr);
|
|
217 |
iControlEp0->SendRequest(request,this);
|
|
218 |
iControlEp0->LastRequestStartTime( iStartTime[aTimerIndex]);
|
253
|
219 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_REQUESTNUMBYTESSENT_EXIT, this );
|
0
|
220 |
}
|
|
221 |
|
|
222 |
|
|
223 |
void CUT_PBASE_T_USBDI_1229::Ep0TransferCompleteL(TInt aCompletionCode)
|
|
224 |
{
|
253
|
225 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_ENTRY, this );
|
0
|
226 |
|
253
|
227 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d, test step = %d", aCompletionCode, iCaseStep);
|
0
|
228 |
|
|
229 |
if(aCompletionCode != KErrNone)
|
|
230 |
{
|
|
231 |
if(iCaseStep == EFailed)
|
|
232 |
{// ignore error, nad catch the TestFailed method called further down.
|
253
|
233 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP01, "***Failure sending FAIL message to client on endpoint 0***");
|
0
|
234 |
}
|
|
235 |
else
|
|
236 |
{
|
|
237 |
TBuf<256> msg;
|
|
238 |
KillTransfers();
|
|
239 |
_LIT(lit, "<Error %d> Transfer to control endpoint 0 was not successful");
|
|
240 |
msg.Format(lit,aCompletionCode);
|
253
|
241 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP02, msg);
|
0
|
242 |
iCaseStep = EFailed;
|
|
243 |
TTestCaseFailed request(aCompletionCode,msg);
|
|
244 |
iControlEp0->SendRequest(request,this);
|
253
|
245 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_EXIT, this );
|
0
|
246 |
return;
|
|
247 |
}
|
|
248 |
}
|
|
249 |
|
|
250 |
switch(iCaseStep)
|
|
251 |
{
|
|
252 |
// Test case passed
|
|
253 |
case EPassed:
|
|
254 |
TestPassed();
|
|
255 |
break;
|
|
256 |
|
|
257 |
// Test case failed
|
|
258 |
case EFailed:
|
|
259 |
TestFailed(KErrCompletion);
|
|
260 |
break;
|
|
261 |
|
|
262 |
case EGetTimerBase:
|
|
263 |
{
|
|
264 |
iControlEp0->LastRequestCompletionTime( iEndTime[KBaseTimer]);
|
253
|
265 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP03, "Asking client for continuous 'Read' and 'Validate'");
|
0
|
266 |
iCaseStep = ERequestRepeatedReadAndValidate;
|
|
267 |
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
|
|
268 |
iControlEp0->SendRequest(request,this);
|
|
269 |
}
|
|
270 |
break;
|
|
271 |
|
|
272 |
case ERequestRepeatedReadAndValidate:
|
|
273 |
{
|
253
|
274 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP04, "Try to perform ALL transfers");
|
0
|
275 |
|
|
276 |
iCaseStep = ETransfer;
|
|
277 |
|
|
278 |
PerformNextTransfer(KBulkTransferOutId[0]);
|
|
279 |
PerformNextTransfer(KBulkTransferOutId[1]);
|
|
280 |
_LITDBG("Bulk test timer NOT instanciated");
|
|
281 |
__ASSERT_DEBUG(iBulkTestTimer, User::Panic(lit, KErrGeneral));
|
|
282 |
iBulkTestTimer->After(KRepeatedTimerInterval);
|
|
283 |
}
|
|
284 |
break;
|
|
285 |
|
|
286 |
case ETransfer:
|
|
287 |
// we must be getting num bytes read
|
|
288 |
ExtractDeviceReadBytes();
|
|
289 |
|
|
290 |
//Restart timer
|
|
291 |
_LITDBG("Bulk test timer NOT instanciated");
|
|
292 |
__ASSERT_DEBUG(iBulkTestTimer, User::Panic(lit, KErrGeneral));
|
|
293 |
iBulkTestTimer->After(KRepeatedTimerInterval);
|
|
294 |
break;
|
|
295 |
|
|
296 |
case EDelayedTransferComplete:
|
|
297 |
PostTransferAction();
|
|
298 |
break;
|
|
299 |
|
|
300 |
case ERequestPrepareEndpointValidationResult:
|
|
301 |
{
|
253
|
302 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP05, "Asking client to prepare the result of its continuous validation");
|
0
|
303 |
iCaseStep = ERequestValidationResult;
|
|
304 |
iInBufferPtr.Set(iInBuffer->Des());
|
|
305 |
iInBufferPtr.Zero(); //reset
|
|
306 |
iInBufferPtr.SetLength(KPassFailStringLength);
|
|
307 |
TInterfaceGetPayloadRequest request(1,iInBufferPtr);
|
|
308 |
iControlEp0->SendRequest(request,this);
|
|
309 |
}
|
|
310 |
break;
|
|
311 |
|
|
312 |
case ERequestValidationResult:
|
253
|
313 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP06, "Collect client's return validation result in a pass or fail string ...");
|
|
314 |
OstTraceData(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP56, "", iInBuffer->Ptr(), iInBuffer->Length());
|
|
315 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP07, "\n");
|
0
|
316 |
iInBufferPtr.Set(iInBuffer->Des());
|
|
317 |
if(iInBufferPtr.Compare(KClientPassString) == 0)
|
|
318 |
{
|
253
|
319 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP08, "Client Validation Result is a PASS");
|
|
320 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP09, "This is the FINAL check - the whole test has a PASSED");
|
0
|
321 |
iCaseStep = EPassed;
|
|
322 |
TTestCasePassed request;
|
|
323 |
iControlEp0->SendRequest(request,this);
|
|
324 |
}
|
|
325 |
else
|
|
326 |
{
|
|
327 |
TBuf<256> msg;
|
|
328 |
_LIT(lit, "<Error> Bulk data VALIDATION check was NOT successful");
|
|
329 |
msg.Format(lit);
|
253
|
330 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP10, msg);
|
0
|
331 |
iCaseStep = EFailed;
|
|
332 |
TTestCaseFailed request(KErrCorrupt,msg);
|
|
333 |
iControlEp0->SendRequest(request,this);
|
|
334 |
}
|
|
335 |
break;
|
|
336 |
|
|
337 |
default:
|
253
|
338 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP11, "<Error> Unknown test step");
|
0
|
339 |
TestFailed(KErrUnknown);
|
|
340 |
break;
|
|
341 |
}
|
253
|
342 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_EXIT_DUP01, this );
|
0
|
343 |
}
|
|
344 |
|
|
345 |
void CUT_PBASE_T_USBDI_1229::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
|
|
346 |
{
|
253
|
347 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_ENTRY, this );
|
0
|
348 |
Cancel();
|
|
349 |
|
|
350 |
iTransferResult = KErrNone;
|
253
|
351 |
OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL, "Transfer completed (id=%d), aCompletionCode = %d, test step = %d",aTransferId, aCompletionCode, iCaseStep);
|
0
|
352 |
|
|
353 |
|
|
354 |
switch(iCaseStep)
|
|
355 |
{
|
|
356 |
case ETransfer:
|
|
357 |
if(aCompletionCode != KErrNone)
|
|
358 |
{
|
|
359 |
KillTransfers();
|
|
360 |
iTransferResult = KErrCorrupt;
|
|
361 |
_LIT(lit, "<Error %d> The transfer completed with an error.");
|
|
362 |
iMsg.Format(lit, aCompletionCode);
|
|
363 |
break;
|
|
364 |
}
|
|
365 |
if(aTransferId != KBulkTransferOutId[0] && aTransferId != KBulkTransferOutId[1])
|
|
366 |
{
|
|
367 |
iTransferComplete = 0; //reset
|
|
368 |
iTransferResult = KUnexpectedTransferID;
|
|
369 |
_LIT(lit, "<Error %d> Unexpected transfer ID, wanted %d or %d, got %d");
|
|
370 |
iMsg.Format(lit, iTransferResult, KBulkTransferOutId[0], KBulkTransferOutId[1], aTransferId);
|
|
371 |
break;
|
|
372 |
}
|
253
|
373 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP01, "Transfer OUT %d completed - num bytes sent = %d", aTransferId, iNumWriteBytesRequested);
|
0
|
374 |
|
|
375 |
if(PerformNextTransfer(aTransferId)==EFalse)
|
|
376 |
{
|
|
377 |
iTransferComplete |= aTransferId;
|
253
|
378 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP02, "All transfer OUT %ds completed (Transfer Completion Aggregation Mask 0x%x)", aTransferId, iTransferComplete);
|
0
|
379 |
}
|
|
380 |
|
|
381 |
if(iTransferResult==KErrNone && (iTransferComplete & KBulkTransferIdMask) == KBulkTransferIdMask)
|
|
382 |
{
|
|
383 |
/*
|
|
384 |
Transfers all complete - now ask device to validate first interface's transfer OUT
|
|
385 |
*/
|
253
|
386 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP03, "All Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete);
|
0
|
387 |
if(iTransferResult==KErrNone)
|
|
388 |
{
|
|
389 |
iBulkTestTimer->Cancel(); //Cancel Timer
|
|
390 |
iTransferResult = KTransferSuccess;
|
|
391 |
if(iTimingError == KErrTooBig)
|
|
392 |
{
|
|
393 |
__PRINT_CONTROL_TRANSFER_TIMER_COMPARISON_WARNING
|
|
394 |
iTransferResult = KErrTooBig;
|
|
395 |
iTimingError = KErrNone; //reset
|
|
396 |
}
|
|
397 |
if(KMaxBytesReadDiffPercentage*iDeviceMaxTimedNumBytesRead > KPercent*iDeviceMinTimedNumBytesRead)
|
|
398 |
{
|
253
|
399 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP04, "Device APPARENTLY reading rate erratic:-");
|
|
400 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP05, "Min Timed Number of Bytes = %d", iDeviceMinTimedNumBytesRead);
|
|
401 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP06, "Max Timed Number of Bytes = %d", iDeviceMaxTimedNumBytesRead);
|
0
|
402 |
iTransferResult = KErrTooBig;
|
|
403 |
iDeviceMaxTimedNumBytesRead = 0;
|
|
404 |
iDeviceMinTimedNumBytesRead = KMaxTUint;
|
|
405 |
}
|
|
406 |
}
|
|
407 |
}
|
|
408 |
break;
|
|
409 |
|
|
410 |
default:
|
|
411 |
iTransferResult = KUndefinedStep;
|
|
412 |
_LIT(lit, "<Error %d> Undefined case step %d reached");
|
|
413 |
iMsg.Format(lit,KUndefinedStep, iCaseStep);
|
|
414 |
break;
|
|
415 |
}
|
|
416 |
|
|
417 |
|
|
418 |
if(iTransferResult == KErrReturnedDeviceReadBytesTooVariable)
|
|
419 |
//indicates apparent device read rate validation failure
|
|
420 |
{
|
|
421 |
iMsg.Format(_L("<Error %d> Device APPEARS not to be reading bytes at a constant rate"), iTransferResult);
|
|
422 |
}
|
|
423 |
|
|
424 |
if(iTransferResult == KErrTooBig)
|
|
425 |
//indicates timing validation failure
|
|
426 |
{
|
|
427 |
iMsg.Format(_L("<Error %d> Timer comparison showed too great a difference in transfer times between the time taken by EP0 transfers with and without a bulk transfer"), iTransferResult);
|
|
428 |
}
|
|
429 |
|
|
430 |
if(iTransferResult == KErrCompletion)
|
|
431 |
//indicates data validation failure
|
|
432 |
{
|
|
433 |
_LIT(lit, "<Error %d> Client has posted an error discovered in validation");
|
|
434 |
iMsg.Format(lit, iTransferResult);
|
|
435 |
}
|
|
436 |
|
|
437 |
if(iTransferResult != KErrNone)
|
|
438 |
{
|
|
439 |
KillTransfers(); //harmless if tranfers are all done
|
|
440 |
if(!iControlEp0->IsActive())
|
|
441 |
{
|
|
442 |
PostTransferAction();
|
|
443 |
}
|
|
444 |
else
|
|
445 |
{
|
|
446 |
iCaseStep = EDelayedTransferComplete; //so that we move forward when the EP0 transfer has completed
|
|
447 |
}
|
|
448 |
}
|
253
|
449 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_EXIT, this );
|
0
|
450 |
}
|
|
451 |
|
|
452 |
void CUT_PBASE_T_USBDI_1229::DeviceInsertedL(TUint aDeviceHandle)
|
|
453 |
{
|
253
|
454 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_DEVICEINSERTEDL_ENTRY, this );
|
0
|
455 |
|
|
456 |
Cancel();
|
253
|
457 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_DEVICEINSERTEDL, "this - %08x", this);
|
0
|
458 |
|
|
459 |
TBuf<256> msg;
|
|
460 |
TInt err = KErrNone;
|
|
461 |
if(BaseBulkDeviceInsertedL(aDeviceHandle, EFalse) == EDeviceConfigurationError)
|
|
462 |
// Prepare for response from control transfer to client
|
|
463 |
{
|
|
464 |
err = KErrGeneral;
|
|
465 |
_LIT(lit, "Base class DeviceInsertedL failed");
|
|
466 |
msg.Format(lit);
|
|
467 |
}
|
|
468 |
else
|
|
469 |
{
|
|
470 |
if(SetUpInterfaceAndPipesL(aDeviceHandle, 2) == EDeviceConfigurationError)
|
|
471 |
// Prepare for response from control transfer to client
|
|
472 |
{
|
|
473 |
err = KErrGeneral;
|
|
474 |
_LIT(lit, "Base class SetUpInterfaceAndPipes for Interface 2 failed");
|
|
475 |
msg.Format(lit);
|
|
476 |
}
|
|
477 |
else
|
|
478 |
{
|
|
479 |
|
|
480 |
iOutTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferOutId[0]);
|
|
481 |
iOutTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferOutId[1]);
|
|
482 |
|
|
483 |
// Initialise the descriptors for transfer
|
253
|
484 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_DEVICEINSERTEDL_DUP01, "Initialising the transfer descriptors - interface 1");
|
0
|
485 |
err = iUsbInterface1.InitialiseTransferDescriptors();
|
|
486 |
if(err != KErrNone)
|
|
487 |
{
|
|
488 |
_LIT(lit, "<Error %d> Unable to initialise transfer descriptors");
|
|
489 |
msg.Format(lit,err);
|
|
490 |
}
|
|
491 |
}
|
|
492 |
}
|
|
493 |
if(err != KErrNone)
|
|
494 |
{
|
253
|
495 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_DEVICEINSERTEDL_DUP02, msg);
|
0
|
496 |
iCaseStep = EFailed;
|
|
497 |
TTestCaseFailed request(err,msg);
|
|
498 |
iControlEp0->SendRequest(request,this);
|
|
499 |
}
|
|
500 |
else
|
|
501 |
{
|
|
502 |
iCaseStep = EGetTimerBase;
|
|
503 |
iDeviceMinTimedNumBytesRead = KMaxTUint;
|
|
504 |
iDeviceMaxTimedNumBytesRead = 0;
|
|
505 |
iDeviceNumBytesReadInTotal = 0;
|
|
506 |
RequestNumBytesSent(KBaseTimer);
|
|
507 |
}
|
253
|
508 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_DEVICEINSERTEDL_EXIT, this );
|
0
|
509 |
}
|
|
510 |
|
|
511 |
void CUT_PBASE_T_USBDI_1229::HandleBulkTestTimerFired()
|
|
512 |
{
|
253
|
513 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_HANDLEBULKTESTTIMERFIRED_ENTRY, this );
|
0
|
514 |
if(iCaseStep == ETransfer)
|
|
515 |
{
|
|
516 |
RequestNumBytesSent(KTestTimer);
|
|
517 |
}
|
253
|
518 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_HANDLEBULKTESTTIMERFIRED_EXIT, this );
|
0
|
519 |
}
|
|
520 |
|
|
521 |
} //end namespace
|