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-1230.cpp
|
|
15 |
// @internalComponent
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "PBASE-T_USBDI-1230.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-1230Traces.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 KHostNumReadBytes = 1024*16;
|
|
35 |
const TInt KBulkMaxTransferSize = KHostNumReadBytes + 1000;
|
|
36 |
const TInt KDeviceNumWriteBytes = 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 KBulkTransferInId0 = 1<<0;
|
|
42 |
const TUint32 KBulkTransferInId1 = 1<<1;
|
|
43 |
const TUint32 KBulkTransferInId[KMaxNumInTransfers] = {KBulkTransferInId0, KBulkTransferInId1};
|
|
44 |
const TUint32 KBulkTransferIdMask = KBulkTransferInId[0] | KBulkTransferInId[1];
|
|
45 |
|
|
46 |
const TInt KUndefinedStep = -102;
|
|
47 |
const TInt KUnexpectedTransferID = -103;
|
|
48 |
const TInt KErrReturnedDeviceReadBytesTooVariable = -140;
|
|
49 |
const TInt KTransferSuccess = +100;
|
|
50 |
|
|
51 |
const TUint KRepeatedTimerInterval = 10000; //10ms
|
|
52 |
const TUint KBaseTimer = 0;
|
|
53 |
const TUint KTestTimer = 1;
|
|
54 |
const TUint KMaxTimeDiffPercentage = 60; //on inspection worst result was just under 70%
|
|
55 |
const TUint KMaxBytesWrittenDiffPercentage = 50;
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
_LIT(KTestCaseId,"PBASE-T_USBDI-1230");
|
|
61 |
const TFunctorTestCase<CUT_PBASE_T_USBDI_1230,TBool> CUT_PBASE_T_USBDI_1230::iFunctor(KTestCaseId);
|
|
62 |
|
|
63 |
CUT_PBASE_T_USBDI_1230* CUT_PBASE_T_USBDI_1230::NewL(TBool aHostRole)
|
|
64 |
{
|
253
|
65 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_NEWL_ENTRY, aHostRole );
|
0
|
66 |
CUT_PBASE_T_USBDI_1230* self = new (ELeave) CUT_PBASE_T_USBDI_1230(aHostRole);
|
|
67 |
CleanupStack::PushL(self);
|
|
68 |
self->ConstructL();
|
|
69 |
CleanupStack::Pop(self);
|
253
|
70 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_NEWL_EXIT, ( TUint )( self ) );
|
0
|
71 |
return self;
|
|
72 |
}
|
|
73 |
|
|
74 |
|
|
75 |
CUT_PBASE_T_USBDI_1230::CUT_PBASE_T_USBDI_1230(TBool aHostRole)
|
|
76 |
: CBaseBulkTestCase(KTestCaseId,aHostRole),
|
|
77 |
iCaseStep(EInProgress)
|
|
78 |
{
|
253
|
79 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_CUT_PBASE_T_USBDI_1230_ENTRY, this );
|
|
80 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_CUT_PBASE_T_USBDI_1230_EXIT, this );
|
0
|
81 |
}
|
|
82 |
|
|
83 |
|
|
84 |
void CUT_PBASE_T_USBDI_1230::ConstructL()
|
|
85 |
{
|
253
|
86 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_CONSTRUCTL_ENTRY, this );
|
0
|
87 |
BaseBulkConstructL();
|
|
88 |
|
|
89 |
iInBuffer = HBufC8::NewL(KTestBufferLength);
|
|
90 |
|
|
91 |
iBulkTestTimer = CBulkTestTimer::NewL(*this);
|
|
92 |
|
|
93 |
//Create buffer to contain multiple lots of the payload pattern
|
|
94 |
//..so that we may grab cyclic chunks of said payload pattern
|
|
95 |
TInt repeats = KHostNumReadBytes / (KLiteralEnglish5().Length()) + 1 + 1; //1 extra to accommodate start point plus 1 to accomodate remainder in division
|
|
96 |
iValidateBuffer = HBufC8::NewL(KLiteralEnglish5().Length() * repeats);
|
|
97 |
iValidateBufferPtr.Set(iValidateBuffer->Des());
|
|
98 |
iValidateBufferPtr.Zero();
|
|
99 |
for(TInt i=0;i<repeats;i++)
|
|
100 |
{
|
|
101 |
iValidateBufferPtr.Append(KLiteralEnglish5());
|
|
102 |
}
|
|
103 |
|
253
|
104 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_CONSTRUCTL, "CUT_PBASE_T_USBDI_1230::ConstructL(): buffer created");
|
|
105 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_CONSTRUCTL_EXIT, this );
|
0
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
CUT_PBASE_T_USBDI_1230::~CUT_PBASE_T_USBDI_1230()
|
|
110 |
{
|
253
|
111 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_CUT_PBASE_T_USBDI_1230_ENTRY_DUP01, this );
|
|
112 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_CUT_PBASE_T_USBDI_1230_EXIT_DUP01, this );
|
0
|
113 |
}
|
|
114 |
|
|
115 |
void CUT_PBASE_T_USBDI_1230::KillTransfers()
|
|
116 |
{
|
253
|
117 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_KILLTRANSFERS_ENTRY, this );
|
0
|
118 |
|
|
119 |
iInTransfer[0]->Cancel();
|
|
120 |
iInTransfer[1]->Cancel();
|
253
|
121 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_KILLTRANSFERS_EXIT, this );
|
0
|
122 |
}
|
|
123 |
|
|
124 |
void CUT_PBASE_T_USBDI_1230::ExtractDeviceReadBytes()
|
|
125 |
{
|
253
|
126 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_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_1230_EXTRACTDEVICEREADBYTES, "Collect client's return of the number of bytes written on its bulk in 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_1230_EXTRACTDEVICEREADBYTES_DUP01, "********************NUM*BYTES****************************");
|
|
137 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EXTRACTDEVICEREADBYTES_DUP02, " NUM BYTES READ BY CLIENT ==== %d ==== ", numBytes);
|
|
138 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EXTRACTDEVICEREADBYTES_DUP03, "********************NUM*BYTES****************************");
|
|
139 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_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_1230_EXTRACTDEVICEREADBYTES_EXIT, this );
|
0
|
150 |
}
|
|
151 |
|
|
152 |
|
|
153 |
void CUT_PBASE_T_USBDI_1230::PostTransferAction()
|
|
154 |
{
|
253
|
155 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_POSTTRANSFERACTION_ENTRY, this );
|
0
|
156 |
switch(iTransferResult)
|
|
157 |
{
|
|
158 |
case KErrNone:
|
|
159 |
//do nothing
|
|
160 |
return;
|
|
161 |
|
|
162 |
case KTransferSuccess:
|
|
163 |
{
|
|
164 |
// Indicates success - comparison is a match
|
253
|
165 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_POSTTRANSFERACTION, "Comparison for IN transfer is a match");
|
0
|
166 |
iCaseStep = EPassed;
|
|
167 |
TTestCasePassed request;
|
|
168 |
iTransferComplete = 0; //reset
|
|
169 |
iControlEp0->SendRequest(request,this);
|
|
170 |
}
|
253
|
171 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_POSTTRANSFERACTION_EXIT, this );
|
0
|
172 |
return;
|
|
173 |
|
|
174 |
|
|
175 |
default:
|
|
176 |
{
|
|
177 |
iCaseStep = EFailed;
|
253
|
178 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_POSTTRANSFERACTION_DUP01, iMsg);
|
0
|
179 |
TTestCaseFailed request(iTransferResult,iMsg);
|
|
180 |
iControlEp0->SendRequest(request,this);
|
|
181 |
}
|
253
|
182 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_POSTTRANSFERACTION_EXIT_DUP01, this );
|
0
|
183 |
return;
|
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
|
|
188 |
TInt CUT_PBASE_T_USBDI_1230::ValidatePreviousAndPerformNextTransfers(TInt aTransferId)
|
|
189 |
{
|
253
|
190 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_ENTRY, this );
|
0
|
191 |
|
|
192 |
TUint8 index = 0;
|
|
193 |
switch(aTransferId)
|
|
194 |
{
|
|
195 |
case KBulkTransferInId0:
|
|
196 |
index = 0;
|
|
197 |
break;
|
|
198 |
|
|
199 |
case KBulkTransferInId1:
|
|
200 |
index = 1;
|
|
201 |
break;
|
|
202 |
|
|
203 |
default:
|
|
204 |
_LIT(lit, "TRANSFER ID OUT OF RANGE");
|
|
205 |
User::Panic(lit, KErrArgument);
|
253
|
206 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_EXIT, this );
|
0
|
207 |
return 0; //should never get here
|
|
208 |
}
|
|
209 |
|
253
|
210 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS, "\n");
|
|
211 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_DUP01, "Transfer[%d]", index);
|
0
|
212 |
|
|
213 |
|
|
214 |
if(iNumBytesExpected[index] != 0)
|
|
215 |
{
|
|
216 |
TPtrC8 data1(iInTransfer[index]->DataPolled());
|
|
217 |
if(ValidateData(data1, iValidateBufferPtr.Mid(iValidationStringStartPointTransfer[index], iNumBytesExpected[index])) == EFalse)
|
|
218 |
{
|
253
|
219 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_DUP02, "=====VALIDATION FAILURE: Point of Validation String Entry %u, Newly Read Bytes %u=====",iValidationStringStartPointTransfer[index], iNumBytesExpected[index]);
|
0
|
220 |
iIsValid = EFalse;
|
|
221 |
}
|
|
222 |
iNumBytesExpected[index] = 0; //reset
|
|
223 |
}
|
|
224 |
if(iNumBytesRequestedSoFar >= KTotalBytesToTransfer)
|
|
225 |
//if we are near the end end the other transfer will mop up remaining bytes...
|
|
226 |
{
|
253
|
227 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_DUP03, "****ALL DONE for Transfer[%d]****", index);
|
|
228 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_EXIT_DUP01, this, (TUint)KBulkTransferInId[index] );
|
0
|
229 |
return KBulkTransferInId[index];
|
|
230 |
}
|
|
231 |
iValidationStringStartPointTransfer[index] = iNumBytesRequestedSoFar%(KLiteralEnglish5().Length()); //PRIOR TO THIS TRANSFER
|
|
232 |
TUint bytesLeftToRead = KTotalBytesToTransfer - iNumBytesRequestedSoFar;
|
|
233 |
iNumBytesExpected[index] = bytesLeftToRead < KHostNumReadBytes ? bytesLeftToRead : KHostNumReadBytes;
|
|
234 |
iNumBytesRequestedSoFar += iNumBytesExpected[index];
|
|
235 |
iInTransfer[index]->TransferIn(KHostNumReadBytes); //rely on ZLP to complete the last 'TransferIn'
|
|
236 |
iExpectedNextTransferNumber = 1 - iExpectedNextTransferNumber;
|
|
237 |
|
253
|
238 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_EXIT_DUP02, this );
|
0
|
239 |
return 0;
|
|
240 |
}
|
|
241 |
|
|
242 |
|
|
243 |
void CUT_PBASE_T_USBDI_1230::RequestNumBytesSent(TUint8 aTimerIndex)
|
|
244 |
{
|
253
|
245 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_REQUESTNUMBYTESSENT_ENTRY, this );
|
0
|
246 |
iInBufferPtr.Set(iInBuffer->Des());
|
|
247 |
iInBufferPtr.Zero(); //reset
|
|
248 |
iInBufferPtr.SetLength(KNumberStringLength);
|
|
249 |
TInterfaceGetRecordedNumBytesReadInPayload request(1,1,iInBufferPtr);
|
|
250 |
iControlEp0->SendRequest(request,this);
|
|
251 |
iControlEp0->LastRequestStartTime( iStartTime[aTimerIndex]);
|
253
|
252 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_REQUESTNUMBYTESSENT_EXIT, this );
|
0
|
253 |
}
|
|
254 |
|
|
255 |
|
|
256 |
void CUT_PBASE_T_USBDI_1230::Ep0TransferCompleteL(TInt aCompletionCode)
|
|
257 |
{
|
253
|
258 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_ENTRY, this );
|
0
|
259 |
|
253
|
260 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d, test step = %d", aCompletionCode, iCaseStep);
|
0
|
261 |
|
|
262 |
if(aCompletionCode != KErrNone)
|
|
263 |
{
|
|
264 |
if(iCaseStep == EFailed)
|
|
265 |
{// ignore error, nad catch the TestFailed method called further down.
|
253
|
266 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP01, "***Failure sending FAIL message to client on endpoint 0***");
|
0
|
267 |
}
|
|
268 |
else
|
|
269 |
{
|
|
270 |
TBuf<256> msg;
|
|
271 |
KillTransfers();
|
|
272 |
_LIT(lit, "<Error %d> Transfer to control endpoint 0 was not successful");
|
|
273 |
msg.Format(lit,aCompletionCode);
|
253
|
274 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP02, msg);
|
0
|
275 |
iCaseStep = EFailed;
|
|
276 |
TTestCaseFailed request(aCompletionCode,msg);
|
|
277 |
iControlEp0->SendRequest(request,this);
|
253
|
278 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_EXIT, this );
|
0
|
279 |
return;
|
|
280 |
}
|
|
281 |
}
|
|
282 |
|
|
283 |
switch(iCaseStep)
|
|
284 |
{
|
|
285 |
// Test case passed
|
|
286 |
case EPassed:
|
|
287 |
TestPassed();
|
|
288 |
break;
|
|
289 |
|
|
290 |
// Test case failed
|
|
291 |
case EFailed:
|
|
292 |
TestFailed(KErrCompletion);
|
|
293 |
break;
|
|
294 |
|
|
295 |
case EGetTimerBase:
|
|
296 |
{
|
|
297 |
iControlEp0->LastRequestCompletionTime( iEndTime[KBaseTimer]);
|
253
|
298 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP03, "Asking client for repeated 'Write'");
|
0
|
299 |
iCaseStep = ERequestRepeatedWrite;
|
|
300 |
TRepeatedWriteDataRequest request(1,1,KLiteralEnglish5(),KDeviceNumWriteBytes,KTotalBytesToTransfer);// EP2 means endpoint index 2 not the actual endpoint number, here the ep with 32 byte max packet size
|
|
301 |
iControlEp0->SendRequest(request,this);
|
|
302 |
}
|
|
303 |
break;
|
|
304 |
|
|
305 |
case ERequestRepeatedWrite:
|
|
306 |
{
|
253
|
307 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP04, "Try to perform ALL transfers");
|
0
|
308 |
|
|
309 |
iCaseStep = ETransfer;
|
|
310 |
iIsValid = ETrue; //innocent until proved guilty
|
253
|
311 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP05, "\n");
|
0
|
312 |
ValidatePreviousAndPerformNextTransfers(KBulkTransferInId[0]); //should not validate - just perform necessary transfers
|
|
313 |
ValidatePreviousAndPerformNextTransfers(KBulkTransferInId[1]); //should not validate - just perform necessary transfers
|
253
|
314 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP06, "\n");
|
0
|
315 |
_LITDBG("Bulk test timer NOT instanciated");
|
|
316 |
__ASSERT_DEBUG(iBulkTestTimer, User::Panic(lit, KErrGeneral));
|
|
317 |
iBulkTestTimer->After(KRepeatedTimerInterval);
|
|
318 |
}
|
|
319 |
break;
|
|
320 |
|
|
321 |
case ETransfer:
|
|
322 |
// we must be getting num bytes read
|
|
323 |
{
|
|
324 |
ExtractDeviceReadBytes();
|
|
325 |
|
|
326 |
//Restart timer
|
|
327 |
_LITDBG("Bulk test timer NOT instanciated");
|
|
328 |
__ASSERT_DEBUG(iBulkTestTimer, User::Panic(lit, KErrGeneral));
|
|
329 |
iBulkTestTimer->After(KRepeatedTimerInterval);
|
|
330 |
}
|
|
331 |
break;
|
|
332 |
|
|
333 |
case EDelayedTransferComplete:
|
|
334 |
{
|
|
335 |
PostTransferAction();
|
|
336 |
}
|
|
337 |
break;
|
|
338 |
|
|
339 |
default:
|
253
|
340 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP07, "<Error> Unknown test step");
|
0
|
341 |
TestFailed(KErrUnknown);
|
|
342 |
break;
|
|
343 |
}
|
253
|
344 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_EXIT_DUP01, this );
|
0
|
345 |
}
|
|
346 |
|
|
347 |
void CUT_PBASE_T_USBDI_1230::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
|
|
348 |
{
|
253
|
349 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_ENTRY, this );
|
0
|
350 |
Cancel();
|
|
351 |
|
|
352 |
iTransferResult = KErrNone;
|
253
|
353 |
OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL, "Transfer completed (id=%d), aCompletionCode = %d, test step = %d",aTransferId, aCompletionCode, iCaseStep);
|
0
|
354 |
|
|
355 |
|
|
356 |
switch(iCaseStep)
|
|
357 |
{
|
|
358 |
case ETransfer:
|
|
359 |
if(aCompletionCode != KErrNone)
|
|
360 |
{
|
|
361 |
KillTransfers();
|
|
362 |
iTransferResult = KErrCorrupt;
|
|
363 |
_LIT(lit, "<Error %d> The transfer completed with an error.");
|
|
364 |
iMsg.Format(lit, aCompletionCode);
|
|
365 |
break;
|
|
366 |
}
|
|
367 |
if(aTransferId != KBulkTransferInId[0] && aTransferId != KBulkTransferInId[1])
|
|
368 |
{
|
|
369 |
iTransferComplete = 0; //reset
|
|
370 |
iTransferResult = KUnexpectedTransferID;
|
|
371 |
_LIT(lit, "<Error %d> Unexpected transfer ID, wanted %d or %d, got %d");
|
|
372 |
iMsg.Format(lit, iTransferResult, KBulkTransferInId[0], KBulkTransferInId[1], aTransferId);
|
|
373 |
break;
|
|
374 |
}
|
|
375 |
|
253
|
376 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP01, "Transfer IN %d completed - num bytes requested = %u", aTransferId, iNumBytesRequestedSoFar);
|
0
|
377 |
|
253
|
378 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP02, "\n");
|
0
|
379 |
iTransferComplete |= ValidatePreviousAndPerformNextTransfers(aTransferId);
|
253
|
380 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP03, "\n");
|
0
|
381 |
|
|
382 |
if(iTransferResult==KErrNone && (iTransferComplete & KBulkTransferIdMask) == KBulkTransferIdMask)
|
|
383 |
{
|
|
384 |
/*
|
|
385 |
Transfers all complete - now check validation
|
|
386 |
*/
|
253
|
387 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP04, "All Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete);
|
0
|
388 |
iBulkTestTimer->Cancel(); //Cancel Timer
|
|
389 |
iTransferResult = KTransferSuccess;
|
|
390 |
if(!iIsValid)
|
|
391 |
{
|
|
392 |
iTransferResult = KErrCompletion; //indicates data validation failure
|
|
393 |
iIsValid = ETrue; //reset
|
|
394 |
}
|
|
395 |
|
|
396 |
if(iTimingError == KErrTooBig)
|
|
397 |
{
|
|
398 |
__PRINT_CONTROL_TRANSFER_TIMER_COMPARISON_WARNING
|
|
399 |
iTransferResult = KErrTooBig;
|
|
400 |
iTimingError = KErrNone; //reset
|
|
401 |
}
|
|
402 |
|
|
403 |
if(KMaxBytesWrittenDiffPercentage*iDeviceMaxTimedNumBytesRead > KPercent*iDeviceMinTimedNumBytesRead)
|
|
404 |
{
|
253
|
405 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP05, "Device APPARENTLY reading rate erratic:-");
|
|
406 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP06, "Min Timed Number of Bytes = %d", iDeviceMinTimedNumBytesRead);
|
|
407 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP07, "Max Timed Number of Bytes = %d", iDeviceMaxTimedNumBytesRead);
|
0
|
408 |
iTransferResult = KErrTooBig;
|
|
409 |
iDeviceMaxTimedNumBytesRead = 0;
|
|
410 |
iDeviceMinTimedNumBytesRead = KMaxTUint;
|
|
411 |
}
|
|
412 |
}
|
|
413 |
break;
|
|
414 |
|
|
415 |
default:
|
|
416 |
iTransferResult = KUndefinedStep;
|
|
417 |
_LIT(lit, "<Error %d> Undefined case step %d reached");
|
|
418 |
iMsg.Format(lit,KUndefinedStep, iCaseStep);
|
|
419 |
break;
|
|
420 |
}
|
|
421 |
|
|
422 |
|
|
423 |
if(iTransferResult == KErrReturnedDeviceReadBytesTooVariable)
|
|
424 |
//indicates apparent device read rate validation failure
|
|
425 |
{
|
|
426 |
iMsg.Format(_L("<Error %d> Device APPEARS not to be reading bytes at a constant rate"), iTransferResult);
|
|
427 |
}
|
|
428 |
|
|
429 |
if(iTransferResult == KErrTooBig)
|
|
430 |
//indicates timing validation failure
|
|
431 |
{
|
|
432 |
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);
|
|
433 |
}
|
|
434 |
|
|
435 |
if(iTransferResult == KErrCompletion)
|
|
436 |
//indicates data validation failure
|
|
437 |
{
|
|
438 |
_LIT(lit, "<Error %d> Client has posted an error discovered in validation");
|
|
439 |
iMsg.Format(lit, iTransferResult);
|
|
440 |
}
|
|
441 |
|
|
442 |
if(iTransferResult != KErrNone)
|
|
443 |
{
|
|
444 |
KillTransfers(); //harmless if tranfers are all done
|
|
445 |
if(!iControlEp0->IsActive())
|
|
446 |
{
|
|
447 |
PostTransferAction();
|
|
448 |
}
|
|
449 |
else
|
|
450 |
{
|
|
451 |
iCaseStep = EDelayedTransferComplete; //so that we move forward when the EP0 transfer has completed
|
|
452 |
}
|
|
453 |
}
|
253
|
454 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_EXIT, this );
|
0
|
455 |
}
|
|
456 |
|
|
457 |
void CUT_PBASE_T_USBDI_1230::DeviceInsertedL(TUint aDeviceHandle)
|
|
458 |
{
|
253
|
459 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_DEVICEINSERTEDL_ENTRY, this );
|
0
|
460 |
|
|
461 |
Cancel();
|
253
|
462 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_DEVICEINSERTEDL, "this - %08x", this);
|
0
|
463 |
|
|
464 |
TBuf<256> msg;
|
|
465 |
TInt err = KErrNone;
|
|
466 |
if(BaseBulkDeviceInsertedL(aDeviceHandle, EFalse) == EDeviceConfigurationError)
|
|
467 |
// Prepare for response from control transfer to client
|
|
468 |
{
|
|
469 |
err = KErrGeneral;
|
|
470 |
_LIT(lit, "Base class DeviceInsertedL failed");
|
|
471 |
msg.Format(lit);
|
|
472 |
}
|
|
473 |
else
|
|
474 |
{
|
|
475 |
if(SetUpInterfaceAndPipesL(aDeviceHandle, 2) == EDeviceConfigurationError)
|
|
476 |
// Prepare for response from control transfer to client
|
|
477 |
{
|
|
478 |
err = KErrGeneral;
|
|
479 |
_LIT(lit, "Base class SetUpInterfaceAndPipes for Interface 2 failed");
|
|
480 |
msg.Format(lit);
|
|
481 |
}
|
|
482 |
else
|
|
483 |
{
|
|
484 |
|
|
485 |
iInTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferInId[0]);
|
|
486 |
iInTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferInId[1]);
|
|
487 |
|
|
488 |
// Initialise the descriptors for transfer
|
253
|
489 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_DEVICEINSERTEDL_DUP01, "Initialising the transfer descriptors - interface 1");
|
0
|
490 |
err = iUsbInterface1.InitialiseTransferDescriptors();
|
|
491 |
if(err != KErrNone)
|
|
492 |
{
|
|
493 |
_LIT(lit, "<Error %d> Unable to initialise transfer descriptors");
|
|
494 |
msg.Format(lit,err);
|
|
495 |
}
|
|
496 |
}
|
|
497 |
}
|
|
498 |
if(err != KErrNone)
|
|
499 |
{
|
253
|
500 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_DEVICEINSERTEDL_DUP02, msg);
|
0
|
501 |
iCaseStep = EFailed;
|
|
502 |
TTestCaseFailed request(err,msg);
|
|
503 |
iControlEp0->SendRequest(request,this);
|
|
504 |
}
|
|
505 |
else
|
|
506 |
{
|
|
507 |
iCaseStep = EGetTimerBase;
|
|
508 |
iDeviceMinTimedNumBytesRead = KMaxTUint;
|
|
509 |
iDeviceMaxTimedNumBytesRead = 0;
|
|
510 |
iDeviceNumBytesReadInTotal = 0;
|
|
511 |
RequestNumBytesSent(KBaseTimer);
|
|
512 |
}
|
253
|
513 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_DEVICEINSERTEDL_EXIT, this );
|
0
|
514 |
}
|
|
515 |
|
|
516 |
void CUT_PBASE_T_USBDI_1230::HandleBulkTestTimerFired()
|
|
517 |
{
|
253
|
518 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_HANDLEBULKTESTTIMERFIRED_ENTRY, this );
|
0
|
519 |
if(iCaseStep == ETransfer)
|
|
520 |
{
|
|
521 |
RequestNumBytesSent(KTestTimer);
|
|
522 |
}
|
253
|
523 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_HANDLEBULKTESTTIMERFIRED_EXIT, this );
|
0
|
524 |
}
|
|
525 |
|
|
526 |
} //end namespace
|