12 // |
12 // |
13 // Description: |
13 // Description: |
14 // e32test/usb/t_usb_device/src/activerw.cpp |
14 // e32test/usb/t_usb_device/src/activerw.cpp |
15 // USB Test Program T_USB_DEVICE, functional part. |
15 // USB Test Program T_USB_DEVICE, functional part. |
16 // Device-side part, to work against T_USB_HOST running on the host. |
16 // Device-side part, to work against T_USB_HOST running on the host. |
17 // |
17 // |
18 // |
18 // |
19 |
19 |
20 #include "general.h" // CActiveControl, CActiveRW |
20 #include "general.h" // CActiveControl, CActiveRW |
21 #include "config.h" |
21 #include "config.h" |
22 #include "activerw.h" |
22 #include "activerw.h" |
23 #include "activetimer.h" |
23 #include "activetimer.h" |
24 #include "usblib.h" // Helpers |
24 #include "usblib.h" // Helpers |
|
25 #include "OstTraceDefinitions.h" |
|
26 #ifdef OST_TRACE_COMPILER_IN_USE |
|
27 #include "activerwTraces.h" |
|
28 #endif |
|
29 |
25 |
30 |
26 _LIT(KFileName, "\\T_USBFILE.BIN"); |
31 _LIT(KFileName, "\\T_USBFILE.BIN"); |
27 |
32 |
28 extern RTest test; |
33 extern RTest test; |
29 extern TBool gVerbose; |
34 extern TBool gVerbose; |
45 |
50 |
46 CActiveRW::CActiveRW(CConsoleBase* aConsole, RDEVCLIENT* aPort, RFs aFs, TUint16 aIndex, TBool aLastSetting) |
51 CActiveRW::CActiveRW(CConsoleBase* aConsole, RDEVCLIENT* aPort, RFs aFs, TUint16 aIndex, TBool aLastSetting) |
47 : CActive(EPriorityNormal), |
52 : CActive(EPriorityNormal), |
48 #ifndef USB_SC |
53 #ifndef USB_SC |
49 iWriteBuf((TUint8 *)NULL,0,0), // temporary initialisation |
54 iWriteBuf((TUint8 *)NULL,0,0), // temporary initialisation |
50 iReadBuf((TUint8 *)NULL,0,0), // temporary initialisation |
55 iReadBuf((TUint8 *)NULL,0,0), // temporary initialisation |
51 #endif |
56 #endif |
52 iConsole(aConsole), |
57 iConsole(aConsole), |
53 iPort(aPort), |
58 iPort(aPort), |
54 iBufSz(0), |
59 iBufSz(0), |
55 iMaxPktSz(0), |
60 iMaxPktSz(0), |
64 iIndex (aIndex), |
69 iIndex (aIndex), |
65 iLastSetting (aLastSetting) |
70 iLastSetting (aLastSetting) |
66 { |
71 { |
67 gActiveTestCount++; |
72 gActiveTestCount++; |
68 TUSB_VERBOSE_PRINT("CActiveRW::CActiveRW()"); |
73 TUSB_VERBOSE_PRINT("CActiveRW::CActiveRW()"); |
|
74 if(gVerbose) |
|
75 { |
|
76 OstTrace0(TRACE_VERBOSE, CACTIVERW_CACTIVERW, "CActiveRW::CActiveRW()"); |
|
77 } |
69 } |
78 } |
70 |
79 |
71 |
80 |
72 CActiveRW* CActiveRW::NewL(CConsoleBase* aConsole, RDEVCLIENT* aPort, RFs aFs, TUint16 aIndex, TBool aLastSetting) |
81 CActiveRW* CActiveRW::NewL(CConsoleBase* aConsole, RDEVCLIENT* aPort, RFs aFs, TUint16 aIndex, TBool aLastSetting) |
73 { |
82 { |
|
83 //TUSB_VERBOSE_APRINT("CActiveRW::NewL()"); |
|
84 //OstTrace0(TRACE_NORMAL, CACTIVERW_NEWL, "CActiveRW::NewL()"); |
74 |
85 |
75 CActiveRW* self = new (ELeave) CActiveRW(aConsole, aPort, aFs, aIndex, aLastSetting); |
86 CActiveRW* self = new (ELeave) CActiveRW(aConsole, aPort, aFs, aIndex, aLastSetting); |
76 CleanupStack::PushL(self); |
87 CleanupStack::PushL(self); |
77 self->ConstructL(); |
88 self->ConstructL(); |
78 CActiveScheduler::Add(self); |
89 CActiveScheduler::Add(self); |
82 |
93 |
83 |
94 |
84 void CActiveRW::ConstructL() |
95 void CActiveRW::ConstructL() |
85 { |
96 { |
86 TUSB_VERBOSE_PRINT("CActiveRW::ConstructL()"); |
97 TUSB_VERBOSE_PRINT("CActiveRW::ConstructL()"); |
|
98 if(gVerbose) |
|
99 { |
|
100 OstTrace0(TRACE_VERBOSE, CACTIVERW_CONSTRUCTL, "CActiveRW::ConstructL()"); |
|
101 } |
87 |
102 |
88 // Create read timeout timer active object (but don't activate it yet) |
103 // Create read timeout timer active object (but don't activate it yet) |
89 iTimeoutTimer = CActiveTimer::NewL(iConsole, iPort); |
104 iTimeoutTimer = CActiveTimer::NewL(iConsole, iPort); |
90 if (!iTimeoutTimer) |
105 if (!iTimeoutTimer) |
91 { |
106 { |
92 TUSB_PRINT("Failed to create timeout timer"); |
107 TUSB_PRINT("Failed to create timeout timer"); |
|
108 OstTrace0(TRACE_NORMAL, CACTIVERW_CONSTRUCTL_DUP01, "Failed to create timeout timer"); |
93 } |
109 } |
94 } |
110 } |
95 |
111 |
96 |
112 |
97 CActiveRW::~CActiveRW() |
113 CActiveRW::~CActiveRW() |
98 { |
114 { |
99 TUSB_VERBOSE_PRINT("CActiveRW::~CActiveRW()"); |
115 TUSB_VERBOSE_PRINT("CActiveRW::~CActiveRW()"); |
|
116 if(gVerbose) |
|
117 { |
|
118 OstTrace0(TRACE_VERBOSE, CACTIVERW_DCACTIVERW, "CActiveRW::~CActiveRW()"); |
|
119 } |
100 Cancel(); // base class |
120 Cancel(); // base class |
101 delete iTimeoutTimer; |
121 delete iTimeoutTimer; |
102 #ifdef USB_SC |
122 #ifdef USB_SC |
103 if ((TENDPOINTNUMBER)iTestParams.outPipe <= KMaxEndpointsPerClient) |
123 if ((TENDPOINTNUMBER)iTestParams.outPipe <= KMaxEndpointsPerClient) |
104 { |
124 { |
132 #ifndef USB_SC |
152 #ifndef USB_SC |
133 TAny * newBuffer = User::Alloc(aTpPtr->maxSize); |
153 TAny * newBuffer = User::Alloc(aTpPtr->maxSize); |
134 if (newBuffer == NULL) |
154 if (newBuffer == NULL) |
135 { |
155 { |
136 TUSB_PRINT ("Failure to allocate heap memory"); |
156 TUSB_PRINT ("Failure to allocate heap memory"); |
|
157 OstTrace0 (TRACE_ERROR, CACTIVERW_SETTESTPARAMS, "Failure to allocate heap memory"); |
137 test(EFalse); |
158 test(EFalse); |
138 } |
159 } |
139 iReadBuf.Set((TUint8 *)newBuffer,0,(TInt)aTpPtr->maxSize); |
160 iReadBuf.Set((TUint8 *)newBuffer,0,(TInt)aTpPtr->maxSize); |
140 #endif |
161 #endif |
141 TBuf8<KUsbDescSize_Endpoint> descriptor; |
162 TBuf8<KUsbDescSize_Endpoint> descriptor; |
142 TUSB_VERBOSE_PRINT2 ("GetEndpointDescriptor Alt Setting %d Endpoint %d",iTestParams.alternateSetting, iTestParams.outPipe); |
163 TUSB_VERBOSE_PRINT2 ("GetEndpointDescriptor Alt Setting %d Endpoint %d",iTestParams.alternateSetting, iTestParams.outPipe); |
|
164 if(gVerbose) |
|
165 { |
|
166 OstTraceExt2 (TRACE_VERBOSE, CACTIVERW_SETTESTPARAMS_DUP01, "GetEndpointDescriptor Alt Setting %d Endpoint %d",iTestParams.alternateSetting, iTestParams.outPipe); |
|
167 } |
143 TInt r = iPort->GetEndpointDescriptor(iTestParams.alternateSetting, (TENDPOINTNUMBER)iTestParams.outPipe, descriptor); |
168 TInt r = iPort->GetEndpointDescriptor(iTestParams.alternateSetting, (TENDPOINTNUMBER)iTestParams.outPipe, descriptor); |
144 if ((TUint)r != iReadSize) |
169 if ((TUint)r != iReadSize) |
145 { |
170 { |
146 TUSB_PRINT("Failed to get endpoint descriptor"); |
171 TUSB_PRINT("Failed to get endpoint descriptor"); |
|
172 OstTrace0(TRACE_ERROR, CACTIVERW_SETTESTPARAMS_DUP02, "Failed to get endpoint descriptor"); |
147 test(EFalse); |
173 test(EFalse); |
148 return; |
174 return; |
149 } |
175 } |
150 |
176 |
151 iMaxPktSz = EpSize(descriptor[KEpDesc_PacketSizeOffset],descriptor[KEpDesc_PacketSizeOffset+1]); |
177 iMaxPktSz = EpSize(descriptor[KEpDesc_PacketSizeOffset],descriptor[KEpDesc_PacketSizeOffset+1]); |
152 TUSB_VERBOSE_PRINT5 ("Out Endpoint 0x%x attributes 0x%x interface %d setting %d max packet size %d", |
178 TUSB_VERBOSE_PRINT5 ("Out Endpoint 0x%x attributes 0x%x interface %d setting %d max packet size %d", |
153 descriptor[KEpDesc_AddressOffset],descriptor[KEpDesc_AttributesOffset],iTestParams.interfaceNumber,iTestParams.alternateSetting,iMaxPktSz); |
179 descriptor[KEpDesc_AddressOffset],descriptor[KEpDesc_AttributesOffset],iTestParams.interfaceNumber,iTestParams.alternateSetting,iMaxPktSz); |
|
180 if(gVerbose) |
|
181 { |
|
182 OstTraceExt5 (TRACE_VERBOSE, CACTIVERW_SETTESTPARAMS_DUP03, "Out Endpoint 0x%x attributes 0x%x interface %d setting %d max packet size %d", |
|
183 (TUint)descriptor[KEpDesc_AddressOffset],(TUint)descriptor[KEpDesc_AttributesOffset],(TUint)iTestParams.interfaceNumber,(TUint)iTestParams.alternateSetting,(TUint)iMaxPktSz); |
|
184 } |
154 if (!gSkip && iMaxPktSz != (TUint)gInterfaceConfig[iTestParams.interfaceNumber][iTestParams.alternateSetting]->iInfoPtr->iEndpointData[iTestParams.outPipe-1].iSize) |
185 if (!gSkip && iMaxPktSz != (TUint)gInterfaceConfig[iTestParams.interfaceNumber][iTestParams.alternateSetting]->iInfoPtr->iEndpointData[iTestParams.outPipe-1].iSize) |
155 { |
186 { |
156 TUSB_PRINT4("Error - Interface %d Setting %d Endpoint %d Max Packet Size %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe,iMaxPktSz); |
187 TUSB_PRINT4("Error - Interface %d Setting %d Endpoint %d Max Packet Size %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe,iMaxPktSz); |
|
188 OstTraceExt4(TRACE_ERROR, CACTIVERW_SETTESTPARAMS_DUP04, "Error - Interface %d Setting %d Endpoint %d Max Packet Size %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe,iMaxPktSz); |
157 test(EFalse); |
189 test(EFalse); |
158 return; |
190 return; |
159 } |
191 } |
160 } |
192 } |
161 if ((TENDPOINTNUMBER)iTestParams.inPipe <= KMaxEndpointsPerClient) |
193 if ((TENDPOINTNUMBER)iTestParams.inPipe <= KMaxEndpointsPerClient) |
163 #ifndef USB_SC |
195 #ifndef USB_SC |
164 TAny * newBuffer = User::Alloc(aTpPtr->maxSize); |
196 TAny * newBuffer = User::Alloc(aTpPtr->maxSize); |
165 if (newBuffer == NULL) |
197 if (newBuffer == NULL) |
166 { |
198 { |
167 TUSB_PRINT ("Failure to allocate heap memory"); |
199 TUSB_PRINT ("Failure to allocate heap memory"); |
|
200 OstTrace0 (TRACE_ERROR, CACTIVERW_SETTESTPARAMS_DUP05, "Failure to allocate heap memory"); |
168 test(EFalse); |
201 test(EFalse); |
169 } |
202 } |
170 iWriteBuf.Set((TUint8 *)newBuffer,0,(TInt)aTpPtr->maxSize); |
203 iWriteBuf.Set((TUint8 *)newBuffer,0,(TInt)aTpPtr->maxSize); |
171 #endif |
204 #endif |
172 TBuf8<KUsbDescSize_Endpoint> descriptor; |
205 TBuf8<KUsbDescSize_Endpoint> descriptor; |
173 TUSB_VERBOSE_PRINT2 ("GetEndpointDescriptor Alt Setting %d Endpoint %d",iTestParams.alternateSetting, iTestParams.inPipe); |
206 TUSB_VERBOSE_PRINT2 ("GetEndpointDescriptor Alt Setting %d Endpoint %d",iTestParams.alternateSetting, iTestParams.inPipe); |
|
207 if(gVerbose) |
|
208 { |
|
209 OstTraceExt2 (TRACE_VERBOSE, CACTIVERW_SETTESTPARAMS_DUP06, "GetEndpointDescriptor Alt Setting %d Endpoint %d",iTestParams.alternateSetting, iTestParams.inPipe); |
|
210 } |
174 TInt r = iPort->GetEndpointDescriptor(iTestParams.alternateSetting, (TENDPOINTNUMBER)iTestParams.inPipe, descriptor); |
211 TInt r = iPort->GetEndpointDescriptor(iTestParams.alternateSetting, (TENDPOINTNUMBER)iTestParams.inPipe, descriptor); |
175 if (r != KErrNone) |
212 if (r != KErrNone) |
176 { |
213 { |
177 TUSB_PRINT("Failed to get endpoint descriptor"); |
214 TUSB_PRINT("Failed to get endpoint descriptor"); |
|
215 OstTrace0(TRACE_ERROR, CACTIVERW_SETTESTPARAMS_DUP07, "Failed to get endpoint descriptor"); |
178 test(EFalse); |
216 test(EFalse); |
179 return; |
217 return; |
180 } |
218 } |
181 |
219 |
182 TInt maxPktSz = EpSize(descriptor[KEpDesc_PacketSizeOffset],descriptor[KEpDesc_PacketSizeOffset+1]); |
220 TInt maxPktSz = EpSize(descriptor[KEpDesc_PacketSizeOffset],descriptor[KEpDesc_PacketSizeOffset+1]); |
183 TUSB_VERBOSE_PRINT5 ("In Endpoint 0x%x attributes 0x%x interface %d setting %d max packet size %d", |
221 TUSB_VERBOSE_PRINT5 ("In Endpoint 0x%x attributes 0x%x interface %d setting %d max packet size %d", |
184 descriptor[KEpDesc_AddressOffset],descriptor[KEpDesc_AttributesOffset],iTestParams.interfaceNumber,iTestParams.alternateSetting,maxPktSz); |
222 descriptor[KEpDesc_AddressOffset],descriptor[KEpDesc_AttributesOffset],iTestParams.interfaceNumber,iTestParams.alternateSetting,maxPktSz); |
|
223 if(gVerbose) |
|
224 { |
|
225 OstTraceExt5 (TRACE_VERBOSE, CACTIVERW_SETTESTPARAMS_DUP08, "In Endpoint 0x%x attributes 0x%x interface %d setting %d max packet size %d", |
|
226 descriptor[KEpDesc_AddressOffset],descriptor[KEpDesc_AttributesOffset],iTestParams.interfaceNumber,iTestParams.alternateSetting,maxPktSz); |
|
227 } |
185 if (!gSkip && maxPktSz != gInterfaceConfig[iTestParams.interfaceNumber][iTestParams.alternateSetting]->iInfoPtr->iEndpointData[iTestParams.inPipe-1].iSize) |
228 if (!gSkip && maxPktSz != gInterfaceConfig[iTestParams.interfaceNumber][iTestParams.alternateSetting]->iInfoPtr->iEndpointData[iTestParams.inPipe-1].iSize) |
186 { |
229 { |
187 TUSB_PRINT4("Error - Interface %d Setting %d Endpoint %d Max Packet Size %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.inPipe,maxPktSz); |
230 TUSB_PRINT4("Error - Interface %d Setting %d Endpoint %d Max Packet Size %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.inPipe,maxPktSz); |
|
231 OstTraceExt4(TRACE_ERROR, CACTIVERW_SETTESTPARAMS_DUP09, "Error - Interface %d Setting %d Endpoint %d Max Packet Size %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.inPipe,maxPktSz); |
188 test(EFalse); |
232 test(EFalse); |
189 return; |
233 return; |
190 } |
234 } |
191 } |
235 } |
192 |
236 |
193 } |
237 } |
194 |
238 |
195 |
239 |
196 void CActiveRW::SetTransferMode(TXferMode aMode) |
240 void CActiveRW::SetTransferMode(TXferMode aMode) |
197 { |
241 { |
205 |
249 |
206 void CActiveRW::Suspend(TXferType aType) |
250 void CActiveRW::Suspend(TXferType aType) |
207 { |
251 { |
208 if (aType == ESuspend) |
252 if (aType == ESuspend) |
209 TUSB_VERBOSE_PRINT1("Index %d Suspend",iIndex); |
253 TUSB_VERBOSE_PRINT1("Index %d Suspend",iIndex); |
|
254 if(gVerbose) |
|
255 { |
|
256 OstTrace1(TRACE_VERBOSE, CACTIVERW_SUSPEND, "Index %d Suspend",iIndex); |
|
257 } |
210 if (aType == EAltSetting) |
258 if (aType == EAltSetting) |
211 TUSB_VERBOSE_PRINT3("Index %d Suspend for Alternate Setting - interface %d setting %d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting); |
259 TUSB_VERBOSE_PRINT3("Index %d Suspend for Alternate Setting - interface %d setting %d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting); |
|
260 if(gVerbose) |
|
261 { |
|
262 OstTraceExt3(TRACE_VERBOSE, CACTIVERW_SUSPEND_DUP01, "Index %d Suspend for Alternate Setting - interface %d setting %d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting); |
|
263 } |
212 iStatus = KRequestPending; |
264 iStatus = KRequestPending; |
213 iCurrentXfer = aType; |
265 iCurrentXfer = aType; |
214 if (!IsActive()) |
266 if (!IsActive()) |
215 { |
267 { |
216 SetActive(); |
268 SetActive(); |
217 } |
269 } |
218 } |
270 } |
219 |
271 |
220 void CActiveRW::Resume() |
272 void CActiveRW::Resume() |
221 { |
273 { |
222 TUSB_VERBOSE_PRINT3("Index %d Resume interface %d setting %d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting); |
274 TUSB_VERBOSE_PRINT3("Index %d Resume interface %d setting %d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting); |
|
275 if(gVerbose) |
|
276 { |
|
277 OstTraceExt3(TRACE_VERBOSE, CACTIVERW_RESUME, "Index %d Resume interface %d setting %d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting); |
|
278 } |
223 TRequestStatus* status = &iStatus; |
279 TRequestStatus* status = &iStatus; |
224 User::RequestComplete(status,KErrNone); |
280 User::RequestComplete(status,KErrNone); |
225 if (!IsActive()) |
281 if (!IsActive()) |
226 { |
282 { |
227 SetActive(); |
283 SetActive(); |
260 if (iTestParams.alternateSetting != gSettingNumber[iTestParams.interfaceNumber]) |
320 if (iTestParams.alternateSetting != gSettingNumber[iTestParams.interfaceNumber]) |
261 { |
321 { |
262 gSettingNumber[iTestParams.interfaceNumber] = iTestParams.alternateSetting; |
322 gSettingNumber[iTestParams.interfaceNumber] = iTestParams.alternateSetting; |
263 r = iPort->StartNextOutAlternateSetting(ETrue); |
323 r = iPort->StartNextOutAlternateSetting(ETrue); |
264 TUSB_VERBOSE_PRINT1("StartNextOutAlternateSetting retValue %d",r); |
324 TUSB_VERBOSE_PRINT1("StartNextOutAlternateSetting retValue %d",r); |
|
325 if(gVerbose) |
|
326 { |
|
327 OstTrace1(TRACE_VERBOSE, CACTIVERW_STARTORSUSPEND, "StartNextOutAlternateSetting retValue %d",r); |
|
328 } |
265 test_Value(r, (r >= KErrNone) || (r == KErrNotReady) || (r == KErrGeneral)); |
329 test_Value(r, (r >= KErrNone) || (r == KErrNotReady) || (r == KErrGeneral)); |
266 } |
330 } |
267 TUSB_VERBOSE_PRINT4 ("CActiveRW::StartOrSuspend() interface %d setting %d Out %d In %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe,iTestParams.inPipe); |
331 TUSB_VERBOSE_PRINT4 ("CActiveRW::StartOrSuspend() interface %d setting %d Out %d In %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe,iTestParams.inPipe); |
|
332 if(gVerbose) |
|
333 { |
|
334 OstTraceExt4 (TRACE_VERBOSE, CACTIVERW_STARTORSUSPEND_DUP01, "CActiveRW::StartOrSuspend() interface %d setting %d Out %d In %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe,iTestParams.inPipe); |
|
335 } |
268 if ((TENDPOINTNUMBER)iTestParams.outPipe <= KMaxEndpointsPerClient) |
336 if ((TENDPOINTNUMBER)iTestParams.outPipe <= KMaxEndpointsPerClient) |
269 { |
337 { |
270 r = iPort->OpenEndpoint(iSCReadBuf,iTestParams.outPipe); |
338 r = iPort->OpenEndpoint(iSCReadBuf,iTestParams.outPipe); |
271 test_KErrNone(r); |
339 test_KErrNone(r); |
272 } |
340 } |
288 else |
356 else |
289 { |
357 { |
290 SendData(); // or we send data |
358 SendData(); // or we send data |
291 if (iXferMode == ETransmitOnly) |
359 if (iXferMode == ETransmitOnly) |
292 { |
360 { |
293 iPktNum++; |
361 iPktNum++; |
294 iRepeat++; |
362 iRepeat++; |
295 } |
363 } |
296 } |
364 } |
297 } |
365 } |
298 } |
366 } |
299 |
367 |
300 void CActiveRW::RunL() |
368 void CActiveRW::RunL() |
301 { |
369 { |
302 #ifdef USB_SC |
370 #ifdef USB_SC |
303 TInt r = 0; |
371 TInt r = 0; |
304 #else |
372 #else |
305 TInt altSetting; |
373 TInt altSetting; |
306 #endif |
374 #endif |
307 |
375 |
308 TUSB_VERBOSE_PRINT("CActiveRW::RunL()"); |
376 TUSB_VERBOSE_PRINT("CActiveRW::RunL()"); |
|
377 if(gVerbose) |
|
378 { |
|
379 OstTrace0(TRACE_VERBOSE, CACTIVERW_RUNL, "CActiveRW::RunL()"); |
|
380 } |
309 |
381 |
310 if ((iStatus != KErrNone) && (iStatus != KErrEof)) |
382 if ((iStatus != KErrNone) && (iStatus != KErrEof)) |
311 { |
383 { |
312 TUSB_PRINT1("Error %d in RunL", iStatus.Int()); |
384 TUSB_PRINT1("Error %d in RunL", iStatus.Int()); |
|
385 OstTrace1(TRACE_NORMAL, CACTIVERW_RUNL_DUP01, "Error %d in RunL", iStatus.Int()); |
313 } |
386 } |
314 if (iDoStop) |
387 if (iDoStop) |
315 { |
388 { |
316 TUSB_PRINT("Stopped"); |
389 TUSB_PRINT("Stopped"); |
|
390 OstTrace0(TRACE_NORMAL, CACTIVERW_RUNL_DUP02, "Stopped"); |
317 iDoStop = EFalse; |
391 iDoStop = EFalse; |
318 return; |
392 return; |
319 } |
393 } |
320 switch (iCurrentXfer) |
394 switch (iCurrentXfer) |
321 { |
395 { |
332 test_KErrNone(r); |
406 test_KErrNone(r); |
333 } |
407 } |
334 #endif |
408 #endif |
335 if (iTestParams.settingRepeat && ((iRepeat < iTestParams.repeat) || !iLastSetting)) |
409 if (iTestParams.settingRepeat && ((iRepeat < iTestParams.repeat) || !iLastSetting)) |
336 { |
410 { |
337 gRW[iTestParams.afterIndex]->Resume(); |
411 gRW[iTestParams.afterIndex]->Resume(); |
338 } |
412 } |
339 Suspend(ESuspend); |
413 Suspend(ESuspend); |
340 break; |
414 break; |
341 |
415 |
342 case ESuspend: |
416 case ESuspend: |
343 #ifdef USB_SC |
417 #ifdef USB_SC |
344 TUSB_VERBOSE_PRINT3("Index %d Resumed interface %d setting test=%d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting); |
418 TUSB_VERBOSE_PRINT3("Index %d Resumed interface %d setting test=%d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting); |
|
419 if(gVerbose) |
|
420 { |
|
421 OstTraceExt3(TRACE_VERBOSE, CACTIVERW_RUNL_DUP03, "Index %d Resumed interface %d setting test=%d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting); |
|
422 } |
345 if (iTestParams.alternateSetting != gSettingNumber[iTestParams.interfaceNumber]) |
423 if (iTestParams.alternateSetting != gSettingNumber[iTestParams.interfaceNumber]) |
346 { |
424 { |
347 r = iPort->StartNextOutAlternateSetting(ETrue); |
425 r = iPort->StartNextOutAlternateSetting(ETrue); |
348 TUSB_VERBOSE_PRINT1("StartNextOutAlternateSetting retValue %d",r); |
426 TUSB_VERBOSE_PRINT1("StartNextOutAlternateSetting retValue %d",r); |
|
427 if(gVerbose) |
|
428 { |
|
429 OstTrace1(TRACE_VERBOSE, CACTIVERW_RUNL_DUP04, "StartNextOutAlternateSetting retValue %d",r); |
|
430 } |
349 test_Value(r, (r >= KErrNone) || (r == KErrNotReady) || (r == KErrGeneral)); |
431 test_Value(r, (r >= KErrNone) || (r == KErrNotReady) || (r == KErrGeneral)); |
350 if (r != KErrNotReady) |
432 if (r != KErrNotReady) |
351 { |
433 { |
352 gSettingNumber[iTestParams.interfaceNumber] = r; |
434 gSettingNumber[iTestParams.interfaceNumber] = r; |
353 } |
435 } |
357 break; |
439 break; |
358 } |
440 } |
359 } |
441 } |
360 #else |
442 #else |
361 iPort->GetAlternateSetting (altSetting); |
443 iPort->GetAlternateSetting (altSetting); |
362 TUSB_VERBOSE_PRINT4("Index %d Resumed interface %d setting test=%d actual=%d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting,altSetting); |
444 TUSB_VERBOSE_PRINT4("Index %d Resumed interface %d setting test=%d actual=%d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting,altSetting); |
|
445 if(gVerbose) |
|
446 { |
|
447 OstTraceExt4(TRACE_VERBOSE, CACTIVERW_RUNL_DUP05, "Index %d Resumed interface %d setting test=%d actual=%d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting,altSetting); |
|
448 } |
363 if (gAltSettingOnNotify) |
449 if (gAltSettingOnNotify) |
364 { |
450 { |
365 if (iTestParams.alternateSetting != altSetting) |
451 if (iTestParams.alternateSetting != altSetting) |
366 { |
452 { |
367 Suspend(EAltSetting); |
453 Suspend(EAltSetting); |
368 break; |
454 break; |
369 } |
455 } |
370 } |
456 } |
371 #endif |
457 #endif |
372 |
458 |
373 // If alternate setting is ok drops through to EAltSetting to start next read or write |
459 // If alternate setting is ok drops through to EAltSetting to start next read or write |
374 iCurrentXfer = EAltSetting; |
460 iCurrentXfer = EAltSetting; |
375 |
461 |
376 case EAltSetting: |
462 case EAltSetting: |
377 #ifdef USB_SC |
463 #ifdef USB_SC |
378 if (iTestParams.alternateSetting != gSettingNumber[iTestParams.interfaceNumber]) |
464 if (iTestParams.alternateSetting != gSettingNumber[iTestParams.interfaceNumber]) |
379 { |
465 { |
380 r = iPort->StartNextOutAlternateSetting(ETrue); |
466 r = iPort->StartNextOutAlternateSetting(ETrue); |
381 TUSB_VERBOSE_PRINT1("StartNextOutAlternateSetting retValue %d",r); |
467 TUSB_VERBOSE_PRINT1("StartNextOutAlternateSetting retValue %d",r); |
|
468 if(gVerbose) |
|
469 { |
|
470 OstTrace1(TRACE_VERBOSE, CACTIVERW_RUNL_DUP06, "StartNextOutAlternateSetting retValue %d",r); |
|
471 } |
382 test_Value(r, (r >= KErrNone) || (r == KErrNotReady) || (r == KErrGeneral)); |
472 test_Value(r, (r >= KErrNone) || (r == KErrNotReady) || (r == KErrGeneral)); |
383 if (r != KErrNotReady) |
473 if (r != KErrNotReady) |
384 { |
474 { |
385 gSettingNumber[iTestParams.interfaceNumber] = r; |
475 gSettingNumber[iTestParams.interfaceNumber] = r; |
386 } |
476 } |
436 #else |
530 #else |
437 iReadSize = iReadBuf.Length(); |
531 iReadSize = iReadBuf.Length(); |
438 ProcessReadXfer(); |
532 ProcessReadXfer(); |
439 #endif |
533 #endif |
440 break; |
534 break; |
441 |
535 |
442 default: |
536 default: |
443 TUSB_PRINT("Oops. (Shouldn't end up here...)"); |
537 TUSB_PRINT("Oops. (Shouldn't end up here...)"); |
|
538 OstTrace0(TRACE_NORMAL, CACTIVERW_RUNL_DUP08, "Oops. (Shouldn't end up here...)"); |
444 break; |
539 break; |
445 } |
540 } |
446 return; |
541 return; |
447 } |
542 } |
448 |
543 |
449 void CActiveRW::ProcessWriteXfer() |
544 void CActiveRW::ProcessWriteXfer() |
450 { |
545 { |
451 if (iXferMode == ETransmitOnly) |
546 if (iXferMode == ETransmitOnly) |
452 { |
547 { |
453 if (iTestParams.settingRepeat && iRepeat) |
548 if (iTestParams.settingRepeat && iRepeat) |
454 { |
549 { |
455 if (((iRepeat % iTestParams.settingRepeat) == 0) || (iRepeat >= iTestParams.repeat)) |
550 if (((iRepeat % iTestParams.settingRepeat) == 0) || (iRepeat >= iTestParams.repeat)) |
456 { |
551 { |
457 if ((iRepeat < iTestParams.repeat) || !iLastSetting) |
552 if ((iRepeat < iTestParams.repeat) || !iLastSetting) |
458 { |
553 { |
459 #ifdef USB_SC |
554 #ifdef USB_SC |
460 if ((TENDPOINTNUMBER)iTestParams.inPipe <= KMaxEndpointsPerClient) |
555 if ((TENDPOINTNUMBER)iTestParams.inPipe <= KMaxEndpointsPerClient) |
461 { |
556 { |
462 test_KErrNone(iSCWriteBuf.Close()); |
557 test_KErrNone(iSCWriteBuf.Close()); |
463 } |
558 } |
464 #endif |
559 #endif |
465 gRW[iTestParams.afterIndex]->Resume(); |
560 gRW[iTestParams.afterIndex]->Resume(); |
466 } |
561 } |
467 if (iRepeat < iTestParams.repeat) |
562 if (iRepeat < iTestParams.repeat) |
468 { |
563 { |
469 Suspend(ESuspend); |
564 Suspend(ESuspend); |
470 return; |
565 return; |
471 } |
566 } |
472 } |
567 } |
473 } |
568 } |
474 |
569 |
475 if ((iTestParams.repeat == 0) || (iRepeat < iTestParams.repeat)) |
570 if ((iTestParams.repeat == 0) || (iRepeat < iTestParams.repeat)) |
518 { |
614 { |
519 #ifdef USB_SC |
615 #ifdef USB_SC |
520 const TUint32 num = *reinterpret_cast<const TUint32*>(iSCReadData); |
616 const TUint32 num = *reinterpret_cast<const TUint32*>(iSCReadData); |
521 #else |
617 #else |
522 const TUint32 num = *reinterpret_cast<const TUint32*>(iReadBuf.Ptr()); |
618 const TUint32 num = *reinterpret_cast<const TUint32*>(iReadBuf.Ptr()); |
523 #endif |
619 #endif |
524 if (num != iPktNum) |
620 if (num != iPktNum) |
525 { |
621 { |
526 TUSB_PRINT3("*** Repeat %d rcv'd wrong pkt number: 0x%x (expected: 0x%x)", iRepeat, num, iPktNum); |
622 TUSB_PRINT3("*** Repeat %d rcv'd wrong pkt number: 0x%x (expected: 0x%x)", iRepeat, num, iPktNum); |
|
623 OstTraceExt3(TRACE_NORMAL, CACTIVERW_PROCESSREADXFER_DUP01, "*** Repeat %d rcv'd wrong pkt number: 0x%x (expected: 0x%x)", (TInt32)iRepeat, (TInt32)num, (TInt32)iPktNum); |
527 iPktNum = num; |
624 iPktNum = num; |
528 test(EFalse); |
625 test(EFalse); |
529 } |
626 } |
530 } |
627 } |
531 if (iDiskAccessEnabled) |
628 if (iDiskAccessEnabled) |
532 { |
629 { |
533 // Write out to disk previous completed Read |
630 // Write out to disk previous completed Read |
534 #ifdef USB_SC |
631 #ifdef USB_SC |
535 TPtr8 readBuf((TUint8 *)iSCReadData,iReadSize,iReadSize); |
632 TPtr8 readBuf((TUint8 *)iSCReadData,iReadSize,iReadSize); |
536 WriteBufferToDisk(readBuf, iReadSize); |
633 WriteBufferToDisk(readBuf, iReadSize); |
537 #else |
634 #else |
538 TUSB_VERBOSE_PRINT2("Max Buffer Size = %d (iReadBuf.Size(): %d)", iTestParams.maxSize, iReadBuf.Size()); |
635 TUSB_VERBOSE_PRINT2("Max Buffer Size = %d (iReadBuf.Size(): %d)", iTestParams.maxSize, iReadBuf.Size()); |
|
636 if(gVerbose) |
|
637 { |
|
638 OstTraceExt2(TRACE_VERBOSE, CACTIVERW_PROCESSREADXFER_DUP02, "Max Buffer Size = %u (iReadBuf.Size(): %d)", (TUint32)iTestParams.maxSize, (TUint32)iReadBuf.Size()); |
|
639 } |
539 WriteBufferToDisk(iReadBuf, iTestParams.maxSize); |
640 WriteBufferToDisk(iReadBuf, iTestParams.maxSize); |
540 #endif |
641 #endif |
541 } |
642 } |
542 iReadOffset += iReadSize; |
643 iReadOffset += iReadSize; |
543 if (iReadOffset >= iBufSz) |
644 if (iReadOffset >= iBufSz) |
544 { |
645 { |
545 iReadOffset = 0; |
646 iReadOffset = 0; |
546 } |
647 } |
547 else |
648 else |
548 { |
649 { |
549 #ifdef USB_SC |
650 #ifdef USB_SC |
550 iReadSize = ReadData(); |
651 iReadSize = ReadData(); |
733 TPtr8 writeBuf((TUint8 *)inBuffer,iBufSz,iBufSz); |
835 TPtr8 writeBuf((TUint8 *)inBuffer,iBufSz,iBufSz); |
734 ReadBufferFromDisk(writeBuf, iBufSz); |
836 ReadBufferFromDisk(writeBuf, iBufSz); |
735 } |
837 } |
736 if (iBufSz > 3) |
838 if (iBufSz > 3) |
737 *reinterpret_cast<TUint32*>(inBuffer) = iPktNum; |
839 *reinterpret_cast<TUint32*>(inBuffer) = iPktNum; |
738 |
840 |
739 if (iXferMode == ELoopComp) |
841 if (iXferMode == ELoopComp) |
740 { |
842 { |
741 for (TUint i = 4; i < iBufSz; i++) |
843 for (TUint i = 4; i < iBufSz; i++) |
742 { |
844 { |
743 *(inBuffer+i) = static_cast<TUint8>((iPktNum+i) & 0x000000ff); |
845 *(inBuffer+i) = static_cast<TUint8>((iPktNum+i) & 0x000000ff); |
744 } |
846 } |
745 } |
847 } |
746 TUSB_VERBOSE_PRINT3("SendData interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.inPipe); |
848 TUSB_VERBOSE_PRINT3("SendData interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.inPipe); |
|
849 if(gVerbose) |
|
850 { |
|
851 OstTraceExt3(TRACE_VERBOSE, CACTIVERW_SENDDATA, "SendData interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.inPipe); |
|
852 } |
747 iCurrentXfer = EWriteXfer; |
853 iCurrentXfer = EWriteXfer; |
748 TInt r = iSCWriteBuf.WriteBuffer(inBuffer, iBufSz, FALSE, iStatus); |
854 TInt r = iSCWriteBuf.WriteBuffer(inBuffer, iBufSz, FALSE, iStatus); |
749 test_KErrNone(r); |
855 test_KErrNone(r); |
750 #else |
856 #else |
751 if (iDiskAccessEnabled) |
857 if (iDiskAccessEnabled) |
779 TInt r = KErrNone; |
889 TInt r = KErrNone; |
780 |
890 |
781 iFileName.Format(_L("%c:"), aDriveLetter.operator TUint()); |
891 iFileName.Format(_L("%c:"), aDriveLetter.operator TUint()); |
782 iFileName.Append(KFileName); |
892 iFileName.Append(KFileName); |
783 TUSB_PRINT1("\nFilename = %S", &iFileName); |
893 TUSB_PRINT1("\nFilename = %S", &iFileName); |
|
894 OstTraceExt1(TRACE_NORMAL, CACTIVERW_WRITETODISK, "\nFilename = %S", iFileName); |
784 |
895 |
785 // open the record file |
896 // open the record file |
786 r = iFile.Replace(iFs, iFileName, EFileWrite); |
897 r = iFile.Replace(iFs, iFileName, EFileWrite); |
787 iFileOffset = 0; |
898 iFileOffset = 0; |
788 if (r != KErrNone) |
899 if (r != KErrNone) |
789 { |
900 { |
790 TUSB_PRINT1("RFile::Replace() returned %d", r); |
901 TUSB_PRINT1("RFile::Replace() returned %d", r); |
|
902 OstTrace1(TRACE_ERROR, CACTIVERW_WRITETODISK_DUP01, "RFile::Replace() returned %d", r); |
791 iDiskAccessEnabled = EFalse; |
903 iDiskAccessEnabled = EFalse; |
792 return r; |
904 return r; |
793 } |
905 } |
794 |
906 |
795 return r; |
907 return r; |
796 } |
908 } |
797 |
909 |
798 |
910 |
799 TInt CActiveRW::ReadFromDisk(TChar aDriveLetter, TInt aMaxFileSize) |
911 TInt CActiveRW::ReadFromDisk(TChar aDriveLetter, TInt aMaxFileSize) |
802 TInt r = KErrNone; |
914 TInt r = KErrNone; |
803 |
915 |
804 iFileName.Format(_L("%c:"), aDriveLetter.operator TUint()); |
916 iFileName.Format(_L("%c:"), aDriveLetter.operator TUint()); |
805 iFileName.Append(KFileName); |
917 iFileName.Append(KFileName); |
806 TUSB_PRINT1("\nFilename = %S", &iFileName); |
918 TUSB_PRINT1("\nFilename = %S", &iFileName); |
|
919 OstTraceExt1(TRACE_NORMAL, CACTIVERW_READFROMDISK, "\nFilename = %S", iFileName); |
807 TUSB_PRINT1("File size: %d", aMaxFileSize); |
920 TUSB_PRINT1("File size: %d", aMaxFileSize); |
|
921 OstTrace1(TRACE_NORMAL, CACTIVERW_READFROMDISK_DUP01, "File size: %d", aMaxFileSize); |
808 |
922 |
809 // First create the file & fill it |
923 // First create the file & fill it |
810 r = iFile.Replace(iFs, iFileName, EFileWrite); |
924 r = iFile.Replace(iFs, iFileName, EFileWrite); |
811 if (r != KErrNone) |
925 if (r != KErrNone) |
812 { |
926 { |
813 TUSB_PRINT1("RFile::Replace() returned %d", r); |
927 TUSB_PRINT1("RFile::Replace() returned %d", r); |
|
928 OstTrace1(TRACE_ERROR, CACTIVERW_READFROMDISK_DUP02, "RFile::Replace() returned %d", r); |
814 iDiskAccessEnabled = EFalse; |
929 iDiskAccessEnabled = EFalse; |
815 return r; |
930 return r; |
816 } |
931 } |
817 const TInt KBufferSize = 4 * 1024; |
932 const TInt KBufferSize = 4 * 1024; |
818 TBuf8<KBufferSize> buffer; |
933 TBuf8<KBufferSize> buffer; |
820 for (TInt n = 0; n < KBufferSize; n++) |
935 for (TInt n = 0; n < KBufferSize; n++) |
821 { |
936 { |
822 buffer[n] = static_cast<TUint8>(n & 0x000000ff); |
937 buffer[n] = static_cast<TUint8>(n & 0x000000ff); |
823 } |
938 } |
824 TUSB_PRINT("Writing data to file (this may take some minutes...)"); |
939 TUSB_PRINT("Writing data to file (this may take some minutes...)"); |
|
940 OstTrace0(TRACE_NORMAL, CACTIVERW_READFROMDISK_DUP03, "Writing data to file (this may take some minutes...)"); |
825 for (TInt n = 0; n < aMaxFileSize; n += KBufferSize) |
941 for (TInt n = 0; n < aMaxFileSize; n += KBufferSize) |
826 { |
942 { |
827 r = iFile.Write(buffer, KBufferSize); |
943 r = iFile.Write(buffer, KBufferSize); |
828 if (r != KErrNone) |
944 if (r != KErrNone) |
829 { |
945 { |
830 TUSB_PRINT1("RFile::Write() returned %d (disk full?)", r); |
946 TUSB_PRINT1("RFile::Write() returned %d (disk full?)", r); |
|
947 OstTrace1(TRACE_ERROR, CACTIVERW_READFROMDISK_DUP04, "RFile::Write() returned %d (disk full?)", r); |
831 iFile.Close(); |
948 iFile.Close(); |
832 iDiskAccessEnabled = EFalse; |
949 iDiskAccessEnabled = EFalse; |
833 return r; |
950 return r; |
834 } |
951 } |
835 } |
952 } |
836 TUSB_PRINT("Done."); |
953 TUSB_PRINT("Done."); |
|
954 OstTrace0(TRACE_NORMAL, CACTIVERW_READFROMDISK_DUP05, "Done."); |
837 iFile.Close(); |
955 iFile.Close(); |
838 // Now open the file for reading |
956 // Now open the file for reading |
839 r = iFile.Open(iFs, iFileName, EFileRead); |
957 r = iFile.Open(iFs, iFileName, EFileRead); |
840 if (r != KErrNone) |
958 if (r != KErrNone) |
841 { |
959 { |
842 TUSB_PRINT1("RFile::Open() returned %d", r); |
960 TUSB_PRINT1("RFile::Open() returned %d", r); |
|
961 OstTrace1(TRACE_ERROR, CACTIVERW_READFROMDISK_DUP06, "RFile::Open() returned %d", r); |
843 iDiskAccessEnabled = EFalse; |
962 iDiskAccessEnabled = EFalse; |
844 return r; |
963 return r; |
845 } |
964 } |
846 iFileOffset = 0; |
965 iFileOffset = 0; |
847 |
966 |
850 |
969 |
851 |
970 |
852 void CActiveRW::WriteBufferToDisk(TDes8& aBuffer, TInt aLen) |
971 void CActiveRW::WriteBufferToDisk(TDes8& aBuffer, TInt aLen) |
853 { |
972 { |
854 TUSB_VERBOSE_PRINT1("CActiveRW::WriteBufferToDisk(), len = %d", aLen); |
973 TUSB_VERBOSE_PRINT1("CActiveRW::WriteBufferToDisk(), len = %d", aLen); |
|
974 if(gVerbose) |
|
975 { |
|
976 OstTrace1(TRACE_VERBOSE, CACTIVERW_WRITEBUFFERTODISK, "CActiveRW::WriteBufferToDisk(), len = %d", aLen); |
|
977 } |
855 TInt r = iFile.Write(aBuffer, aLen); |
978 TInt r = iFile.Write(aBuffer, aLen); |
856 if (r != KErrNone) |
979 if (r != KErrNone) |
857 { |
980 { |
858 TUSB_PRINT2("Error writing to %S (%d)", &iFileName, r); |
981 TUSB_PRINT2("Error writing to %S (%d)", &iFileName, r); |
|
982 OstTraceExt2(TRACE_ERROR, CACTIVERW_WRITEBUFFERTODISK_DUP01, "Error writing to %S (%d)", iFileName, r); |
859 iDiskAccessEnabled = EFalse; |
983 iDiskAccessEnabled = EFalse; |
860 return; |
984 return; |
861 } |
985 } |
862 iFileOffset += aLen; |
986 iFileOffset += aLen; |
863 } |
987 } |
867 { |
991 { |
868 const TInt r = iFile.Read(aBuffer, aLen); |
992 const TInt r = iFile.Read(aBuffer, aLen); |
869 if (r != KErrNone) |
993 if (r != KErrNone) |
870 { |
994 { |
871 TUSB_PRINT2("Error reading from %S (%d)", &iFileName, r); |
995 TUSB_PRINT2("Error reading from %S (%d)", &iFileName, r); |
|
996 OstTraceExt2(TRACE_ERROR, CACTIVERW_READBUFFERFROMDISK, "Error reading from %S (%d)", iFileName, r); |
872 iDiskAccessEnabled = EFalse; |
997 iDiskAccessEnabled = EFalse; |
873 return; |
998 return; |
874 } |
999 } |
875 TInt readLen = aBuffer.Length(); |
1000 TInt readLen = aBuffer.Length(); |
876 TUSB_VERBOSE_PRINT1("CActiveRW::ReadBufferFromDisk(), len = %d\n", readLen); |
1001 TUSB_VERBOSE_PRINT1("CActiveRW::ReadBufferFromDisk(), len = %d\n", readLen); |
|
1002 if(gVerbose) |
|
1003 { |
|
1004 OstTrace1(TRACE_VERBOSE, CACTIVERW_READBUFFERFROMDISK_DUP01, "CActiveRW::ReadBufferFromDisk(), len = %d\n", readLen); |
|
1005 } |
877 if (readLen < aLen) |
1006 if (readLen < aLen) |
878 { |
1007 { |
879 TUSB_PRINT3("Only %d bytes of %d read from file %S)", |
1008 TUSB_PRINT3("Only %d bytes of %d read from file %S)", |
880 readLen, aLen, &iFileName); |
1009 readLen, aLen, &iFileName); |
|
1010 OstTraceExt3(TRACE_NORMAL, CACTIVERW_READBUFFERFROMDISK_DUP02, "Only %d bytes of %d read from file %S)", |
|
1011 readLen, aLen, iFileName); |
881 iDiskAccessEnabled = EFalse; |
1012 iDiskAccessEnabled = EFalse; |
882 return; |
1013 return; |
883 } |
1014 } |
884 iFileOffset += aLen; |
1015 iFileOffset += aLen; |
885 } |
1016 } |
888 TUint CActiveRW::ReadData() |
1019 TUint CActiveRW::ReadData() |
889 { |
1020 { |
890 __ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 664)); |
1021 __ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 664)); |
891 iCurrentXfer = EReadXfer; |
1022 iCurrentXfer = EReadXfer; |
892 #ifdef USB_SC |
1023 #ifdef USB_SC |
893 TUint readSize = 0; // note that this returns zero when asynchronous read is pending |
1024 TUint readSize = 0; // note that this returns zero when asynchronous read is pending |
894 TInt r = 0; |
1025 TInt r = 0; |
895 do |
1026 do |
896 { |
1027 { |
897 r = iSCReadBuf.GetBuffer (iSCReadData,readSize,iReadZlp,iStatus); |
1028 r = iSCReadBuf.GetBuffer (iSCReadData,readSize,iReadZlp,iStatus); |
898 test_Value(r, (r == KErrNone) || (r == KErrCompletion) || (r == KErrEof)); |
1029 test_Value(r, (r == KErrNone) || (r == KErrCompletion) || (r == KErrEof)); |
899 TUSB_VERBOSE_PRINT4("Get Buffer Return code %d Status %d DataPtr 0x%x Size %d", r, iStatus.Int(),iSCReadData,readSize); |
1030 TUSB_VERBOSE_PRINT4("Get Buffer Return code %d Status %d DataPtr 0x%x Size %d", r, iStatus.Int(),iSCReadData,readSize); |
|
1031 if(gVerbose) |
|
1032 { |
|
1033 OstTraceExt4(TRACE_VERBOSE, CACTIVERW_READDATA, "Get Buffer Return code %d Status %d DataPtr 0x%x Size %d", r, iStatus.Int(),(TInt)iSCReadData,readSize); |
|
1034 } |
900 } |
1035 } |
901 while ((r == KErrCompletion && readSize == 0) || (r == KErrEof)); |
1036 while ((r == KErrCompletion && readSize == 0) || (r == KErrEof)); |
902 if (r == KErrCompletion) |
1037 if (r == KErrCompletion) |
903 { |
1038 { |
904 return readSize; |
1039 return readSize; |
915 iReadBuf.SetLength (0); |
1050 iReadBuf.SetLength (0); |
916 if (iBufSz <= iMaxPktSz) |
1051 if (iBufSz <= iMaxPktSz) |
917 { |
1052 { |
918 // Testing the packet version of Read() |
1053 // Testing the packet version of Read() |
919 TUSB_VERBOSE_PRINT3("ReadData (single packet) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe); |
1054 TUSB_VERBOSE_PRINT3("ReadData (single packet) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe); |
|
1055 if(gVerbose) |
|
1056 { |
|
1057 OstTraceExt3(TRACE_VERBOSE, CACTIVERW_READDATA_DUP01, "ReadData (single packet) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe); |
|
1058 } |
920 iPort->ReadPacket(iStatus, (TENDPOINTNUMBER)iTestParams.outPipe, iReadBuf, iBufSz); |
1059 iPort->ReadPacket(iStatus, (TENDPOINTNUMBER)iTestParams.outPipe, iReadBuf, iBufSz); |
921 } |
1060 } |
922 else if ((TUint)iBufSz == iTestParams.maxSize) |
1061 else if ((TUint)iBufSz == iTestParams.maxSize) |
923 { |
1062 { |
924 // Testing the two-parameter version |
1063 // Testing the two-parameter version |
925 TUSB_VERBOSE_PRINT3("ReadData (w/o length) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe); |
1064 TUSB_VERBOSE_PRINT3("ReadData (w/o length) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe); |
|
1065 if(gVerbose) |
|
1066 { |
|
1067 OstTraceExt3(TRACE_VERBOSE, CACTIVERW_READDATA_DUP02, "ReadData (w/o length) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe); |
|
1068 } |
926 iPort->Read(iStatus, (TENDPOINTNUMBER)iTestParams.outPipe, iReadBuf); |
1069 iPort->Read(iStatus, (TENDPOINTNUMBER)iTestParams.outPipe, iReadBuf); |
927 } |
1070 } |
928 else |
1071 else |
929 { |
1072 { |
930 // otherwise, we use the universal default version |
1073 // otherwise, we use the universal default version |
931 // Testing the three-parameter version |
1074 // Testing the three-parameter version |
932 TUSB_VERBOSE_PRINT3("ReadData (normal) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe); |
1075 TUSB_VERBOSE_PRINT3("ReadData (normal) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe); |
|
1076 if(gVerbose) |
|
1077 { |
|
1078 OstTraceExt3(TRACE_VERBOSE, CACTIVERW_READDATA_DUP03, "ReadData (normal) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe); |
|
1079 } |
933 iPort->Read(iStatus, (TENDPOINTNUMBER)iTestParams.outPipe, iReadBuf, iBufSz); |
1080 iPort->Read(iStatus, (TENDPOINTNUMBER)iTestParams.outPipe, iReadBuf, iBufSz); |
934 } |
1081 } |
935 if (!IsActive()) |
1082 if (!IsActive()) |
936 { |
1083 { |
937 SetActive(); |
1084 SetActive(); |
958 |
1107 |
959 |
1108 |
960 void CActiveRW::DoCancel() |
1109 void CActiveRW::DoCancel() |
961 { |
1110 { |
962 TUSB_VERBOSE_PRINT("CActiveRW::DoCancel()"); |
1111 TUSB_VERBOSE_PRINT("CActiveRW::DoCancel()"); |
|
1112 if(gVerbose) |
|
1113 { |
|
1114 OstTrace0(TRACE_VERBOSE, CACTIVERW_DOCANCEL, "CActiveRW::DoCancel()"); |
|
1115 } |
963 // Canceling the transfer requests can be done explicitly |
1116 // Canceling the transfer requests can be done explicitly |
964 // for every transfer... |
1117 // for every transfer... |
965 iPort->WriteCancel((TENDPOINTNUMBER)iTestParams.inPipe); |
1118 iPort->WriteCancel((TENDPOINTNUMBER)iTestParams.inPipe); |
966 iPort->ReadCancel((TENDPOINTNUMBER)iTestParams.outPipe); |
1119 iPort->ReadCancel((TENDPOINTNUMBER)iTestParams.outPipe); |
967 // or like this: |
1120 // or like this: |
968 // iPort->EndpointTransferCancel(~0); |
1121 // iPort->EndpointTransferCancel(~0); |
969 } |
1122 } |
970 |
1123 |
971 |
1124 |
972 TBool CActiveRW::CompareBuffers() |
1125 TBool CActiveRW::CompareBuffers() |
973 { |
1126 { |
974 TUSB_VERBOSE_PRINT2("CActiveRW::CompareBuffers() ReadOffset %d ReadSize %d",iReadOffset,iReadSize); |
1127 TUSB_VERBOSE_PRINT2("CActiveRW::CompareBuffers() ReadOffset %d ReadSize %d",iReadOffset,iReadSize); |
|
1128 if(gVerbose) |
|
1129 { |
|
1130 OstTraceExt2(TRACE_VERBOSE, CACTIVERW_COMPAREBUFFERS, "CActiveRW::CompareBuffers() ReadOffset %d ReadSize %d",iReadOffset,iReadSize); |
|
1131 } |
975 #ifdef USB_SC |
1132 #ifdef USB_SC |
976 TUint8 *readPtr = reinterpret_cast<TUint8*>(iSCReadData); |
1133 TUint8 *readPtr = reinterpret_cast<TUint8*>(iSCReadData); |
977 TUint8* writePtr; |
1134 TUint8* writePtr; |
978 TUint inBufLength; |
1135 TUint inBufLength; |
979 test_KErrNone(iSCWriteBuf.GetInBufferRange((TAny*&)writePtr, inBufLength)); |
1136 test_KErrNone(iSCWriteBuf.GetInBufferRange((TAny*&)writePtr, inBufLength)); |
982 for (TUint i = 0; i < iReadSize; i++) |
1139 for (TUint i = 0; i < iReadSize; i++) |
983 { |
1140 { |
984 #ifdef USB_SC |
1141 #ifdef USB_SC |
985 if (*readPtr != *writePtr) |
1142 if (*readPtr != *writePtr) |
986 { |
1143 { |
987 TUSB_PRINT3 ("*** Error while comparing tx & rx buffers packet 0x%x length %d index %d",iPktNum, iReadSize,i + iReadOffset); |
1144 TUSB_PRINT3 ("*** Error while comparing tx & rx buffers packet 0x%x length %d index %d",iPktNum, iReadSize,i + iReadOffset); |
988 TUSB_PRINT2 ("*** Read byte 0x%x Write byte 0x%x",*readPtr,*writePtr); |
1145 OstTraceExt3 (TRACE_NORMAL, CACTIVERW_COMPAREBUFFERS_DUP01, "*** Error while comparing tx & rx buffers packet 0x%x length %u index %u",iPktNum, (TUint32)iReadSize,(TUint32)(i + iReadOffset)); |
|
1146 TUSB_PRINT2 ("*** Read byte 0x%x Write byte 0x%x",*readPtr,*writePtr); |
|
1147 OstTraceExt2 (TRACE_NORMAL, CACTIVERW_COMPAREBUFFERS_DUP02, "*** Read byte 0x%x Write byte 0x%x",*readPtr,*writePtr); |
989 return EFalse; |
1148 return EFalse; |
990 } |
1149 } |
991 readPtr++; |
1150 readPtr++; |
992 writePtr++; |
1151 writePtr++; |
993 #else |
1152 #else |
994 if (iReadBuf[i] != iWriteBuf[i + iReadOffset]) |
1153 if (iReadBuf[i] != iWriteBuf[i + iReadOffset]) |
995 { |
1154 { |
996 TUSB_PRINT3 ("*** Error while comparing tx & rx buffers packet 0x%x length %d index %d",iPktNum, iReadSize,i + iReadOffset); |
1155 TUSB_PRINT3 ("*** Error while comparing tx & rx buffers packet 0x%x length %d index %d",iPktNum, iReadSize,i + iReadOffset); |
|
1156 OstTraceExt3 (TRACE_NORMAL, CACTIVERW_COMPAREBUFFERS_DUP03, "*** Error while comparing tx & rx buffers packet 0x%x length %u index %u",(TUint32)iPktNum, (TUint32)iReadSize,(TUint32)(i + iReadOffset)); |
997 TUSB_PRINT5 ("WriteBuf Start 0x%x 0x%x 0x%x 0x%x 0x%x", |
1157 TUSB_PRINT5 ("WriteBuf Start 0x%x 0x%x 0x%x 0x%x 0x%x", |
998 iWriteBuf[i], iWriteBuf[i+1], iWriteBuf[i+2], iWriteBuf[i+3], iWriteBuf[i+4]); |
1158 iWriteBuf[i], iWriteBuf[i+1], iWriteBuf[i+2], iWriteBuf[i+3], iWriteBuf[i+4]); |
|
1159 OstTraceExt5 (TRACE_NORMAL, CACTIVERW_COMPAREBUFFERS_DUP04, "WriteBuf Start 0x%x 0x%x 0x%x 0x%x 0x%x", |
|
1160 iWriteBuf[i], iWriteBuf[i+1], iWriteBuf[i+2], iWriteBuf[i+3], iWriteBuf[i+4]); |
999 TUSB_PRINT5 ("ReadBuf Start 0x%x 0x%x 0x%x 0x%x 0x%x", |
1161 TUSB_PRINT5 ("ReadBuf Start 0x%x 0x%x 0x%x 0x%x 0x%x", |
1000 iReadBuf[i], iReadBuf[i+1], iReadBuf[i+2], iReadBuf[i+3], iReadBuf[i+4]); |
1162 iReadBuf[i], iReadBuf[i+1], iReadBuf[i+2], iReadBuf[i+3], iReadBuf[i+4]); |
|
1163 OstTraceExt5 (TRACE_NORMAL, CACTIVERW_COMPAREBUFFERS_DUP05, "ReadBuf Start 0x%x 0x%x 0x%x 0x%x 0x%x", |
|
1164 iReadBuf[i], iReadBuf[i+1], iReadBuf[i+2], iReadBuf[i+3], iReadBuf[i+4]); |
1001 if (iReadSize >= 10) |
1165 if (iReadSize >= 10) |
1002 { |
1166 { |
1003 TUSB_PRINT5 ("WriteBuf End 0x%x 0x%x 0x%x 0x%x 0x%x", |
1167 TUSB_PRINT5 ("WriteBuf End 0x%x 0x%x 0x%x 0x%x 0x%x", |
1004 iWriteBuf[iReadSize-5], iWriteBuf[iReadSize-4], iWriteBuf[iReadSize-3], iWriteBuf[iReadSize-2], iWriteBuf[iReadSize-1]); |
1168 iWriteBuf[iReadSize-5], iWriteBuf[iReadSize-4], iWriteBuf[iReadSize-3], iWriteBuf[iReadSize-2], iWriteBuf[iReadSize-1]); |
|
1169 OstTraceExt5 (TRACE_NORMAL, CACTIVERW_COMPAREBUFFERS_DUP06, "WriteBuf End 0x%x 0x%x 0x%x 0x%x 0x%x", |
|
1170 iWriteBuf[iReadSize-5], iWriteBuf[iReadSize-4], iWriteBuf[iReadSize-3], iWriteBuf[iReadSize-2], iWriteBuf[iReadSize-1]); |
1005 TUSB_PRINT5 ("ReadBuf End 0x%x 0x%x 0x%x 0x%x 0x%x", |
1171 TUSB_PRINT5 ("ReadBuf End 0x%x 0x%x 0x%x 0x%x 0x%x", |
1006 iReadBuf[iReadSize-5], iReadBuf[iReadSize-4], iReadBuf[iReadSize-3], iReadBuf[iReadSize-2], iReadBuf[iReadSize-1]); |
1172 iReadBuf[iReadSize-5], iReadBuf[iReadSize-4], iReadBuf[iReadSize-3], iReadBuf[iReadSize-2], iReadBuf[iReadSize-1]); |
|
1173 OstTraceExt5 (TRACE_NORMAL, CACTIVERW_COMPAREBUFFERS_DUP07, "ReadBuf End 0x%x 0x%x 0x%x 0x%x 0x%x", |
|
1174 iReadBuf[iReadSize-5], iReadBuf[iReadSize-4], iReadBuf[iReadSize-3], iReadBuf[iReadSize-2], iReadBuf[iReadSize-1]); |
1007 } |
1175 } |
1008 return EFalse; |
1176 return EFalse; |
1009 } |
1177 } |
1010 #endif |
1178 #endif |
1011 } |
1179 } |