181 * @param aIniFile The ini file to read from. |
172 * @param aIniFile The ini file to read from. |
182 * @param aSection The section to reads from. |
173 * @param aSection The section to reads from. |
183 * @param aBehaviour The behaviour struct to read to. |
174 * @param aBehaviour The behaviour struct to read to. |
184 */ |
175 */ |
185 { |
176 { |
186 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_ENTRY ); |
177 LOG_FUNC |
187 #ifdef _DEBUG |
178 #ifdef __FLOG_ACTIVE |
188 OstTraceExt1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR, |
179 TBuf8<KMaxName> buf; |
189 "CUsbDummyClassController::GetBehaviour;aSection=%S", aSection ); |
180 buf.Copy(aSection); |
190 #endif//_DEBUG |
181 LOGTEXT2(_L8("\taSection = %S"), &buf); |
|
182 #endif // __FLOG_ACTIVE |
191 |
183 |
192 TPtrC temp; |
184 TPtrC temp; |
193 if ( !aIniFile.FindVar(aSection, KType(), temp) ) |
185 if ( !aIniFile.FindVar(aSection, KType(), temp) ) |
194 { |
186 { |
195 OstTraceExt1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP1, |
187 LOGTEXT2(_L8("\tPANICKING: can't find Type item in section %S"), &aSection); |
196 "CUsbDummyClassController::GetBehaviour;PANICKING: can't find Type item in section %S", aSection ); |
188 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadIniFile); |
197 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP2, "CUsbDummyClassController::GetBehaviour; panic code=%d", EDummyPanicBadIniFile ); |
|
198 User::Panic(KDummyControllerPanic, EDummyPanicBadIniFile ); |
|
199 } |
189 } |
200 if ( temp == KSync ) |
190 if ( temp == KSync ) |
201 { |
191 { |
202 aBehaviour.iSynchronicity = ESynchronous; |
192 aBehaviour.iSynchronicity = ESynchronous; |
203 } |
193 } |
209 { |
199 { |
210 aBehaviour.iSynchronicity = ENever; |
200 aBehaviour.iSynchronicity = ENever; |
211 } |
201 } |
212 else |
202 else |
213 { |
203 { |
214 OstTraceExt2( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP3, |
204 LOGTEXT3(_L8("\tPANICKING: bad Type value (%S) in section %S"), &temp, &aSection); |
215 "CUsbDummyClassController::GetBehaviour;PANICKING: bad Type value (%S) in section %S", temp, aSection ); |
205 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadIniFile); |
216 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP4, "CUsbDummyClassController::GetBehaviour; panic code=%d", EDummyPanicBadIniFile ); |
|
217 User::Panic(KDummyControllerPanic, EDummyPanicBadIniFile); |
|
218 } |
206 } |
219 TInt delay; |
207 TInt delay; |
220 if ( !aIniFile.FindVar(aSection, KTime(), delay) ) |
208 if ( !aIniFile.FindVar(aSection, KTime(), delay) ) |
221 { |
209 { |
222 OstTraceExt1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP5, |
210 LOGTEXT2(_L8("\tPANICKING: can't find Time item in section %S"), &aSection); |
223 "CUsbDummyClassController::GetBehaviour;PANICKING: can't find Time item in section %S", aSection ); |
211 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadIniFile); |
224 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP6, "CUsbDummyClassController::GetBehaviour;panic code=%d", EDummyPanicBadIniFile ); |
|
225 User::Panic(KDummyControllerPanic, EDummyPanicBadIniFile); |
|
226 } |
212 } |
227 aBehaviour.iDelay = delay; |
213 aBehaviour.iDelay = delay; |
228 if ( !aIniFile.FindVar(aSection, KError(), aBehaviour.iErrorCode) ) |
214 if ( !aIniFile.FindVar(aSection, KError(), aBehaviour.iErrorCode) ) |
229 { |
215 { |
230 OstTraceExt1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP7, |
216 LOGTEXT2(_L8("\tPANICKING: can't find Error item in section %S"), &aSection); |
231 "CUsbDummyClassController::GetBehaviour;aSection=%S", aSection ); |
217 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadIniFile); |
232 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_DUP8, "CUsbDummyClassController::GetBehaviour;panic code=%d", EDummyPanicBadIniFile ); |
218 } |
233 User::Panic(KDummyControllerPanic, EDummyPanicBadIniFile ); |
|
234 } |
|
235 OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_GETBEHAVIOUR_EXIT ); |
|
236 } |
219 } |
237 |
220 |
238 void CUsbDummyClassController::DoGetConfigL() |
221 void CUsbDummyClassController::DoGetConfigL() |
239 /** |
222 /** |
240 * Reads the config from the ini file. |
223 * Reads the config from the ini file. |
241 */ |
224 */ |
242 { |
225 { |
243 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_DOGETCONFIGL_ENTRY ); |
226 LOG_FUNC |
244 |
227 |
245 CIniFile* iniFile = CIniFile::NewL(_L("dummy.ini")); |
228 CIniFile* iniFile = CIniFile::NewL(_L("dummy.ini")); |
246 CleanupStack::PushL(iniFile); |
229 CleanupStack::PushL(iniFile); |
247 TName section; |
230 TName section; |
248 |
231 |
252 // Read shutdown behaviour |
235 // Read shutdown behaviour |
253 section.Format(_L("%S.%d"), &KShutdown(), iIndex); |
236 section.Format(_L("%S.%d"), &KShutdown(), iIndex); |
254 GetBehaviour(*iniFile, section, iShutdownBehaviour); |
237 GetBehaviour(*iniFile, section, iShutdownBehaviour); |
255 |
238 |
256 CleanupStack::PopAndDestroy(iniFile); |
239 CleanupStack::PopAndDestroy(iniFile); |
257 OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_DOGETCONFIGL_EXIT ); |
|
258 } |
240 } |
259 |
241 |
260 void CUsbDummyClassController::GetConfig() |
242 void CUsbDummyClassController::GetConfig() |
261 /** |
243 /** |
262 * Reads the config from the ini file. |
244 * Reads the config from the ini file. |
263 * Note that this is assumed to succeed. Any failure will break the test and |
245 * Note that this is assumed to succeed. Any failure will break the test and |
264 * it's much cleaner to panic out of the test entirely rather than leave it to |
246 * it's much cleaner to panic out of the test entirely rather than leave it to |
265 * the user to figure out what's gone wrong. |
247 * the user to figure out what's gone wrong. |
266 */ |
248 */ |
267 { |
249 { |
268 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_GETCONFIG_ENTRY ); |
250 LOG_FUNC |
269 |
251 |
270 // Always use dummy.ini. The entity setting up the test is responsible for |
252 // Always use dummy.ini. The entity setting up the test is responsible for |
271 // copying the correct file to c:\\dummy.ini. The first found |
253 // copying the correct file to c:\\dummy.ini. The first found |
272 // by FindByDir will be used. TODO: enforce c:\\. |
254 // by FindByDir will be used. TODO: enforce c:\\. |
273 TRAPD(err, DoGetConfigL()); |
255 TRAPD(err, DoGetConfigL()); |
274 if ( err != KErrNone ) |
256 if ( err != KErrNone ) |
275 { |
257 { |
276 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP7, "CUsbDummyClassController::GetConfig;panic code=%d", EDummyPanicUnhandledError ); |
258 _USB_PANIC(KDummyControllerPanic, EDummyPanicUnhandledError); |
277 User::Panic(KDummyControllerPanic, EDummyPanicUnhandledError); |
259 } |
278 } |
260 |
279 |
261 LOGTEXT2(_L8("\tLogging dummy class controller behaviour for instance %d"), iIndex); |
280 OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG, |
262 LOGTEXT2(_L8("\tiStartupBehaviour.iSynchronicity = %d"), iStartupBehaviour.iSynchronicity); |
281 "CUsbDummyClassController::GetConfig; Logging dummy class controller behaviour for instance %d", iIndex ); |
263 LOGTEXT2(_L8("\tiStartupBehaviour.iDelay = %d"), iStartupBehaviour.iDelay.Int()); |
282 OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP1, |
264 LOGTEXT2(_L8("\tiStartupBehaviour.iErrorCode = %d"), iStartupBehaviour.iErrorCode); |
283 "CUsbDummyClassController::GetConfig;iStartupBehaviour.iSynchronicity=%d", iStartupBehaviour.iSynchronicity ); |
265 LOGTEXT2(_L8("\tiShutdownBehaviour.iSynchronicity = %d"), iShutdownBehaviour.iSynchronicity); |
284 OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP2, |
266 LOGTEXT2(_L8("\tiShutdownBehaviour.iDelay = %d"), iShutdownBehaviour.iDelay.Int()); |
285 "CUsbDummyClassController::GetConfig;iStartupBehaviour.iDelay.Int()=%d", iStartupBehaviour.iDelay.Int() ); |
267 LOGTEXT2(_L8("\tiShutdownBehaviour.iErrorCode = %d"), iShutdownBehaviour.iErrorCode); |
286 OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP3, |
|
287 "CUsbDummyClassController::GetConfig;iStartupBehaviour.iErrorCode=%d", iStartupBehaviour.iErrorCode ); |
|
288 OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP4, |
|
289 "CUsbDummyClassController::GetConfig;iShutdownBehaviour.iSynchronicity=%d", iShutdownBehaviour.iSynchronicity ); |
|
290 OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP5, |
|
291 "CUsbDummyClassController::GetConfig;iShutdownBehaviour.iDelay.Int()=%d", iShutdownBehaviour.iDelay.Int() ); |
|
292 OstTrace1( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_GETCONFIG_DUP6, |
|
293 "CUsbDummyClassController::GetConfig;iShutdownBehaviour.iErrorCode=%d", iShutdownBehaviour.iErrorCode ); |
|
294 OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_GETCONFIG_EXIT ); |
|
295 } |
268 } |
296 |
269 |
297 void CUsbDummyClassController::Start(TRequestStatus& aStatus) |
270 void CUsbDummyClassController::Start(TRequestStatus& aStatus) |
298 /** |
271 /** |
299 * Called by UsbMan to start this class. |
272 * Called by UsbMan to start this class. |
300 * |
273 * |
301 * @param aStatus Will be completed with success or failure. |
274 * @param aStatus Will be completed with success or failure. |
302 */ |
275 */ |
303 { |
276 { |
304 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_START_ENTRY ); |
277 LOG_FUNC |
305 |
278 |
306 //Start() should only be called if the CC is idle or started |
279 //Start() should only be called if the CC is idle or started |
307 |
280 __ASSERT_DEBUG((iState == EUsbServiceIdle || iState == EUsbServiceStarted), |
308 if(!(iState == EUsbServiceIdle || iState == EUsbServiceStarted)) |
281 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadApiCallStart) ); |
309 { |
|
310 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_START, "CUsbDummyClassController::Start;panic code=%d", EDummyPanicBadApiCallStart ); |
|
311 __ASSERT_DEBUG(EFalse, |
|
312 User::Panic(KDummyControllerPanic, EDummyPanicBadApiCallStart) ); |
|
313 } |
|
314 |
282 |
315 // Get config from ini file. Note that can't be done once in ConstructL |
283 // Get config from ini file. Note that can't be done once in ConstructL |
316 // because then, in the case of a CC which doesn't Stop, we'd never be |
284 // because then, in the case of a CC which doesn't Stop, we'd never be |
317 // able to shut down USBMAN! |
285 // able to shut down USBMAN! |
318 GetConfig(); |
286 GetConfig(); |
319 |
287 |
320 // NB We enforce that the device doesn't re-post requests on us. |
288 // NB We enforce that the device doesn't re-post requests on us. |
321 if(iReportStatus) |
289 __ASSERT_DEBUG(!iReportStatus, |
322 { |
290 _USB_PANIC(KDummyControllerPanic, EDummyPanicOutstandingRequestFromDevice)); |
323 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_START_DUP1, "CUsbDummyClassController::Start;panic code=%d", EDummyPanicOutstandingRequestFromDevice ); |
|
324 __ASSERT_DEBUG(EFalse, |
|
325 User::Panic(KDummyControllerPanic, EDummyPanicOutstandingRequestFromDevice)); |
|
326 } |
|
327 aStatus = KRequestPending; |
291 aStatus = KRequestPending; |
328 iReportStatus = &aStatus; |
292 iReportStatus = &aStatus; |
329 |
293 |
330 iState = EUsbServiceStarting; |
294 iState = EUsbServiceStarting; |
331 |
295 |
338 iReportStatus = NULL; |
302 iReportStatus = NULL; |
339 break; |
303 break; |
340 |
304 |
341 case EAsynchronous: |
305 case EAsynchronous: |
342 iTimer.After(iStatus, iStartupBehaviour.iDelay); |
306 iTimer.After(iStatus, iStartupBehaviour.iDelay); |
343 #ifdef _DEBUG |
307 __ASSERT_DEBUG(!IsActive(), _USB_PANIC(KDummyControllerPanic, EDummyPanicAlreadyActive)); |
344 if(IsActive()) |
|
345 { |
|
346 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_START_DUP2, "CUsbDummyClassController::Start;panic code=%d", EDummyPanicAlreadyActive ); |
|
347 User::Panic(KDummyControllerPanic, EDummyPanicAlreadyActive); |
|
348 } |
|
349 #endif |
|
350 SetActive(); |
308 SetActive(); |
351 break; |
309 break; |
352 |
310 |
353 case ENever: |
311 case ENever: |
354 // Don't do anything and never complete |
312 // Don't do anything and never complete |
355 break; |
313 break; |
356 |
314 |
357 default: |
315 default: |
358 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_START_DUP3, "CUsbDummyClassController::Start;panic code=%d", EDummyPanicBadSynchronicity ); |
316 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadSynchronicity); |
359 User::Panic(KDummyControllerPanic, EDummyPanicBadSynchronicity); |
317 break; |
360 break; |
318 } |
361 } |
|
362 OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_START_EXIT ); |
|
363 } |
319 } |
364 |
320 |
365 void CUsbDummyClassController::Stop(TRequestStatus& aStatus) |
321 void CUsbDummyClassController::Stop(TRequestStatus& aStatus) |
366 /** |
322 /** |
367 * Called by UsbMan to stop this class. |
323 * Called by UsbMan to stop this class. |
368 * |
324 * |
369 * @param aStatus Will be completed with success or failure. |
325 * @param aStatus Will be completed with success or failure. |
370 */ |
326 */ |
371 { |
327 { |
372 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_STOP_ENTRY ); |
328 LOG_FUNC |
373 |
329 |
374 //Stop() should only be called if the CC is Started or Idle |
330 //Stop() should only be called if the CC is Started or Idle |
375 if(!(iState == EUsbServiceStarted || iState == EUsbServiceIdle)) |
331 __ASSERT_DEBUG((iState == EUsbServiceStarted || iState == EUsbServiceIdle), |
376 { |
332 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadApiCallStop)); |
377 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_STOP, "CUsbDummyClassController::Stop;panic code=%d", EDummyPanicBadApiCallStop ); |
|
378 __ASSERT_DEBUG(EFalse, |
|
379 User::Panic(KDummyControllerPanic, EDummyPanicBadApiCallStop)); |
|
380 } |
|
381 |
333 |
382 // Get config from ini file. Note that can't be done once in ConstructL |
334 // Get config from ini file. Note that can't be done once in ConstructL |
383 // because then, in the case of a CC which doesn't Stop, we'd never be |
335 // because then, in the case of a CC which doesn't Stop, we'd never be |
384 // able to shutdown USBMAN! |
336 // able to shutdown USBMAN! |
385 GetConfig(); |
337 GetConfig(); |
386 |
338 |
387 // NB We enforce that the device doesn't re-post requests on us. |
339 // NB We enforce that the device doesn't re-post requests on us. |
388 if(iReportStatus) |
340 __ASSERT_DEBUG(!iReportStatus, |
389 { |
341 _USB_PANIC(KDummyControllerPanic, EDummyPanicOutstandingRequestFromDevice)); |
390 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_STOP_DUP1, "CUsbDummyClassController::Stop;panic code=%d", EDummyPanicOutstandingRequestFromDevice ); |
|
391 __ASSERT_DEBUG(EFalse, |
|
392 User::Panic(KDummyControllerPanic, EDummyPanicOutstandingRequestFromDevice)); |
|
393 } |
|
394 aStatus = KRequestPending; |
342 aStatus = KRequestPending; |
395 iReportStatus = &aStatus; |
343 iReportStatus = &aStatus; |
396 |
344 |
397 iState = EUsbServiceStopping; |
345 iState = EUsbServiceStopping; |
398 |
346 |
443 void CUsbDummyClassController::RunL() |
383 void CUsbDummyClassController::RunL() |
444 /** |
384 /** |
445 * Standard active object RunL. |
385 * Standard active object RunL. |
446 */ |
386 */ |
447 { |
387 { |
448 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_RUNL_ENTRY ); |
388 LOGTEXT3(_L8(">>CUsbDummyClassController::RunL [iStatus=%d,iState=%d]"), |
449 OstTraceExt2( TRACE_NORMAL, CUSBDUMMYCLASSCONTROLLER_RUNL, "CUsbDummyClassController::RunL;iStatus.Int()=%d;iState=%d", iStatus.Int(), iState ); |
389 iStatus.Int(), iState); |
450 |
|
451 |
390 |
452 if ( iStatus != KErrNone ) |
391 if ( iStatus != KErrNone ) |
453 { |
392 { |
454 // Panic runtime errors from the timer. We can't ignore them, and |
393 // Panic runtime errors from the timer. We can't ignore them, and |
455 // there's no point trying to code round them. This is part of the |
394 // there's no point trying to code round them. This is part of the |
456 // test framework and if it's failing we want to alert the user |
395 // test framework and if it's failing we want to alert the user |
457 // without faffing around. (It invalidates the test.) |
396 // without faffing around. (It invalidates the test.) |
458 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNL_DUP1, "CUsbDummyClassController::RunL;panic code=%d", EDummyPanicUnhandledError ); |
397 _USB_PANIC(KDummyControllerPanic, EDummyPanicUnhandledError); |
459 User::Panic(KDummyControllerPanic, EDummyPanicUnhandledError); |
|
460 } |
398 } |
461 |
399 |
462 if(!iReportStatus) |
400 __ASSERT_DEBUG(iReportStatus, |
463 { |
401 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadState)); |
464 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNL_DUP2, "CUsbDummyClassController::RunL;panic code=%d", EDummyPanicBadState ); |
|
465 __ASSERT_DEBUG(EFalse, |
|
466 User::Panic(KDummyControllerPanic, EDummyPanicBadState)); |
|
467 } |
|
468 |
402 |
469 switch ( iState ) |
403 switch ( iState ) |
470 { |
404 { |
471 case EUsbServiceStarting: |
405 case EUsbServiceStarting: |
472 // Completion of asynchronous startup... |
406 // Completion of asynchronous startup... |
473 if(iStartupBehaviour.iSynchronicity != EAsynchronous) |
407 __ASSERT_DEBUG(iStartupBehaviour.iSynchronicity == EAsynchronous, |
474 { |
408 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadSynchronicity)); |
475 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNL_DUP3, "CUsbDummyClassController::RunL;panic code=%d", EDummyPanicBadSynchronicity ); |
|
476 __ASSERT_DEBUG(EFalse, |
|
477 User::Panic(KDummyControllerPanic, EDummyPanicBadSynchronicity)); |
|
478 } |
|
479 iState = EUsbServiceStarted; |
409 iState = EUsbServiceStarted; |
480 User::RequestComplete(iReportStatus, iStartupBehaviour.iErrorCode); |
410 User::RequestComplete(iReportStatus, iStartupBehaviour.iErrorCode); |
481 iReportStatus = NULL; |
411 iReportStatus = NULL; |
482 break; |
412 break; |
483 |
413 |
484 case EUsbServiceStopping: |
414 case EUsbServiceStopping: |
485 // Completion of asynchronous shutdown... |
415 // Completion of asynchronous shutdown... |
486 if(iShutdownBehaviour.iSynchronicity != EAsynchronous) |
416 __ASSERT_DEBUG(iShutdownBehaviour.iSynchronicity == EAsynchronous, |
487 { |
417 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadSynchronicity)); |
488 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNL_DUP4, "CUsbDummyClassController::RunL;panic code=%d", EDummyPanicBadSynchronicity ); |
|
489 __ASSERT_DEBUG(EFalse, |
|
490 User::Panic(KDummyControllerPanic, EDummyPanicBadSynchronicity)); |
|
491 } |
|
492 iState = EUsbServiceIdle; |
418 iState = EUsbServiceIdle; |
493 User::RequestComplete(iReportStatus, iShutdownBehaviour.iErrorCode); |
419 User::RequestComplete(iReportStatus, iShutdownBehaviour.iErrorCode); |
494 iReportStatus = NULL; |
420 iReportStatus = NULL; |
495 break; |
421 break; |
496 |
422 |
497 case EUsbServiceIdle: |
423 case EUsbServiceIdle: |
498 case EUsbServiceStarted: |
424 case EUsbServiceStarted: |
499 default: |
425 default: |
500 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNL_DUP5, "CUsbDummyClassController::RunL;panic code=%d", EDummyPanicBadState ); |
426 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadState); |
501 User::Panic(KDummyControllerPanic, EDummyPanicBadState); |
427 break; |
502 break; |
428 } |
503 } |
429 |
504 |
430 LOGTEXT(_L8("<<CUsbDummyClassController::RunL")); |
505 OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_RUNL_EXIT ); |
|
506 } |
431 } |
507 |
432 |
508 void CUsbDummyClassController::DoCancel() |
433 void CUsbDummyClassController::DoCancel() |
509 /** |
434 /** |
510 * Standard active object cancellation function. |
435 * Standard active object cancellation function. |
511 */ |
436 */ |
512 { |
437 { |
513 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLER_DOCANCEL_ENTRY ); |
438 LOG_FUNC |
514 |
439 |
515 // Note that CActive::Cancel does not call DoCancel unless we are active. |
440 // Note that CActive::Cancel does not call DoCancel unless we are active. |
516 // Therefore we are at this point active. Therefore, we should have |
441 // Therefore we are at this point active. Therefore, we should have |
517 // iReportStatus pointing to something. This is true whether we are in |
442 // iReportStatus pointing to something. This is true whether we are in |
518 // our destructor or being cancelled by the device. It is also true that |
443 // our destructor or being cancelled by the device. It is also true that |
524 // 2/ The device wants to cancel us in the middle of a Start before |
449 // 2/ The device wants to cancel us in the middle of a Start before |
525 // issuing a Stop (or vice versa). Note that the device may cancel us in |
450 // issuing a Stop (or vice versa). Note that the device may cancel us in |
526 // the middle of a Start, then immediately issue another Start. |
451 // the middle of a Start, then immediately issue another Start. |
527 |
452 |
528 // Cancel our own asynchronous operation. |
453 // Cancel our own asynchronous operation. |
529 #ifdef _DEBUG |
454 __ASSERT_DEBUG(iTimer.Handle(), |
530 if(!iTimer.Handle()) |
455 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadState)); |
531 { |
|
532 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_DOCANCEL, "CUsbDummyClassController::DoCancel;panic code=%d", EDummyPanicBadState ); |
|
533 User::Panic(KDummyControllerPanic, EDummyPanicBadState); |
|
534 } |
|
535 #endif |
|
536 iTimer.Cancel(); |
456 iTimer.Cancel(); |
537 |
457 |
538 // Update our iState. If we're starting, then roll back to idle. If we're |
458 // Update our iState. If we're starting, then roll back to idle. If we're |
539 // stopping, role back to started. Nothing else is legal. |
459 // stopping, role back to started. Nothing else is legal. |
540 switch ( iState ) |
460 switch ( iState ) |
541 { |
461 { |
542 case EUsbServiceStarting: |
462 case EUsbServiceStarting: |
543 if(iStartupBehaviour.iSynchronicity != EAsynchronous) |
463 __ASSERT_DEBUG(iStartupBehaviour.iSynchronicity == EAsynchronous, |
544 { |
464 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadSynchronicity)); |
545 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_DOCANCEL_DUP1, "CUsbDummyClassController::DoCancel;panic code=%d", EDummyPanicBadSynchronicity ); |
|
546 __ASSERT_DEBUG(EFalse, |
|
547 User::Panic(KDummyControllerPanic, EDummyPanicBadSynchronicity)); |
|
548 } |
|
549 iState = EUsbServiceIdle; |
465 iState = EUsbServiceIdle; |
550 break; |
466 break; |
551 |
467 |
552 case EUsbServiceStopping: |
468 case EUsbServiceStopping: |
553 if(iShutdownBehaviour.iSynchronicity != EAsynchronous) |
469 __ASSERT_DEBUG(iShutdownBehaviour.iSynchronicity == EAsynchronous, |
554 { |
470 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadSynchronicity)); |
555 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_DOCANCEL_DUP2, "CUsbDummyClassController::DoCancel;panic code=%d", EDummyPanicBadSynchronicity ); |
|
556 __ASSERT_DEBUG(EFalse, |
|
557 User::Panic(KDummyControllerPanic, EDummyPanicBadSynchronicity)); |
|
558 } |
|
559 iState = EUsbServiceStarted; |
471 iState = EUsbServiceStarted; |
560 break; |
472 break; |
561 |
473 |
562 case EUsbServiceIdle: |
474 case EUsbServiceIdle: |
563 case EUsbServiceStarted: |
475 case EUsbServiceStarted: |
564 default: |
476 default: |
565 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_DOCANCEL_DUP3, "CUsbDummyClassController::DoCancel;panic code=%d", EDummyPanicBadState ); |
477 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadState); |
566 User::Panic(KDummyControllerPanic, EDummyPanicBadState); |
478 break; |
567 break; |
479 } |
568 } |
480 |
569 |
481 // Complete the client's request. |
570 // Complete the client's request. |
482 __ASSERT_DEBUG(iReportStatus, |
571 if(!iReportStatus) |
483 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadState)); |
572 { |
|
573 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_DOCANCEL_DUP4, "CUsbDummyClassController::DoCancel;panic code=%d", EDummyPanicBadState ); |
|
574 __ASSERT_DEBUG(EFalse, |
|
575 User::Panic(KDummyControllerPanic, EDummyPanicBadState)); |
|
576 } |
|
577 User::RequestComplete(iReportStatus, KErrCancel); |
484 User::RequestComplete(iReportStatus, KErrCancel); |
578 iReportStatus = NULL; |
485 iReportStatus = NULL; |
579 OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLER_DOCANCEL_EXIT ); |
|
580 } |
486 } |
581 |
487 |
582 TInt CUsbDummyClassController::RunError(TInt /*aError*/) |
488 TInt CUsbDummyClassController::RunError(TInt /*aError*/) |
583 /** |
489 /** |
584 * Standard active object error-handling function. |
490 * Standard active object error-handling function. |
585 * |
491 * |
586 * Should return KErrNone to avoid an active scheduler panic. This function |
492 * Should return KErrNone to avoid an active scheduler panic. This function |
587 * should never be called as there is another mechanism for catching errors. |
493 * should never be called as there is another mechanism for catching errors. |
588 */ |
494 */ |
589 { |
495 { |
590 OstTrace1( TRACE_FATAL, CUSBDUMMYCLASSCONTROLLER_RUNERROR, "CUsbDummyClassController::RunError;panic code=%d", EDummyPanicBadState ); |
496 __ASSERT_DEBUG(EFalse, |
591 __ASSERT_DEBUG(EFalse, |
497 _USB_PANIC(KDummyControllerPanic, EDummyPanicBadState)); |
592 User::Panic(KDummyControllerPanic, EDummyPanicBadState)); |
|
593 return KErrNone; |
498 return KErrNone; |
594 } |
499 } |
595 |
500 |
596 // |
501 // |
597 // End of file |
502 // End of file |