usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/CdcDataInterface.cpp
branchRCL_3
changeset 16 012cc2ee6408
parent 15 f92a4f87e424
equal deleted inserted replaced
15:f92a4f87e424 16:012cc2ee6408
     1 /*
     1 /*
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    21 #include "ActiveWriter.h"
    21 #include "ActiveWriter.h"
    22 #include "AcmPanic.h"
    22 #include "AcmPanic.h"
    23 #include "AcmUtils.h"
    23 #include "AcmUtils.h"
    24 #include "ActiveReadOneOrMoreReader.h"
    24 #include "ActiveReadOneOrMoreReader.h"
    25 #include "ActiveDataAvailableNotifier.h"
    25 #include "ActiveDataAvailableNotifier.h"
    26 #include "OstTraceDefinitions.h"
    26 #include <usb/usblogger.h>
    27 #ifdef OST_TRACE_COMPILER_IN_USE
    27 
    28 #include "CdcDataInterfaceTraces.h"
    28 #ifdef __FLOG_ACTIVE
       
    29 _LIT8(KLogComponent, "ECACM");
    29 #endif
    30 #endif
    30 
       
    31 
    31 
    32 #ifdef __HEADLESS_ACM_TEST_CODE__
    32 #ifdef __HEADLESS_ACM_TEST_CODE__
    33 #pragma message ("Building headless ACM (performance test code for RDevUsbcClient)")
    33 #pragma message ("Building headless ACM (performance test code for RDevUsbcClient)")
    34 #endif // __HEADLESS_ACM_TEST_CODE__
    34 #endif // __HEADLESS_ACM_TEST_CODE__
    35 
    35 
    39  * @param aIfcName contains the interface name
    39  * @param aIfcName contains the interface name
    40  */
    40  */
    41  :	CCdcInterfaceBase(aIfcName),
    41  :	CCdcInterfaceBase(aIfcName),
    42  	iPacketSize(KDefaultMaxPacketTypeBulk)
    42  	iPacketSize(KDefaultMaxPacketTypeBulk)
    43 	{
    43 	{
    44 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_CCDCDATAINTERFACE_CONS_ENTRY );
       
    45 	OstTraceFunctionExit0( CCDCDATAINTERFACE_CCDCDATAINTERFACE_CONS_EXIT );
       
    46 	}
    44 	}
    47 
    45 
    48 CCdcDataInterface* CCdcDataInterface::NewL(const TDesC16& aIfcName)
    46 CCdcDataInterface* CCdcDataInterface::NewL(const TDesC16& aIfcName)
    49 /**
    47 /**
    50  * Create a new CCdcDataInterface object and construct it using interface name
    48  * Create a new CCdcDataInterface object and construct it using interface name
    53  * @param aParent Observer.
    51  * @param aParent Observer.
    54  * @param aIfcName Contains the interface name
    52  * @param aIfcName Contains the interface name
    55  * @return A pointer to the new object
    53  * @return A pointer to the new object
    56  */
    54  */
    57 	{
    55 	{
    58 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_NEWL_ENTRY );
    56 	LOG_STATIC_FUNC_ENTRY
    59 	OstTraceExt1( TRACE_NORMAL, CCDCDATAINTERFACE_NEWL, "CCdcDataInterface::NewL;\tData Ifc Name = %S", aIfcName );
    57 
       
    58 	LOGTEXT2(_L("\tData Ifc Name = %S"), &aIfcName);
       
    59 
    60 	CCdcDataInterface* self = new (ELeave) CCdcDataInterface(aIfcName);
    60 	CCdcDataInterface* self = new (ELeave) CCdcDataInterface(aIfcName);
    61 	CleanupStack::PushL(self);
    61 	CleanupStack::PushL(self);
    62 	self->ConstructL();
    62 	self->ConstructL();
    63 	CLEANUPSTACK_POP(self);
    63 	CLEANUPSTACK_POP(self);
    64 	OstTraceFunctionExit0( CCDCDATAINTERFACE_NEWL_EXIT );
       
    65 	return self;
    64 	return self;
    66 	}
    65 	}
    67 
    66 
    68 void CCdcDataInterface::ConstructL()
    67 void CCdcDataInterface::ConstructL()
    69 /**
    68 /**
    71  * This call registers the object with the USB device driver
    70  * This call registers the object with the USB device driver
    72  *
    71  *
    73  * @param aParent Observer.
    72  * @param aParent Observer.
    74  */
    73  */
    75 	{
    74 	{
    76 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_CONSTRUCTL_ENTRY );
       
    77 	
       
    78 	BaseConstructL();
    75 	BaseConstructL();
       
    76 
    79 	iReadOneOrMoreReader  = CActiveReadOneOrMoreReader::NewL(*this, iLdd, EEndpoint2);
    77 	iReadOneOrMoreReader  = CActiveReadOneOrMoreReader::NewL(*this, iLdd, EEndpoint2);
    80 	iReader = CActiveReader::NewL(*this, iLdd, EEndpoint2);
    78 	iReader = CActiveReader::NewL(*this, iLdd, EEndpoint2);
    81 	iDataAvailableNotifier = CActiveDataAvailableNotifier::NewL(*this, iLdd, EEndpoint2);
    79 	iDataAvailableNotifier = CActiveDataAvailableNotifier::NewL(*this, iLdd, EEndpoint2);
    82 	iWriter = CActiveWriter::NewL(*this, iLdd, EEndpoint1);
    80 	iWriter = CActiveWriter::NewL(*this, iLdd, EEndpoint1);
    83 	iLinkState = CLinkStateNotifier::NewL(*this, iLdd);
    81 	iLinkState = CLinkStateNotifier::NewL(*this, iLdd);
    84 	
    82 	
    85 	iLinkState->Start();
    83 	iLinkState->Start();
    86 
    84 
    87 	iHostCanHandleZLPs = (KUsbAcmHostCanHandleZLPs != 0);
    85 	iHostCanHandleZLPs = (KUsbAcmHostCanHandleZLPs != 0);
    88 	
    86 	
    89 	OstTraceFunctionExit0( CCDCDATAINTERFACE_CONSTRUCTL_EXIT );
       
    90 	}
    87 	}
    91 
    88 
    92 TInt CCdcDataInterface::SetUpInterface()
    89 TInt CCdcDataInterface::SetUpInterface()
    93 /**
    90 /**
    94  * Retrieves the device capabilities and searches for suitable input and 
    91  * Retrieves the device capabilities and searches for suitable input and 
    95  * output bulk endpoints. If suitable endpoints are found, an interface 
    92  * output bulk endpoints. If suitable endpoints are found, an interface 
    96  * descriptor for the endpoints is registered with the LDD.
    93  * descriptor for the endpoints is registered with the LDD.
    97  */
    94  */
    98 	{
    95 	{
    99 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_SETUPINTERFACE_ENTRY );
    96 	LOGTEXT(_L8(">>CCdcDataInterface::SetUpInterface"));
   100 
    97 
   101 	TUsbDeviceCaps dCaps;
    98 	TUsbDeviceCaps dCaps;
   102 	TInt ret = iLdd.DeviceCaps(dCaps);
    99 	TInt ret = iLdd.DeviceCaps(dCaps);
   103 	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE, "CCdcDataInterface::SetUpInterface;\tchecking result of DeviceCaps" );
   100 	LOGTEXT(_L8("\tchecking result of DeviceCaps"));
   104 	if ( ret )
   101 	if ( ret )
   105 		{
   102 		{
   106 		OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP1, "CCdcDataInterface::SetUpInterface;ret=%d", ret );
   103 		LOGTEXT2(_L8("<<CCdcDataInterface::SetUpInterface ret=%d"), ret);
   107 		OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT );
       
   108 		return ret;
   104 		return ret;
   109 		}
   105 		}
   110 
   106 
   111 	TInt maxBulkPacketSize = (dCaps().iHighSpeed) ? KMaxPacketTypeBulkHS : KMaxPacketTypeBulkFS;
   107 	TInt maxBulkPacketSize = (dCaps().iHighSpeed) ? KMaxPacketTypeBulkHS : KMaxPacketTypeBulkFS;
   112 	const TUint KRequiredNumberOfEndpoints = 2;
   108 	const TUint KRequiredNumberOfEndpoints = 2;
   113 
   109 
   114 	const TUint totalEndpoints = static_cast<TUint>(dCaps().iTotalEndpoints);
   110 	const TUint totalEndpoints = static_cast<TUint>(dCaps().iTotalEndpoints);
   115 	OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP2, 
   111 	LOGTEXT2(_L8("\tiTotalEndpoints = %d"), totalEndpoints);
   116 			"CCdcDataInterface::SetUpInterface;totalEndpoints=%d", (TInt)totalEndpoints );
       
   117 	
       
   118 	if ( totalEndpoints < KRequiredNumberOfEndpoints )
   112 	if ( totalEndpoints < KRequiredNumberOfEndpoints )
   119 		{
   113 		{
   120 		OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP3, "CCdcDataInterface::SetUpInterface;ret=%d", KErrGeneral );
   114 		LOGTEXT2(_L8("<<CCdcDataInterface::SetUpInterface ret=%d"), 
   121 		OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT_DUP1 );
   115 			KErrGeneral);
   122 		return KErrGeneral;
   116 		return KErrGeneral;
   123 		}
   117 		}
   124 	
   118 	
   125 	// Endpoints
   119 	// Endpoints
   126 	TUsbcEndpointData data[KUsbcMaxEndpoints];
   120 	TUsbcEndpointData data[KUsbcMaxEndpoints];
   127 	TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
   121 	TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
   128 	ret = iLdd.EndpointCaps(dataptr);
   122 	ret = iLdd.EndpointCaps(dataptr);
   129 	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP9, "CCdcDataInterface::SetUpInterface;\tchecking result of EndpointCaps" );
   123 	LOGTEXT(_L8("\tchecking result of EndpointCaps"));
   130 	if ( ret )
   124 	if ( ret )
   131 		{
   125 		{
   132 		OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP4, "CCdcDataInterface::SetUpInterface;ret=%d", ret );
   126 		LOGTEXT2(_L8("<<CCdcDataInterface::SetUpInterface ret=%d"), ret);
   133 		OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT_DUP2 );
       
   134 		return ret;
   127 		return ret;
   135 		}
   128 		}
   136 
   129 
   137 	// 
   130 	// 
   138 	TUsbcInterfaceInfoBuf ifc;
   131 	TUsbcInterfaceInfoBuf ifc;
   139 	TBool foundIn = EFalse;
   132 	TBool foundIn = EFalse;
   140 	TBool foundOut = EFalse;
   133 	TBool foundOut = EFalse;
   141 	
   134 
   142 	for ( TUint i = 0; !(foundIn && foundOut) && i < totalEndpoints; i++ )
   135 	for ( TUint i = 0; !(foundIn && foundOut) && i < totalEndpoints; i++ )
   143 		{
   136 		{
   144 		const TUsbcEndpointCaps* caps = &data[i].iCaps;
   137 		const TUsbcEndpointCaps* caps = &data[i].iCaps;
   145 		if (!caps)
   138 		__ASSERT_DEBUG(caps, 
   146 			{
   139 			_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   147 			OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP5, "CCdcDataInterface::SetUpInterface;caps=%p", caps );
       
   148 			__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   149 			}
       
   150 		if (data[i].iInUse)
   140 		if (data[i].iInUse)
   151 			continue;
   141 			continue;
   152 
   142 
   153 		//get the max packet size it can potentially support
   143 		//get the max packet size it can potentially support
   154 		//it's possible that it can support Isoch (1023) which is greater
   144 		//it's possible that it can support Isoch (1023) which is greater
   189 			}
   179 			}
   190 		}
   180 		}
   191 
   181 
   192 	if (! (foundIn && foundOut))
   182 	if (! (foundIn && foundOut))
   193 		{
   183 		{
   194 		OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP6, "CCdcDataInterface::SetUpInterface;ret=%d", KErrGeneral );
   184 		LOGTEXT2(_L8("<<CCdcDataInterface::SetUpInterface ret=%d"), 
   195 		OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT_DUP3 );
   185 			KErrGeneral);
   196 		return KErrGeneral;
   186 		return KErrGeneral;
   197 		}
   187 		}
   198 
   188 
   199 		// If the device supports USB High-speed, then we request 64KB buffers
   189 		// If the device supports USB High-speed, then we request 64KB buffers
   200 		// (otherwise the default 4KB ones will do).
   190 		// (otherwise the default 4KB ones will do).
   213 
   203 
   214 	// Indicate that this interface does not expect any control transfers 
   204 	// Indicate that this interface does not expect any control transfers 
   215 	// from EP0.
   205 	// from EP0.
   216 	ifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease;
   206 	ifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease;
   217 
   207 
   218 	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP7, "CCdcDataInterface::SetUpInterface;\tcalling SetInterface" );
   208 	LOGTEXT(_L8("\tcalling SetInterface"));
   219 	// Zero effectively indicates that alternate interfaces are not used.
   209 	// Zero effectively indicates that alternate interfaces are not used.
   220 	ret = iLdd.SetInterface(0, ifc, bandwidthPriority);
   210 	ret = iLdd.SetInterface(0, ifc, bandwidthPriority);
   221 
   211 
   222 	OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP8, "CCdcDataInterface::SetUpInterface;ret=%d", ret );
   212 	LOGTEXT2(_L8("<<CCdcDataInterface::SetUpInterface ret=%d"), ret);
   223 	OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT_DUP4 );
       
   224 	return ret;
   213 	return ret;
   225 	}
   214 	}
   226 
   215 
   227 
   216 
   228 void CCdcDataInterface::MLSOStateChange(TInt aPacketSize)
   217 void CCdcDataInterface::MLSOStateChange(TInt aPacketSize)
   229 	{
   218 	{
   230 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_MLSOSTATECHANGE_ENTRY );	
       
   231 	iPacketSize = aPacketSize;
   219 	iPacketSize = aPacketSize;
   232 	OstTraceFunctionExit0( CCDCDATAINTERFACE_MLSOSTATECHANGE_EXIT );
       
   233 	}
   220 	}
   234 
   221 
   235 
   222 
   236 CCdcDataInterface::~CCdcDataInterface()
   223 CCdcDataInterface::~CCdcDataInterface()
   237 /**
   224 /**
   238  * Destructor. Cancel and destroy the child classes.
   225  * Destructor. Cancel and destroy the child classes.
   239  */
   226  */
   240 	{
   227 	{
   241 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_CCDCDATAINTERFACE_DES_ENTRY );
   228 	LOG_FUNC
       
   229 
   242 	delete iLinkState;
   230 	delete iLinkState;
   243 	delete iReadOneOrMoreReader;
   231 	delete iReadOneOrMoreReader;
   244 	delete iReader;
   232 	delete iReader;
   245 	delete iWriter;
   233 	delete iWriter;
   246 	delete iDataAvailableNotifier;
   234 	delete iDataAvailableNotifier;
   247 	OstTraceFunctionExit0( CCDCDATAINTERFACE_CCDCDATAINTERFACE_DES_EXIT );
       
   248 	}
   235 	}
   249 
   236 
   250 void CCdcDataInterface::Write(MWriteObserver& aObserver, 
   237 void CCdcDataInterface::Write(MWriteObserver& aObserver, 
   251 						  const TDesC8& aDes, 
   238 						  const TDesC8& aDes, 
   252 						  TInt aLen)
   239 						  TInt aLen)
   256  * @param aObserver The observer to notify of completion.
   243  * @param aObserver The observer to notify of completion.
   257  * @param aDes Descriptor containing the data to be sent
   244  * @param aDes Descriptor containing the data to be sent
   258  * @param aLen Length of the data to be sent
   245  * @param aLen Length of the data to be sent
   259  */
   246  */
   260 	{
   247 	{
   261 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_WRITE_ENTRY );
   248 	LOG_FUNC
   262 	if (iWriteObserver)
   249 
   263 		{
   250 	__ASSERT_DEBUG(!iWriteObserver, 
   264 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_WRITE, "CCdcDataInterface::Write;iWriteObserver=%p", iWriteObserver );
   251 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   265 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
   252 
   266 		}
       
   267 	iWriteObserver = &aObserver;
   253 	iWriteObserver = &aObserver;
   268 	if (!iWriter)
   254 
   269 		{
   255 	__ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   270 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_WRITE_DUP1, "CCdcDataInterface::Write;iWriter=%p", iWriter );
       
   271 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   272 		}
       
   273 	
   256 	
   274 	if ( iHostCanHandleZLPs )
   257 	if ( iHostCanHandleZLPs )
   275 		{
   258 		{
   276 		
   259 		
   277 		// Make sure the driver sends a Zero Length Packet if required (i.e. if the 
   260 		// Make sure the driver sends a Zero Length Packet if required (i.e. if the 
   282 	else
   265 	else
   283 		{
   266 		{
   284 		iWriter->Write(aDes, aLen, EFalse); 
   267 		iWriter->Write(aDes, aLen, EFalse); 
   285 		}
   268 		}
   286 		
   269 		
   287 	OstTraceFunctionExit0( CCDCDATAINTERFACE_WRITE_EXIT );
   270 	LOGTEXT(_L8("<<CCdcDataInterface::Write"));
   288 	}
   271 	}
   289 
   272 
   290 void CCdcDataInterface::WriteCompleted(TInt aError)
   273 void CCdcDataInterface::WriteCompleted(TInt aError)
   291 /**
   274 /**
   292  * Called when a write request completes.
   275  * Called when a write request completes.
   293  *
   276  *
   294  * @param aError Error.
   277  * @param aError Error.
   295  */
   278  */
   296 	{
   279 	{
   297 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_WRITECOMPLETED_ENTRY );
   280 	LOGTEXT2(_L8(">>CCdcDataInterface::WriteCompleted aError=%d"), aError);
   298 	OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_WRITECOMPLETED, "CCdcDataInterface::WriteCompleted;aError=%d", aError );
       
   299 
   281 
   300 #ifdef __HEADLESS_ACM_TEST_CODE__
   282 #ifdef __HEADLESS_ACM_TEST_CODE__
   301 	// Issue another Read or ReadOneOrMore as appropriate.
   283 	// Issue another Read or ReadOneOrMore as appropriate.
   302 	// If the Write completed with an error, we panic, as it's invalidating 
   284 	// If the Write completed with an error, we panic, as it's invalidating 
   303 	// the test.
   285 	// the test.
   304 	if (aError != KErrNone)
   286 	__ASSERT_DEBUG(aError == KErrNone, 
   305 		{
   287 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   306 		OstTrace1( TRACE_FATAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP1, "CCdcDataInterface::WriteCompleted;aError=%d", aError );
       
   307 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   308 		}
       
   309 	switch ( iHeadlessReadType )
   288 	switch ( iHeadlessReadType )
   310 		{
   289 		{
   311 	case ERead:
   290 	case ERead:
   312 		OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP2, 
   291 		LOGTEXT2(_L8("__HEADLESS_ACM_TEST_CODE__- issuing Read for %d bytes"), 
   313 				"CCdcDataInterface::WriteCompleted;__HEADLESS_ACM_TEST_CODE__- issuing Read for %d bytes", iHeadlessReadLength );
   292 			iHeadlessReadLength);
   314 
   293 		__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   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 			}
       
   320 		iReader->Read(iHeadlessAcmBuffer, iHeadlessReadLength);
   294 		iReader->Read(iHeadlessAcmBuffer, iHeadlessReadLength);
   321 		break;
   295 		break;
   322 	case EReadOneOrMore:
   296 	case EReadOneOrMore:
   323 		OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP4, 
   297 		LOGTEXT2(_L8("__HEADLESS_ACM_TEST_CODE__- issuing ReadOneOrMore for %d bytes"), 
   324 				"CCdcDataInterface::WriteCompleted;__HEADLESS_ACM_TEST_CODE__- issuing ReadOneOrMore for %d bytes", iHeadlessReadLength );
   298 			iHeadlessReadLength);
   325 	
   299 		__ASSERT_DEBUG(iReadOneOrMoreReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   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 			}
       
   332 		iReadOneOrMoreReader->ReadOneOrMore(iHeadlessAcmBuffer, iHeadlessReadLength);
   300 		iReadOneOrMoreReader->ReadOneOrMore(iHeadlessAcmBuffer, iHeadlessReadLength);
   333 		break;
   301 		break;
   334 	case EUnknown:
   302 	case EUnknown:
   335 	default:
   303 	default:
   336 		OstTrace0( TRACE_FATAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP6, "CCdcDataInterface::WriteCompleted;EPanicInternalError" );
   304 		_USB_PANIC(KAcmPanicCat, EPanicInternalError);
   337 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   338 		break;
   305 		break;
   339 		}
   306 		}
   340 #else
   307 #else
   341 	// In case the write observer wants to post another write synchronously on 
   308 	// In case the write observer wants to post another write synchronously on 
   342 	// being informed that this write has completed, use this little 'temp' 
   309 	// being informed that this write has completed, use this little 'temp' 
   343 	// fiddle.
   310 	// fiddle.
   344 	if (!iWriteObserver)
   311 	__ASSERT_DEBUG(iWriteObserver, 
   345 		{
   312 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   346 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP7, 
       
   347 						"CCdcDataInterface::WriteCompleted;iWriteObserver=%p", iWriteObserver );
       
   348 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   349 		}
       
   350 	MWriteObserver* temp = iWriteObserver;
   313 	MWriteObserver* temp = iWriteObserver;
   351 	iWriteObserver = NULL;
   314 	iWriteObserver = NULL;
   352 	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_WRITECOMPLETED_DUP8, 
   315 	LOGTEXT(_L8("\tcalling WriteCompleted on observer"));
   353 				"CCdcDataInterface::WriteCompleted;\tcalling WriteCompleted on observer" );
       
   354 	temp->WriteCompleted(aError);
   316 	temp->WriteCompleted(aError);
   355 #endif // __HEADLESS_ACM_TEST_CODE__
   317 #endif // __HEADLESS_ACM_TEST_CODE__
   356 
   318 
   357 	OstTraceFunctionExit0( CCDCDATAINTERFACE_WRITECOMPLETED_EXIT );
   319 	LOGTEXT(_L8("<<CCdcDataInterface::WriteCompleted"));
   358 	}
   320 	}
   359 
   321 
   360 void CCdcDataInterface::CancelWrite()
   322 void CCdcDataInterface::CancelWrite()
   361 /**
   323 /**
   362  * Cancel an outstanding write request
   324  * Cancel an outstanding write request
   363  */
   325  */
   364 	{
   326 	{
   365 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_CANCELWRITE_ENTRY );
   327 	LOG_FUNC
   366 	if (!iWriter)
   328 	
   367 		{
   329 	__ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   368 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_CANCELWRITE, "CCdcDataInterface::CancelWrite;iWriter=%p", iWriter );
   330 
   369 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   370 		}
       
   371 	iWriter->Cancel();
   331 	iWriter->Cancel();
       
   332 
   372 	iWriteObserver = NULL;
   333 	iWriteObserver = NULL;
   373 	OstTraceFunctionExit0( CCDCDATAINTERFACE_CANCELWRITE_EXIT );
       
   374 	}
   334 	}
   375 
   335 
   376 void CCdcDataInterface::Read(MReadObserver& aObserver, 
   336 void CCdcDataInterface::Read(MReadObserver& aObserver, 
   377 							 TDes8& aDes, 
   337 							 TDes8& aDes, 
   378 							 TInt aMaxLen)
   338 							 TInt aMaxLen)
   383  * @param aObserver The observer to notify of completion.
   343  * @param aObserver The observer to notify of completion.
   384  * @param aDes Descriptor to put the read data in
   344  * @param aDes Descriptor to put the read data in
   385  * @param aMaxLen Number of bytes to read
   345  * @param aMaxLen Number of bytes to read
   386  */
   346  */
   387 	{
   347 	{
   388 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_READ_ENTRY );
   348 	LOG_FUNC
   389 	
   349 
   390 #ifdef __HEADLESS_ACM_TEST_CODE__
   350 #ifdef __HEADLESS_ACM_TEST_CODE__
   391 	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_READ, "CCdcDataInterface::Read;__HEADLESS_ACM_TEST_CODE__" );
   351 	LOGTEXT(_L8("__HEADLESS_ACM_TEST_CODE__"));
   392 	// Issue a Read using our special internal buffer.
   352 	// Issue a Read using our special internal buffer.
   393 	iHeadlessReadType = ERead;
   353 	iHeadlessReadType = ERead;
   394 	iHeadlessReadLength = aMaxLen;
   354 	iHeadlessReadLength = aMaxLen;
   395 	static_cast<void>(&aObserver);
   355 	static_cast<void>(&aObserver);
   396 	static_cast<void>(&aDes);
   356 	static_cast<void>(&aDes);
   397 	if (aMaxLen > iHeadlessAcmBuffer.MaxLength())
   357 	__ASSERT_DEBUG(aMaxLen <= iHeadlessAcmBuffer.MaxLength(), 
   398 		{
   358 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   399 		OstTrace1( TRACE_FATAL, CCDCDATAINTERFACE_READ_DUP1, "CCdcDataInterface::Read;aMaxLen=%d", aMaxLen );
   359 	__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   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 		}
       
   407 	iReader->Read(iHeadlessAcmBuffer, aMaxLen);
   360 	iReader->Read(iHeadlessAcmBuffer, aMaxLen);
   408 #else
   361 #else
   409 	if (iReadObserver)
   362 	__ASSERT_DEBUG(!iReadObserver, 
   410 		{
   363 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   411 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READ_DUP3, "CCdcDataInterface::Read;iReadObserver=%p", iReadObserver );
       
   412 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   413 		}
       
   414 	iReadObserver = &aObserver;
   364 	iReadObserver = &aObserver;
   415 	if (!iReader)
   365 
   416 		{
   366 	__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   417 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READ_DUP4, "CCdcDataInterface::Read;iReader=%p", iReader );
       
   418 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   419 		}
       
   420 	
       
   421 	iReader->Read(aDes, aMaxLen);
   367 	iReader->Read(aDes, aMaxLen);
   422 #endif // __HEADLESS_ACM_TEST_CODE__
   368 #endif // __HEADLESS_ACM_TEST_CODE__
   423 	OstTraceFunctionExit0( CCDCDATAINTERFACE_READ_EXIT );
       
   424 	}
   369 	}
   425 
   370 
   426 void CCdcDataInterface::ReadOneOrMore(MReadOneOrMoreObserver& aObserver, 
   371 void CCdcDataInterface::ReadOneOrMore(MReadOneOrMoreObserver& aObserver, 
   427 								  TDes8& aDes, 
   372 								  TDes8& aDes, 
   428 								  TInt aMaxLen)
   373 								  TInt aMaxLen)
   433  * @param aObserver The observer to notify of completion.
   378  * @param aObserver The observer to notify of completion.
   434  * @param aDes Descriptor to put the read data in
   379  * @param aDes Descriptor to put the read data in
   435  * @param aMaxLen Number of bytes to read
   380  * @param aMaxLen Number of bytes to read
   436  */
   381  */
   437 	{
   382 	{
   438 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_READONEORMORE_ENTRY );
   383 	LOG_FUNC
   439 	
       
   440 
   384 
   441 #ifdef __HEADLESS_ACM_TEST_CODE__
   385 #ifdef __HEADLESS_ACM_TEST_CODE__
   442 	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_READONEORMORE, "CCdcDataInterface::ReadOneOrMore;__HEADLESS_ACM_TEST_CODE__" );
   386 	LOGTEXT(_L8("__HEADLESS_ACM_TEST_CODE__"));
   443 	// Issue a ReadOneOrMore using our special internal buffer.
   387 	// Issue a ReadOneOrMore using our special internal buffer.
   444 	iHeadlessReadType = EReadOneOrMore;
   388 	iHeadlessReadType = EReadOneOrMore;
   445 	iHeadlessReadLength = aMaxLen;
   389 	iHeadlessReadLength = aMaxLen;
   446 	static_cast<void>(&aObserver);
   390 	static_cast<void>(&aObserver);
   447 	static_cast<void>(&aDes);
   391 	static_cast<void>(&aDes);
   448 	if (aMaxLen > iHeadlessAcmBuffer.MaxLength())
   392 	__ASSERT_DEBUG(aMaxLen <= iHeadlessAcmBuffer.MaxLength(), 
   449 		{
   393 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   450 		OstTrace1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORE_DUP1, "CCdcDataInterface::ReadOneOrMore;aMaxLen=%d", aMaxLen );
   394 	__ASSERT_DEBUG(iReadOneOrMoreReader, 
   451 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
   395 		_USB_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 		}
       
   459 	iReadOneOrMoreReader->ReadOneOrMore(iHeadlessAcmBuffer, aMaxLen);
   396 	iReadOneOrMoreReader->ReadOneOrMore(iHeadlessAcmBuffer, aMaxLen);
   460 #else
   397 #else
   461 	if (iReadOneOrMoreObserver)
   398 	__ASSERT_DEBUG(!iReadOneOrMoreObserver, 
   462 		{
   399 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   463 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORE_DUP3, 
       
   464 						"CCdcDataInterface::ReadOneOrMore;iReadOneOrMoreObserver=%p", iReadOneOrMoreObserver );
       
   465 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   466 		}
       
   467 	iReadOneOrMoreObserver = &aObserver;
   400 	iReadOneOrMoreObserver = &aObserver;
   468 	if (!iReadOneOrMoreReader)
   401 
   469 		{
   402 	__ASSERT_DEBUG(iReadOneOrMoreReader, 
   470 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORE_DUP4, 
   403 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   471 						"CCdcDataInterface::ReadOneOrMore;iReadOneOrMoreObserver=%p", iReadOneOrMoreObserver );
       
   472 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   473 		}
       
   474 	iReadOneOrMoreReader->ReadOneOrMore(aDes, aMaxLen);
   404 	iReadOneOrMoreReader->ReadOneOrMore(aDes, aMaxLen);
   475 #endif // __HEADLESS_ACM_TEST_CODE__
   405 #endif // __HEADLESS_ACM_TEST_CODE__
   476 	OstTraceFunctionExit0( CCDCDATAINTERFACE_READONEORMORE_EXIT );
       
   477 	}
   406 	}
   478 
   407 
   479 void CCdcDataInterface::ReadOneOrMoreCompleted(TInt aError)
   408 void CCdcDataInterface::ReadOneOrMoreCompleted(TInt aError)
   480 /**
   409 /**
   481  * The completion function, called when a ReadOneOrMore request is completed 
   410  * The completion function, called when a ReadOneOrMore request is completed 
   482  * by the LDD.
   411  * by the LDD.
   483  *
   412  *
   484  * @param aError The result of the read request.
   413  * @param aError The result of the read request.
   485  */
   414  */
   486 	{
   415 	{
   487 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_READONEORMORECOMPLETED_ENTRY );
   416 	LOGTEXT2(_L8(">>CCdcDataInterface::ReadOneOrMoreCompleted aError=%d"), 
   488 	OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_READONEORMORECOMPLETED, "CCdcDataInterface::ReadOneOrMoreCompleted;aError=%d", aError );
   417 		aError);
   489 
   418 
   490 #ifdef __HEADLESS_ACM_TEST_CODE__
   419 #ifdef __HEADLESS_ACM_TEST_CODE__
   491 	OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_READONEORMORECOMPLETED_DUP1, 
   420 	LOGTEXT2(_L8("__HEADLESS_ACM_TEST_CODE__- issuing Write for %d bytes"),
   492 			"CCdcDataInterface::ReadOneOrMoreCompleted;__HEADLESS_ACM_TEST_CODE__- issuing Write for %d bytes", iHeadlessAcmBuffer.Length() );
   421 		iHeadlessAcmBuffer.Length());
   493 
       
   494 	// Write back the data just read.
   422 	// Write back the data just read.
   495 	// If the ReadOneOrMore completed with an error, we panic, as it's 
   423 	// If the ReadOneOrMore completed with an error, we panic, as it's 
   496 	// invalidating the test.
   424 	// invalidating the test.
   497 	if (aError != KErrNone)
   425 	__ASSERT_DEBUG(aError == KErrNone, 
   498 		{
   426 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   499 		OstTrace1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORECOMPLETED_DUP2, 
   427 	__ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   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 		}
       
   510 	iWriter->Write(iHeadlessAcmBuffer, iHeadlessAcmBuffer.Length(), EFalse); 
   428 	iWriter->Write(iHeadlessAcmBuffer, iHeadlessAcmBuffer.Length(), EFalse); 
   511 #else
   429 #else
   512 	if (!iReadOneOrMoreObserver)
   430 	__ASSERT_DEBUG(iReadOneOrMoreObserver, 
   513 		{
   431 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   514 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READONEORMORECOMPLETED_DUP4, 
       
   515 							"CCdcDataInterface::ReadOneOrMoreCompleted;iReadOneOrMoreObserver=%p", iReadOneOrMoreObserver );
       
   516 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   517 		}
       
   518 
   432 
   519 	// See comment in WriteCompleted.
   433 	// See comment in WriteCompleted.
   520 	MReadOneOrMoreObserver* temp = iReadOneOrMoreObserver;
   434 	MReadOneOrMoreObserver* temp = iReadOneOrMoreObserver;
   521 	iReadOneOrMoreObserver = NULL;
   435 	iReadOneOrMoreObserver = NULL;
   522 	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_READONEORMORECOMPLETED_DUP5, 
   436 	LOGTEXT(_L8("\tcalling ReadOneOrMoreCompleted on observer"));
   523 			"CCdcDataInterface::ReadOneOrMoreCompleted;\tcalling ReadOneOrMoreCompleted on observer" );
       
   524 	temp->ReadOneOrMoreCompleted(aError);
   437 	temp->ReadOneOrMoreCompleted(aError);
   525 #endif // __HEADLESS_ACM_TEST_CODE__
   438 #endif // __HEADLESS_ACM_TEST_CODE__
   526 
   439 
   527 	OstTraceFunctionExit0( CCDCDATAINTERFACE_READONEORMORECOMPLETED_EXIT );
   440 	LOGTEXT(_L8("<<CCdcDataInterface::ReadOneOrMoreCompleted"));
   528 	}
   441 	}
   529 
   442 
   530 void CCdcDataInterface::ReadCompleted(TInt aError)
   443 void CCdcDataInterface::ReadCompleted(TInt aError)
   531 /**
   444 /**
   532  * Called by the active reader object when it completes.
   445  * Called by the active reader object when it completes.
   533  *
   446  *
   534  * @param aError Error.
   447  * @param aError Error.
   535  */
   448  */
   536 	{
   449 	{
   537 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_READCOMPLETED_ENTRY );
   450 	LOGTEXT2(_L8(">>CCdcDataInterface::ReadCompleted aError=%d"), aError);
   538 	OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_READCOMPLETED, "CCdcDataInterface::ReadCompleted;aError=%d", aError );
       
   539 
   451 
   540 #ifdef __HEADLESS_ACM_TEST_CODE__
   452 #ifdef __HEADLESS_ACM_TEST_CODE__
   541 	OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_READCOMPLETED_DUP1, 
   453 	LOGTEXT2(_L8("__HEADLESS_ACM_TEST_CODE__- issuing Write for %d bytes"),
   542 			"CCdcDataInterface::ReadCompleted;__HEADLESS_ACM_TEST_CODE__- issuing Write for %d bytes", iHeadlessAcmBuffer.Length() );
   454 		iHeadlessAcmBuffer.Length());
   543 	
       
   544 	// Write back the data just read.
   455 	// Write back the data just read.
   545 	// If the Read completed with an error, we panic, as it's invalidating the 
   456 	// If the Read completed with an error, we panic, as it's invalidating the 
   546 	// test.				 
   457 	// test.				 
   547 	if (aError != KErrNone)
   458 	__ASSERT_DEBUG(aError == KErrNone,
   548 		{
   459 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   549 		OstTrace1( TRACE_FATAL, CCDCDATAINTERFACE_READCOMPLETED_DUP2, "CCdcDataInterface::ReadCompleted;aError=%d", aError );
   460 	__ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   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 		}
       
   558 	iWriter->Write(iHeadlessAcmBuffer, iHeadlessAcmBuffer.Length(), EFalse); 
   461 	iWriter->Write(iHeadlessAcmBuffer, iHeadlessAcmBuffer.Length(), EFalse); 
   559 #else
   462 #else
   560 	if (!iReadObserver)
   463 	__ASSERT_DEBUG(iReadObserver, 
   561 		{
   464 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   562 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_READCOMPLETED_DUP4, 
       
   563 							"CCdcDataInterface::ReadCompleted;iReadObserver=%p", iReadObserver );
       
   564 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   565 		}
       
   566 
   465 
   567 	// See comment in WriteCompleted.
   466 	// See comment in WriteCompleted.
   568 	MReadObserver* temp = iReadObserver;
   467 	MReadObserver* temp = iReadObserver;
   569 	iReadObserver = NULL;
   468 	iReadObserver = NULL;
   570 	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_READCOMPLETED_DUP5, "CCdcDataInterface::ReadCompleted;\tcalled ReadCompleted on observer" );
   469 	LOGTEXT(_L8("\tcalled ReadCompleted on observer"));
   571 	temp->ReadCompleted(aError);
   470 	temp->ReadCompleted(aError);
   572 #endif // __HEADLESS_ACM_TEST_CODE__
   471 #endif // __HEADLESS_ACM_TEST_CODE__
   573 
   472 
   574 	OstTraceFunctionExit0( CCDCDATAINTERFACE_READCOMPLETED_EXIT );
   473 	LOGTEXT(_L8("<<CCdcDataInterface::ReadCompleted"));
   575 	}
   474 	}
   576 
   475 
   577 void CCdcDataInterface::CancelRead()
   476 void CCdcDataInterface::CancelRead()
   578 /**
   477 /**
   579  * Cancel an outstanding read request
   478  * Cancel an outstanding read request
   580  */
   479  */
   581 	{
   480 	{
   582 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_CANCELREAD_ENTRY );
   481 	LOG_FUNC
   583 	if (!iReader)
   482 
   584 		{
   483 	__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   585 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_CANCELREAD, "CCdcDataInterface::CancelRead;iReader=%p", iReader );
   484 	__ASSERT_DEBUG(iReadOneOrMoreReader, 
   586 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
   485 		_USB_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 		}
       
   594 
   486 
   595 	iReader->Cancel();
   487 	iReader->Cancel();
   596 	iReadOneOrMoreReader->Cancel();
   488 	iReadOneOrMoreReader->Cancel();
   597 	iReadObserver = NULL;
   489 	iReadObserver = NULL;
   598 	iReadOneOrMoreObserver = NULL;
   490 	iReadOneOrMoreObserver = NULL;
   599 	OstTraceFunctionExit0( CCDCDATAINTERFACE_CANCELREAD_EXIT );
       
   600 	}
   491 	}
   601 
   492 
   602 	
   493 	
   603 void CCdcDataInterface::NotifyDataAvailableCompleted(TInt aError)
   494 void CCdcDataInterface::NotifyDataAvailableCompleted(TInt aError)
   604 /**
   495 /**
   605  * Called by the active data available notifier object when it completes.
   496  * Called by the active data available notifier object when it completes.
   606  *
   497  *
   607  * @param aError Error.
   498  * @param aError Error.
   608  */
   499  */
   609 	{
   500 	{
   610 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_NOTIFYDATAAVAILABLECOMPLETED_ENTRY );
   501 	LOGTEXT2(_L8(">>CCdcDataInterface::NotifyDataAvailableCompleted aError=%d"), aError);	
   611 	OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_NOTIFYDATAAVAILABLECOMPLETED, 
       
   612 			"CCdcDataInterface::NotifyDataAvailableCompleted;aError=%d", aError );	
       
   613 	
   502 	
   614 	// See comment in WriteCompleted.
   503 	// See comment in WriteCompleted.
   615 	MNotifyDataAvailableObserver* temp = iNotifyDataAvailableObserver;
   504 	MNotifyDataAvailableObserver* temp = iNotifyDataAvailableObserver;
   616 	iNotifyDataAvailableObserver = NULL;
   505 	iNotifyDataAvailableObserver = NULL;
   617 	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_NOTIFYDATAAVAILABLECOMPLETED_DUP1, 
   506 	LOGTEXT(_L8("\tcalled NotifyDataAvailableCompleted on observer"));
   618 			"CCdcDataInterface::NotifyDataAvailableCompleted;\tcalled NotifyDataAvailableCompleted on observer" );
       
   619 	temp->NotifyDataAvailableCompleted(aError);
   507 	temp->NotifyDataAvailableCompleted(aError);
   620 	OstTraceFunctionExit0( CCDCDATAINTERFACE_NOTIFYDATAAVAILABLECOMPLETED_EXIT );
   508 	
       
   509 	LOGTEXT(_L8("<<CCdcDataInterface::NotifyDataAvailableCompleted"));
   621 	}
   510 	}
   622 	
   511 	
   623 void CCdcDataInterface::NotifyDataAvailable(MNotifyDataAvailableObserver& aObserver)
   512 void CCdcDataInterface::NotifyDataAvailable(MNotifyDataAvailableObserver& aObserver)
   624 /**
   513 /**
   625  * Complete if any data arrives.
   514  * Complete if any data arrives.
   626  *
   515  *
   627  * @param aObserver The observer to notify of completion.
   516  * @param aObserver The observer to notify of completion.
   628  */
   517  */
   629 	{
   518 	{
   630 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_NOTIFYDATAAVAILABLE_ENTRY );
   519 	LOG_FUNC
   631 	
   520 		
   632 	if (iNotifyDataAvailableObserver)
   521 	__ASSERT_DEBUG(!iNotifyDataAvailableObserver, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   633 		{
       
   634 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_NOTIFYDATAAVAILABLE, 
       
   635 							"CCdcDataInterface::NotifyDataAvailable;iNotifyDataAvailableObserver=%p", iNotifyDataAvailableObserver );
       
   636 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   637 		}
       
   638 	iNotifyDataAvailableObserver = &aObserver;
   522 	iNotifyDataAvailableObserver = &aObserver;
   639 	if (!iDataAvailableNotifier)
   523 
   640 		{
   524 	__ASSERT_DEBUG(iDataAvailableNotifier, 
   641 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_NOTIFYDATAAVAILABLE_DUP1, 
   525 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   642 						"CCdcDataInterface::NotifyDataAvailable;iDataAvailableNotifier=%p", iDataAvailableNotifier );
       
   643 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   644 		}
       
   645 	iDataAvailableNotifier->NotifyDataAvailable();
   526 	iDataAvailableNotifier->NotifyDataAvailable();
   646 	OstTraceFunctionExit0( CCDCDATAINTERFACE_NOTIFYDATAAVAILABLE_EXIT );
       
   647 	}
   527 	}
   648 
   528 
   649 void CCdcDataInterface::CancelNotifyDataAvailable()
   529 void CCdcDataInterface::CancelNotifyDataAvailable()
   650 /**
   530 /**
   651  * Cancel notification of arrival of data.
   531  * Cancel notification of arrival of data.
   652  */
   532  */
   653 	{
   533 	{
   654 	OstTraceFunctionEntry0( CCDCDATAINTERFACE_CANCELNOTIFYDATAAVAILABLE_ENTRY );
   534 	LOG_FUNC
   655 	if (!iDataAvailableNotifier)
   535 
   656 		{
   536 	__ASSERT_DEBUG(iDataAvailableNotifier, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   657 		OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_CANCELNOTIFYDATAAVAILABLE, 
   537 
   658 						"CCdcDataInterface::CancelNotifyDataAvailable;iDataAvailableNotifier=%p", iDataAvailableNotifier );
       
   659 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   660 		}
       
   661 	iDataAvailableNotifier->Cancel();
   538 	iDataAvailableNotifier->Cancel();
   662 	iNotifyDataAvailableObserver = NULL;	
   539 	iNotifyDataAvailableObserver = NULL;	
   663 	OstTraceFunctionExit0( CCDCDATAINTERFACE_CANCELNOTIFYDATAAVAILABLE_EXIT );
       
   664 	}
   540 	}
   665 
   541 
   666 //
   542 //
   667 // End of file
   543 // End of file