70 * This call registers the object with the USB device driver |
71 * This call registers the object with the USB device driver |
71 * |
72 * |
72 * @param aParent Observer. |
73 * @param aParent Observer. |
73 */ |
74 */ |
74 { |
75 { |
|
76 OstTraceFunctionEntry0( CCDCDATAINTERFACE_CONSTRUCTL_ENTRY ); |
|
77 |
75 BaseConstructL(); |
78 BaseConstructL(); |
76 |
|
77 iReadOneOrMoreReader = CActiveReadOneOrMoreReader::NewL(*this, iLdd, EEndpoint2); |
79 iReadOneOrMoreReader = CActiveReadOneOrMoreReader::NewL(*this, iLdd, EEndpoint2); |
78 iReader = CActiveReader::NewL(*this, iLdd, EEndpoint2); |
80 iReader = CActiveReader::NewL(*this, iLdd, EEndpoint2); |
79 iDataAvailableNotifier = CActiveDataAvailableNotifier::NewL(*this, iLdd, EEndpoint2); |
81 iDataAvailableNotifier = CActiveDataAvailableNotifier::NewL(*this, iLdd, EEndpoint2); |
80 iWriter = CActiveWriter::NewL(*this, iLdd, EEndpoint1); |
82 iWriter = CActiveWriter::NewL(*this, iLdd, EEndpoint1); |
81 iLinkState = CLinkStateNotifier::NewL(*this, iLdd); |
83 iLinkState = CLinkStateNotifier::NewL(*this, iLdd); |
82 |
84 |
83 iLinkState->Start(); |
85 iLinkState->Start(); |
84 |
86 |
85 iHostCanHandleZLPs = (KUsbAcmHostCanHandleZLPs != 0); |
87 iHostCanHandleZLPs = (KUsbAcmHostCanHandleZLPs != 0); |
86 |
88 |
|
89 OstTraceFunctionExit0( CCDCDATAINTERFACE_CONSTRUCTL_EXIT ); |
87 } |
90 } |
88 |
91 |
89 TInt CCdcDataInterface::SetUpInterface() |
92 TInt CCdcDataInterface::SetUpInterface() |
90 /** |
93 /** |
91 * Retrieves the device capabilities and searches for suitable input and |
94 * Retrieves the device capabilities and searches for suitable input and |
92 * output bulk endpoints. If suitable endpoints are found, an interface |
95 * output bulk endpoints. If suitable endpoints are found, an interface |
93 * descriptor for the endpoints is registered with the LDD. |
96 * descriptor for the endpoints is registered with the LDD. |
94 */ |
97 */ |
95 { |
98 { |
96 LOGTEXT(_L8(">>CCdcDataInterface::SetUpInterface")); |
99 OstTraceFunctionEntry0( CCDCDATAINTERFACE_SETUPINTERFACE_ENTRY ); |
97 |
100 |
98 TUsbDeviceCaps dCaps; |
101 TUsbDeviceCaps dCaps; |
99 TInt ret = iLdd.DeviceCaps(dCaps); |
102 TInt ret = iLdd.DeviceCaps(dCaps); |
100 LOGTEXT(_L8("\tchecking result of DeviceCaps")); |
103 OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE, "CCdcDataInterface::SetUpInterface;\tchecking result of DeviceCaps" ); |
101 if ( ret ) |
104 if ( ret ) |
102 { |
105 { |
103 LOGTEXT2(_L8("<<CCdcDataInterface::SetUpInterface ret=%d"), ret); |
106 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP1, "CCdcDataInterface::SetUpInterface;ret=%d", ret ); |
|
107 OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT ); |
104 return ret; |
108 return ret; |
105 } |
109 } |
106 |
110 |
107 TInt maxBulkPacketSize = (dCaps().iHighSpeed) ? KMaxPacketTypeBulkHS : KMaxPacketTypeBulkFS; |
111 TInt maxBulkPacketSize = (dCaps().iHighSpeed) ? KMaxPacketTypeBulkHS : KMaxPacketTypeBulkFS; |
108 const TUint KRequiredNumberOfEndpoints = 2; |
112 const TUint KRequiredNumberOfEndpoints = 2; |
109 |
113 |
110 const TUint totalEndpoints = static_cast<TUint>(dCaps().iTotalEndpoints); |
114 const TUint totalEndpoints = static_cast<TUint>(dCaps().iTotalEndpoints); |
111 LOGTEXT2(_L8("\tiTotalEndpoints = %d"), totalEndpoints); |
115 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP2, |
|
116 "CCdcDataInterface::SetUpInterface;totalEndpoints=%d", (TInt)totalEndpoints ); |
|
117 |
112 if ( totalEndpoints < KRequiredNumberOfEndpoints ) |
118 if ( totalEndpoints < KRequiredNumberOfEndpoints ) |
113 { |
119 { |
114 LOGTEXT2(_L8("<<CCdcDataInterface::SetUpInterface ret=%d"), |
120 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP3, "CCdcDataInterface::SetUpInterface;ret=%d", KErrGeneral ); |
115 KErrGeneral); |
121 OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT_DUP1 ); |
116 return KErrGeneral; |
122 return KErrGeneral; |
117 } |
123 } |
118 |
124 |
119 // Endpoints |
125 // Endpoints |
120 TUsbcEndpointData data[KUsbcMaxEndpoints]; |
126 TUsbcEndpointData data[KUsbcMaxEndpoints]; |
121 TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
127 TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
122 ret = iLdd.EndpointCaps(dataptr); |
128 ret = iLdd.EndpointCaps(dataptr); |
123 LOGTEXT(_L8("\tchecking result of EndpointCaps")); |
129 OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP9, "CCdcDataInterface::SetUpInterface;\tchecking result of EndpointCaps" ); |
124 if ( ret ) |
130 if ( ret ) |
125 { |
131 { |
126 LOGTEXT2(_L8("<<CCdcDataInterface::SetUpInterface ret=%d"), ret); |
132 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP4, "CCdcDataInterface::SetUpInterface;ret=%d", ret ); |
|
133 OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT_DUP2 ); |
127 return ret; |
134 return ret; |
128 } |
135 } |
129 |
136 |
130 // |
137 // |
131 TUsbcInterfaceInfoBuf ifc; |
138 TUsbcInterfaceInfoBuf ifc; |
132 TBool foundIn = EFalse; |
139 TBool foundIn = EFalse; |
133 TBool foundOut = EFalse; |
140 TBool foundOut = EFalse; |
134 |
141 |
135 for ( TUint i = 0; !(foundIn && foundOut) && i < totalEndpoints; i++ ) |
142 for ( TUint i = 0; !(foundIn && foundOut) && i < totalEndpoints; i++ ) |
136 { |
143 { |
137 const TUsbcEndpointCaps* caps = &data[i].iCaps; |
144 const TUsbcEndpointCaps* caps = &data[i].iCaps; |
138 __ASSERT_DEBUG(caps, |
145 if (!caps) |
139 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
146 { |
|
147 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP5, "CCdcDataInterface::SetUpInterface;caps=%p", caps ); |
|
148 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
149 } |
140 if (data[i].iInUse) |
150 if (data[i].iInUse) |
141 continue; |
151 continue; |
142 |
152 |
143 //get the max packet size it can potentially support |
153 //get the max packet size it can potentially support |
144 //it's possible that it can support Isoch (1023) which is greater |
154 //it's possible that it can support Isoch (1023) which is greater |
265 else |
282 else |
266 { |
283 { |
267 iWriter->Write(aDes, aLen, EFalse); |
284 iWriter->Write(aDes, aLen, EFalse); |
268 } |
285 } |
269 |
286 |
270 LOGTEXT(_L8("<<CCdcDataInterface::Write")); |
287 OstTraceFunctionExit0( CCDCDATAINTERFACE_WRITE_EXIT ); |
271 } |
288 } |
272 |
289 |
273 void CCdcDataInterface::WriteCompleted(TInt aError) |
290 void CCdcDataInterface::WriteCompleted(TInt aError) |
274 /** |
291 /** |
275 * Called when a write request completes. |
292 * Called when a write request completes. |
276 * |
293 * |
277 * @param aError Error. |
294 * @param aError Error. |
278 */ |
295 */ |
279 { |
296 { |
280 LOGTEXT2(_L8(">>CCdcDataInterface::WriteCompleted aError=%d"), aError); |
297 OstTraceFunctionEntry0( CCDCDATAINTERFACE_WRITECOMPLETED_ENTRY ); |
|
298 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_WRITECOMPLETED, "CCdcDataInterface::WriteCompleted;aError=%d", aError ); |
281 |
299 |
282 #ifdef __HEADLESS_ACM_TEST_CODE__ |
300 #ifdef __HEADLESS_ACM_TEST_CODE__ |
283 // Issue another Read or ReadOneOrMore as appropriate. |
301 // Issue another Read or ReadOneOrMore as appropriate. |
284 // If the Write completed with an error, we panic, as it's invalidating |
302 // If the Write completed with an error, we panic, as it's invalidating |
285 // the test. |
303 // the test. |
286 __ASSERT_DEBUG(aError == KErrNone, |
304 if (aError != KErrNone) |
287 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
305 { |
|
306 OstTrace1( TRACE_FATAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP1, "CCdcDataInterface::WriteCompleted;aError=%d", aError ); |
|
307 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
308 } |
288 switch ( iHeadlessReadType ) |
309 switch ( iHeadlessReadType ) |
289 { |
310 { |
290 case ERead: |
311 case ERead: |
291 LOGTEXT2(_L8("__HEADLESS_ACM_TEST_CODE__- issuing Read for %d bytes"), |
312 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP2, |
292 iHeadlessReadLength); |
313 "CCdcDataInterface::WriteCompleted;__HEADLESS_ACM_TEST_CODE__- issuing Read for %d bytes", iHeadlessReadLength ); |
293 __ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
314 |
|
315 if (!iReader) |
|
316 { |
|
317 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP3, "CCdcDataInterface::WriteCompleted;iReader=%p", iReader ); |
|
318 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
319 } |
294 iReader->Read(iHeadlessAcmBuffer, iHeadlessReadLength); |
320 iReader->Read(iHeadlessAcmBuffer, iHeadlessReadLength); |
295 break; |
321 break; |
296 case EReadOneOrMore: |
322 case EReadOneOrMore: |
297 LOGTEXT2(_L8("__HEADLESS_ACM_TEST_CODE__- issuing ReadOneOrMore for %d bytes"), |
323 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP4, |
298 iHeadlessReadLength); |
324 "CCdcDataInterface::WriteCompleted;__HEADLESS_ACM_TEST_CODE__- issuing ReadOneOrMore for %d bytes", iHeadlessReadLength ); |
299 __ASSERT_DEBUG(iReadOneOrMoreReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
325 |
|
326 if (!iReadOneOrMoreReader) |
|
327 { |
|
328 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP5, |
|
329 "CCdcDataInterface::WriteCompleted;iReadOneOrMoreReader=%p", iReadOneOrMoreReader ); |
|
330 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
331 } |
300 iReadOneOrMoreReader->ReadOneOrMore(iHeadlessAcmBuffer, iHeadlessReadLength); |
332 iReadOneOrMoreReader->ReadOneOrMore(iHeadlessAcmBuffer, iHeadlessReadLength); |
301 break; |
333 break; |
302 case EUnknown: |
334 case EUnknown: |
303 default: |
335 default: |
304 _USB_PANIC(KAcmPanicCat, EPanicInternalError); |
336 OstTrace0( TRACE_FATAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP6, "CCdcDataInterface::WriteCompleted;EPanicInternalError" ); |
|
337 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
305 break; |
338 break; |
306 } |
339 } |
307 #else |
340 #else |
308 // In case the write observer wants to post another write synchronously on |
341 // In case the write observer wants to post another write synchronously on |
309 // being informed that this write has completed, use this little 'temp' |
342 // being informed that this write has completed, use this little 'temp' |
310 // fiddle. |
343 // fiddle. |
311 __ASSERT_DEBUG(iWriteObserver, |
344 if (!iWriteObserver) |
312 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
345 { |
|
346 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP7, |
|
347 "CCdcDataInterface::WriteCompleted;iWriteObserver=%p", iWriteObserver ); |
|
348 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
349 } |
313 MWriteObserver* temp = iWriteObserver; |
350 MWriteObserver* temp = iWriteObserver; |
314 iWriteObserver = NULL; |
351 iWriteObserver = NULL; |
315 LOGTEXT(_L8("\tcalling WriteCompleted on observer")); |
352 OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP8, |
|
353 "CCdcDataInterface::WriteCompleted;\tcalling WriteCompleted on observer" ); |
316 temp->WriteCompleted(aError); |
354 temp->WriteCompleted(aError); |
317 #endif // __HEADLESS_ACM_TEST_CODE__ |
355 #endif // __HEADLESS_ACM_TEST_CODE__ |
318 |
356 |
319 LOGTEXT(_L8("<<CCdcDataInterface::WriteCompleted")); |
357 OstTraceFunctionExit0( CCDCDATAINTERFACE_WRITECOMPLETED_EXIT ); |
320 } |
358 } |
321 |
359 |
322 void CCdcDataInterface::CancelWrite() |
360 void CCdcDataInterface::CancelWrite() |
323 /** |
361 /** |
324 * Cancel an outstanding write request |
362 * Cancel an outstanding write request |
325 */ |
363 */ |
326 { |
364 { |
327 LOG_FUNC |
365 OstTraceFunctionEntry0( CCDCDATAINTERFACE_CANCELWRITE_ENTRY ); |
328 |
366 if (!iWriter) |
329 __ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
367 { |
330 |
368 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_CANCELWRITE, "CCdcDataInterface::CancelWrite;iWriter=%p", iWriter ); |
|
369 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
370 } |
331 iWriter->Cancel(); |
371 iWriter->Cancel(); |
332 |
|
333 iWriteObserver = NULL; |
372 iWriteObserver = NULL; |
|
373 OstTraceFunctionExit0( CCDCDATAINTERFACE_CANCELWRITE_EXIT ); |
334 } |
374 } |
335 |
375 |
336 void CCdcDataInterface::Read(MReadObserver& aObserver, |
376 void CCdcDataInterface::Read(MReadObserver& aObserver, |
337 TDes8& aDes, |
377 TDes8& aDes, |
338 TInt aMaxLen) |
378 TInt aMaxLen) |
343 * @param aObserver The observer to notify of completion. |
383 * @param aObserver The observer to notify of completion. |
344 * @param aDes Descriptor to put the read data in |
384 * @param aDes Descriptor to put the read data in |
345 * @param aMaxLen Number of bytes to read |
385 * @param aMaxLen Number of bytes to read |
346 */ |
386 */ |
347 { |
387 { |
348 LOG_FUNC |
388 OstTraceFunctionEntry0( CCDCDATAINTERFACE_READ_ENTRY ); |
349 |
389 |
350 #ifdef __HEADLESS_ACM_TEST_CODE__ |
390 #ifdef __HEADLESS_ACM_TEST_CODE__ |
351 LOGTEXT(_L8("__HEADLESS_ACM_TEST_CODE__")); |
391 OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_READ, "CCdcDataInterface::Read;__HEADLESS_ACM_TEST_CODE__" ); |
352 // Issue a Read using our special internal buffer. |
392 // Issue a Read using our special internal buffer. |
353 iHeadlessReadType = ERead; |
393 iHeadlessReadType = ERead; |
354 iHeadlessReadLength = aMaxLen; |
394 iHeadlessReadLength = aMaxLen; |
355 static_cast<void>(&aObserver); |
395 static_cast<void>(&aObserver); |
356 static_cast<void>(&aDes); |
396 static_cast<void>(&aDes); |
357 __ASSERT_DEBUG(aMaxLen <= iHeadlessAcmBuffer.MaxLength(), |
397 if (aMaxLen > iHeadlessAcmBuffer.MaxLength()) |
358 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
398 { |
359 __ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
399 OstTrace1( TRACE_FATAL, CCDCDATAINTERFACE_READ_DUP1, "CCdcDataInterface::Read;aMaxLen=%d", aMaxLen ); |
|
400 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
401 } |
|
402 if (!iReader) |
|
403 { |
|
404 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READ_DUP2, "CCdcDataInterface::Read;iReader=%p", iReader ); |
|
405 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
406 } |
360 iReader->Read(iHeadlessAcmBuffer, aMaxLen); |
407 iReader->Read(iHeadlessAcmBuffer, aMaxLen); |
361 #else |
408 #else |
362 __ASSERT_DEBUG(!iReadObserver, |
409 if (iReadObserver) |
363 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
410 { |
|
411 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READ_DUP3, "CCdcDataInterface::Read;iReadObserver=%p", iReadObserver ); |
|
412 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
413 } |
364 iReadObserver = &aObserver; |
414 iReadObserver = &aObserver; |
365 |
415 if (!iReader) |
366 __ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
416 { |
|
417 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READ_DUP4, "CCdcDataInterface::Read;iReader=%p", iReader ); |
|
418 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
419 } |
|
420 |
367 iReader->Read(aDes, aMaxLen); |
421 iReader->Read(aDes, aMaxLen); |
368 #endif // __HEADLESS_ACM_TEST_CODE__ |
422 #endif // __HEADLESS_ACM_TEST_CODE__ |
|
423 OstTraceFunctionExit0( CCDCDATAINTERFACE_READ_EXIT ); |
369 } |
424 } |
370 |
425 |
371 void CCdcDataInterface::ReadOneOrMore(MReadOneOrMoreObserver& aObserver, |
426 void CCdcDataInterface::ReadOneOrMore(MReadOneOrMoreObserver& aObserver, |
372 TDes8& aDes, |
427 TDes8& aDes, |
373 TInt aMaxLen) |
428 TInt aMaxLen) |
378 * @param aObserver The observer to notify of completion. |
433 * @param aObserver The observer to notify of completion. |
379 * @param aDes Descriptor to put the read data in |
434 * @param aDes Descriptor to put the read data in |
380 * @param aMaxLen Number of bytes to read |
435 * @param aMaxLen Number of bytes to read |
381 */ |
436 */ |
382 { |
437 { |
383 LOG_FUNC |
438 OstTraceFunctionEntry0( CCDCDATAINTERFACE_READONEORMORE_ENTRY ); |
|
439 |
384 |
440 |
385 #ifdef __HEADLESS_ACM_TEST_CODE__ |
441 #ifdef __HEADLESS_ACM_TEST_CODE__ |
386 LOGTEXT(_L8("__HEADLESS_ACM_TEST_CODE__")); |
442 OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_READONEORMORE, "CCdcDataInterface::ReadOneOrMore;__HEADLESS_ACM_TEST_CODE__" ); |
387 // Issue a ReadOneOrMore using our special internal buffer. |
443 // Issue a ReadOneOrMore using our special internal buffer. |
388 iHeadlessReadType = EReadOneOrMore; |
444 iHeadlessReadType = EReadOneOrMore; |
389 iHeadlessReadLength = aMaxLen; |
445 iHeadlessReadLength = aMaxLen; |
390 static_cast<void>(&aObserver); |
446 static_cast<void>(&aObserver); |
391 static_cast<void>(&aDes); |
447 static_cast<void>(&aDes); |
392 __ASSERT_DEBUG(aMaxLen <= iHeadlessAcmBuffer.MaxLength(), |
448 if (aMaxLen > iHeadlessAcmBuffer.MaxLength()) |
393 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
449 { |
394 __ASSERT_DEBUG(iReadOneOrMoreReader, |
450 OstTrace1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORE_DUP1, "CCdcDataInterface::ReadOneOrMore;aMaxLen=%d", aMaxLen ); |
395 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
451 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
452 } |
|
453 if (!iReadOneOrMoreReader) |
|
454 { |
|
455 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORE_DUP2, |
|
456 "CCdcDataInterface::ReadOneOrMore;iReadOneOrMoreReader=%p", iReadOneOrMoreReader ); |
|
457 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
458 } |
396 iReadOneOrMoreReader->ReadOneOrMore(iHeadlessAcmBuffer, aMaxLen); |
459 iReadOneOrMoreReader->ReadOneOrMore(iHeadlessAcmBuffer, aMaxLen); |
397 #else |
460 #else |
398 __ASSERT_DEBUG(!iReadOneOrMoreObserver, |
461 if (iReadOneOrMoreObserver) |
399 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
462 { |
|
463 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORE_DUP3, |
|
464 "CCdcDataInterface::ReadOneOrMore;iReadOneOrMoreObserver=%p", iReadOneOrMoreObserver ); |
|
465 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
466 } |
400 iReadOneOrMoreObserver = &aObserver; |
467 iReadOneOrMoreObserver = &aObserver; |
401 |
468 if (!iReadOneOrMoreReader) |
402 __ASSERT_DEBUG(iReadOneOrMoreReader, |
469 { |
403 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
470 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORE_DUP4, |
|
471 "CCdcDataInterface::ReadOneOrMore;iReadOneOrMoreObserver=%p", iReadOneOrMoreObserver ); |
|
472 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
473 } |
404 iReadOneOrMoreReader->ReadOneOrMore(aDes, aMaxLen); |
474 iReadOneOrMoreReader->ReadOneOrMore(aDes, aMaxLen); |
405 #endif // __HEADLESS_ACM_TEST_CODE__ |
475 #endif // __HEADLESS_ACM_TEST_CODE__ |
|
476 OstTraceFunctionExit0( CCDCDATAINTERFACE_READONEORMORE_EXIT ); |
406 } |
477 } |
407 |
478 |
408 void CCdcDataInterface::ReadOneOrMoreCompleted(TInt aError) |
479 void CCdcDataInterface::ReadOneOrMoreCompleted(TInt aError) |
409 /** |
480 /** |
410 * The completion function, called when a ReadOneOrMore request is completed |
481 * The completion function, called when a ReadOneOrMore request is completed |
411 * by the LDD. |
482 * by the LDD. |
412 * |
483 * |
413 * @param aError The result of the read request. |
484 * @param aError The result of the read request. |
414 */ |
485 */ |
415 { |
486 { |
416 LOGTEXT2(_L8(">>CCdcDataInterface::ReadOneOrMoreCompleted aError=%d"), |
487 OstTraceFunctionEntry0( CCDCDATAINTERFACE_READONEORMORECOMPLETED_ENTRY ); |
417 aError); |
488 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_READONEORMORECOMPLETED, "CCdcDataInterface::ReadOneOrMoreCompleted;aError=%d", aError ); |
418 |
489 |
419 #ifdef __HEADLESS_ACM_TEST_CODE__ |
490 #ifdef __HEADLESS_ACM_TEST_CODE__ |
420 LOGTEXT2(_L8("__HEADLESS_ACM_TEST_CODE__- issuing Write for %d bytes"), |
491 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_READONEORMORECOMPLETED_DUP1, |
421 iHeadlessAcmBuffer.Length()); |
492 "CCdcDataInterface::ReadOneOrMoreCompleted;__HEADLESS_ACM_TEST_CODE__- issuing Write for %d bytes", iHeadlessAcmBuffer.Length() ); |
|
493 |
422 // Write back the data just read. |
494 // Write back the data just read. |
423 // If the ReadOneOrMore completed with an error, we panic, as it's |
495 // If the ReadOneOrMore completed with an error, we panic, as it's |
424 // invalidating the test. |
496 // invalidating the test. |
425 __ASSERT_DEBUG(aError == KErrNone, |
497 if (aError != KErrNone) |
426 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
498 { |
427 __ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
499 OstTrace1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORECOMPLETED_DUP2, |
|
500 "CCdcDataInterface::ReadOneOrMoreCompleted;aError=%d", aError ); |
|
501 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
502 } |
|
503 |
|
504 if (!iWriter) |
|
505 { |
|
506 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORECOMPLETED_DUP3, |
|
507 "CCdcDataInterface::ReadOneOrMoreCompleted;iWriter=%p", iWriter ); |
|
508 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
509 } |
428 iWriter->Write(iHeadlessAcmBuffer, iHeadlessAcmBuffer.Length(), EFalse); |
510 iWriter->Write(iHeadlessAcmBuffer, iHeadlessAcmBuffer.Length(), EFalse); |
429 #else |
511 #else |
430 __ASSERT_DEBUG(iReadOneOrMoreObserver, |
512 if (!iReadOneOrMoreObserver) |
431 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
513 { |
|
514 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORECOMPLETED_DUP4, |
|
515 "CCdcDataInterface::ReadOneOrMoreCompleted;iReadOneOrMoreObserver=%p", iReadOneOrMoreObserver ); |
|
516 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
517 } |
432 |
518 |
433 // See comment in WriteCompleted. |
519 // See comment in WriteCompleted. |
434 MReadOneOrMoreObserver* temp = iReadOneOrMoreObserver; |
520 MReadOneOrMoreObserver* temp = iReadOneOrMoreObserver; |
435 iReadOneOrMoreObserver = NULL; |
521 iReadOneOrMoreObserver = NULL; |
436 LOGTEXT(_L8("\tcalling ReadOneOrMoreCompleted on observer")); |
522 OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_READONEORMORECOMPLETED_DUP5, |
|
523 "CCdcDataInterface::ReadOneOrMoreCompleted;\tcalling ReadOneOrMoreCompleted on observer" ); |
437 temp->ReadOneOrMoreCompleted(aError); |
524 temp->ReadOneOrMoreCompleted(aError); |
438 #endif // __HEADLESS_ACM_TEST_CODE__ |
525 #endif // __HEADLESS_ACM_TEST_CODE__ |
439 |
526 |
440 LOGTEXT(_L8("<<CCdcDataInterface::ReadOneOrMoreCompleted")); |
527 OstTraceFunctionExit0( CCDCDATAINTERFACE_READONEORMORECOMPLETED_EXIT ); |
441 } |
528 } |
442 |
529 |
443 void CCdcDataInterface::ReadCompleted(TInt aError) |
530 void CCdcDataInterface::ReadCompleted(TInt aError) |
444 /** |
531 /** |
445 * Called by the active reader object when it completes. |
532 * Called by the active reader object when it completes. |
446 * |
533 * |
447 * @param aError Error. |
534 * @param aError Error. |
448 */ |
535 */ |
449 { |
536 { |
450 LOGTEXT2(_L8(">>CCdcDataInterface::ReadCompleted aError=%d"), aError); |
537 OstTraceFunctionEntry0( CCDCDATAINTERFACE_READCOMPLETED_ENTRY ); |
|
538 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_READCOMPLETED, "CCdcDataInterface::ReadCompleted;aError=%d", aError ); |
451 |
539 |
452 #ifdef __HEADLESS_ACM_TEST_CODE__ |
540 #ifdef __HEADLESS_ACM_TEST_CODE__ |
453 LOGTEXT2(_L8("__HEADLESS_ACM_TEST_CODE__- issuing Write for %d bytes"), |
541 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_READCOMPLETED_DUP1, |
454 iHeadlessAcmBuffer.Length()); |
542 "CCdcDataInterface::ReadCompleted;__HEADLESS_ACM_TEST_CODE__- issuing Write for %d bytes", iHeadlessAcmBuffer.Length() ); |
|
543 |
455 // Write back the data just read. |
544 // Write back the data just read. |
456 // If the Read completed with an error, we panic, as it's invalidating the |
545 // If the Read completed with an error, we panic, as it's invalidating the |
457 // test. |
546 // test. |
458 __ASSERT_DEBUG(aError == KErrNone, |
547 if (aError != KErrNone) |
459 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
548 { |
460 __ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
549 OstTrace1( TRACE_FATAL, CCDCDATAINTERFACE_READCOMPLETED_DUP2, "CCdcDataInterface::ReadCompleted;aError=%d", aError ); |
|
550 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
551 } |
|
552 |
|
553 if (!iWriter) |
|
554 { |
|
555 OstTraceExt1( TRACE_NORMAL, CCDCDATAINTERFACE_READCOMPLETED_DUP3, "CCdcDataInterface::ReadCompleted;iWriter=%p", iWriter ); |
|
556 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
557 } |
461 iWriter->Write(iHeadlessAcmBuffer, iHeadlessAcmBuffer.Length(), EFalse); |
558 iWriter->Write(iHeadlessAcmBuffer, iHeadlessAcmBuffer.Length(), EFalse); |
462 #else |
559 #else |
463 __ASSERT_DEBUG(iReadObserver, |
560 if (!iReadObserver) |
464 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
561 { |
|
562 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READCOMPLETED_DUP4, |
|
563 "CCdcDataInterface::ReadCompleted;iReadObserver=%p", iReadObserver ); |
|
564 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
565 } |
465 |
566 |
466 // See comment in WriteCompleted. |
567 // See comment in WriteCompleted. |
467 MReadObserver* temp = iReadObserver; |
568 MReadObserver* temp = iReadObserver; |
468 iReadObserver = NULL; |
569 iReadObserver = NULL; |
469 LOGTEXT(_L8("\tcalled ReadCompleted on observer")); |
570 OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_READCOMPLETED_DUP5, "CCdcDataInterface::ReadCompleted;\tcalled ReadCompleted on observer" ); |
470 temp->ReadCompleted(aError); |
571 temp->ReadCompleted(aError); |
471 #endif // __HEADLESS_ACM_TEST_CODE__ |
572 #endif // __HEADLESS_ACM_TEST_CODE__ |
472 |
573 |
473 LOGTEXT(_L8("<<CCdcDataInterface::ReadCompleted")); |
574 OstTraceFunctionExit0( CCDCDATAINTERFACE_READCOMPLETED_EXIT ); |
474 } |
575 } |
475 |
576 |
476 void CCdcDataInterface::CancelRead() |
577 void CCdcDataInterface::CancelRead() |
477 /** |
578 /** |
478 * Cancel an outstanding read request |
579 * Cancel an outstanding read request |
479 */ |
580 */ |
480 { |
581 { |
481 LOG_FUNC |
582 OstTraceFunctionEntry0( CCDCDATAINTERFACE_CANCELREAD_ENTRY ); |
482 |
583 if (!iReader) |
483 __ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
584 { |
484 __ASSERT_DEBUG(iReadOneOrMoreReader, |
585 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_CANCELREAD, "CCdcDataInterface::CancelRead;iReader=%p", iReader ); |
485 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
586 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
587 } |
|
588 if (!iReadOneOrMoreReader) |
|
589 { |
|
590 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_CANCELREAD_DUP1, |
|
591 "CCdcDataInterface::CancelRead;iReadOneOrMoreReader=%p", iReadOneOrMoreReader ); |
|
592 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
593 } |
486 |
594 |
487 iReader->Cancel(); |
595 iReader->Cancel(); |
488 iReadOneOrMoreReader->Cancel(); |
596 iReadOneOrMoreReader->Cancel(); |
489 iReadObserver = NULL; |
597 iReadObserver = NULL; |
490 iReadOneOrMoreObserver = NULL; |
598 iReadOneOrMoreObserver = NULL; |
|
599 OstTraceFunctionExit0( CCDCDATAINTERFACE_CANCELREAD_EXIT ); |
491 } |
600 } |
492 |
601 |
493 |
602 |
494 void CCdcDataInterface::NotifyDataAvailableCompleted(TInt aError) |
603 void CCdcDataInterface::NotifyDataAvailableCompleted(TInt aError) |
495 /** |
604 /** |
496 * Called by the active data available notifier object when it completes. |
605 * Called by the active data available notifier object when it completes. |
497 * |
606 * |
498 * @param aError Error. |
607 * @param aError Error. |
499 */ |
608 */ |
500 { |
609 { |
501 LOGTEXT2(_L8(">>CCdcDataInterface::NotifyDataAvailableCompleted aError=%d"), aError); |
610 OstTraceFunctionEntry0( CCDCDATAINTERFACE_NOTIFYDATAAVAILABLECOMPLETED_ENTRY ); |
|
611 OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_NOTIFYDATAAVAILABLECOMPLETED, |
|
612 "CCdcDataInterface::NotifyDataAvailableCompleted;aError=%d", aError ); |
502 |
613 |
503 // See comment in WriteCompleted. |
614 // See comment in WriteCompleted. |
504 MNotifyDataAvailableObserver* temp = iNotifyDataAvailableObserver; |
615 MNotifyDataAvailableObserver* temp = iNotifyDataAvailableObserver; |
505 iNotifyDataAvailableObserver = NULL; |
616 iNotifyDataAvailableObserver = NULL; |
506 LOGTEXT(_L8("\tcalled NotifyDataAvailableCompleted on observer")); |
617 OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_NOTIFYDATAAVAILABLECOMPLETED_DUP1, |
|
618 "CCdcDataInterface::NotifyDataAvailableCompleted;\tcalled NotifyDataAvailableCompleted on observer" ); |
507 temp->NotifyDataAvailableCompleted(aError); |
619 temp->NotifyDataAvailableCompleted(aError); |
508 |
620 OstTraceFunctionExit0( CCDCDATAINTERFACE_NOTIFYDATAAVAILABLECOMPLETED_EXIT ); |
509 LOGTEXT(_L8("<<CCdcDataInterface::NotifyDataAvailableCompleted")); |
|
510 } |
621 } |
511 |
622 |
512 void CCdcDataInterface::NotifyDataAvailable(MNotifyDataAvailableObserver& aObserver) |
623 void CCdcDataInterface::NotifyDataAvailable(MNotifyDataAvailableObserver& aObserver) |
513 /** |
624 /** |
514 * Complete if any data arrives. |
625 * Complete if any data arrives. |
515 * |
626 * |
516 * @param aObserver The observer to notify of completion. |
627 * @param aObserver The observer to notify of completion. |
517 */ |
628 */ |
518 { |
629 { |
519 LOG_FUNC |
630 OstTraceFunctionEntry0( CCDCDATAINTERFACE_NOTIFYDATAAVAILABLE_ENTRY ); |
520 |
631 |
521 __ASSERT_DEBUG(!iNotifyDataAvailableObserver, _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
632 if (iNotifyDataAvailableObserver) |
|
633 { |
|
634 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_NOTIFYDATAAVAILABLE, |
|
635 "CCdcDataInterface::NotifyDataAvailable;iNotifyDataAvailableObserver=%p", iNotifyDataAvailableObserver ); |
|
636 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
637 } |
522 iNotifyDataAvailableObserver = &aObserver; |
638 iNotifyDataAvailableObserver = &aObserver; |
523 |
639 if (!iDataAvailableNotifier) |
524 __ASSERT_DEBUG(iDataAvailableNotifier, |
640 { |
525 _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
641 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_NOTIFYDATAAVAILABLE_DUP1, |
|
642 "CCdcDataInterface::NotifyDataAvailable;iDataAvailableNotifier=%p", iDataAvailableNotifier ); |
|
643 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
644 } |
526 iDataAvailableNotifier->NotifyDataAvailable(); |
645 iDataAvailableNotifier->NotifyDataAvailable(); |
|
646 OstTraceFunctionExit0( CCDCDATAINTERFACE_NOTIFYDATAAVAILABLE_EXIT ); |
527 } |
647 } |
528 |
648 |
529 void CCdcDataInterface::CancelNotifyDataAvailable() |
649 void CCdcDataInterface::CancelNotifyDataAvailable() |
530 /** |
650 /** |
531 * Cancel notification of arrival of data. |
651 * Cancel notification of arrival of data. |
532 */ |
652 */ |
533 { |
653 { |
534 LOG_FUNC |
654 OstTraceFunctionEntry0( CCDCDATAINTERFACE_CANCELNOTIFYDATAAVAILABLE_ENTRY ); |
535 |
655 if (!iDataAvailableNotifier) |
536 __ASSERT_DEBUG(iDataAvailableNotifier, _USB_PANIC(KAcmPanicCat, EPanicInternalError)); |
656 { |
537 |
657 OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_CANCELNOTIFYDATAAVAILABLE, |
|
658 "CCdcDataInterface::CancelNotifyDataAvailable;iDataAvailableNotifier=%p", iDataAvailableNotifier ); |
|
659 __ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) ); |
|
660 } |
538 iDataAvailableNotifier->Cancel(); |
661 iDataAvailableNotifier->Cancel(); |
539 iNotifyDataAvailableObserver = NULL; |
662 iNotifyDataAvailableObserver = NULL; |
|
663 OstTraceFunctionExit0( CCDCDATAINTERFACE_CANCELNOTIFYDATAAVAILABLE_EXIT ); |
540 } |
664 } |
541 |
665 |
542 // |
666 // |
543 // End of file |
667 // End of file |