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