usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/AcmPort.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".
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <acminterface.h>
    18 #include <acminterface.h>
       
    19 #include <usb/usblogger.h>
    19 #include "AcmPort.h"
    20 #include "AcmPort.h"
    20 #include "AcmPortFactory.h"
    21 #include "AcmPortFactory.h"
    21 #include "AcmUtils.h"
    22 #include "AcmUtils.h"
    22 #include "AcmWriter.h"
    23 #include "AcmWriter.h"
    23 #include "AcmReader.h"
    24 #include "AcmReader.h"
    24 #include "AcmPanic.h"
    25 #include "AcmPanic.h"
    25 #include "OstTraceDefinitions.h"
    26 
    26 #ifdef OST_TRACE_COMPILER_IN_USE
    27 #ifdef __FLOG_ACTIVE
    27 #include "AcmPortTraces.h"
    28 _LIT8(KLogComponent, "ECACM");
    28 #endif
    29 #endif
    29 
    30 
    30 const TUint KCapsRate=(   KCapsBps50
    31 const TUint KCapsRate=(   KCapsBps50
    31 						| KCapsBps75
    32 						| KCapsBps75
    32 						| KCapsBps110
    33 						| KCapsBps110
    91  * closes.
    92  * closes.
    92  * @param aUnit The port number.
    93  * @param aUnit The port number.
    93  * @return Ownership of a newly created CAcmPort object
    94  * @return Ownership of a newly created CAcmPort object
    94  */
    95  */
    95 	{
    96 	{
    96 	OstTraceFunctionEntry0( CACMPORT_NEWL_ENTRY );
    97 	LOG_STATIC_FUNC_ENTRY
    97 	
    98 
    98 	CAcmPort* self = new(ELeave) CAcmPort(aUnit, aFactory);
    99 	CAcmPort* self = new(ELeave) CAcmPort(aUnit, aFactory);
    99 	CleanupClosePushL(*self);
   100 	CleanupClosePushL(*self);
   100 	self->ConstructL();
   101 	self->ConstructL();
   101 	CleanupStack::Pop();
   102 	CleanupStack::Pop();
   102 	OstTraceFunctionExit0( CACMPORT_NEWL_EXIT );
       
   103 	return self;
   103 	return self;
   104 	}
   104 	}
   105 
   105 
   106 void CAcmPort::ConstructL()
   106 void CAcmPort::ConstructL()
   107 /**
   107 /**
   108  * Standard second phase constructor. Create owned classes and initialise the 
   108  * Standard second phase constructor. Create owned classes and initialise the 
   109  * port.
   109  * port.
   110  */
   110  */
   111 	{
   111 	{
   112 	OstTraceFunctionEntry0( CACMPORT_CONSTRUCTL_ENTRY );
       
   113 	
       
   114 	iReader = CAcmReader::NewL(*this, KDefaultBufferSize);
   112 	iReader = CAcmReader::NewL(*this, KDefaultBufferSize);
   115 	iWriter = CAcmWriter::NewL(*this, KDefaultBufferSize);
   113 	iWriter = CAcmWriter::NewL(*this, KDefaultBufferSize);
   116 
   114 
   117 	TName name;
   115 	TName name;
   118 	TInt	err;
       
   119 	name.Num(iUnit);
   116 	name.Num(iUnit);
   120 	err = SetName(&name);
   117 	LEAVEIFERRORL(SetName(&name));
   121 	if (err < 0)
       
   122 		{
       
   123 		OstTrace1( TRACE_FATAL, CACMPORT_CONSTRUCTL, "CAcmPort::ConstructL;err=%d", err );
       
   124 		User::Leave(err);
       
   125 		}
       
   126 
   118 
   127 	iCommServerConfig.iBufFlags = 0;
   119 	iCommServerConfig.iBufFlags = 0;
   128 	iCommServerConfig.iBufSize = iReader->BufSize();
   120 	iCommServerConfig.iBufSize = iReader->BufSize();
   129 
   121 
   130 	iCommConfig.iRate			= KDefaultDataRate;
   122 	iCommConfig.iRate			= KDefaultDataRate;
   139 	iCommConfig.iXonChar		= KDefaultXon;
   131 	iCommConfig.iXonChar		= KDefaultXon;
   140 	iCommConfig.iXoffChar		= KDefaultXoff;
   132 	iCommConfig.iXoffChar		= KDefaultXoff;
   141 	iCommConfig.iParityErrorChar= 0;
   133 	iCommConfig.iParityErrorChar= 0;
   142 	iCommConfig.iSIREnable		= ESIRDisable;
   134 	iCommConfig.iSIREnable		= ESIRDisable;
   143 	iCommConfig.iSIRSettings	= 0;
   135 	iCommConfig.iSIRSettings	= 0;
   144 	OstTraceFunctionExit0( CACMPORT_CONSTRUCTL_EXIT );
       
   145 	}
   136 	}
   146 
   137 
   147 CAcmPort::CAcmPort(const TUint aUnit, MAcmPortObserver& aObserver) 
   138 CAcmPort::CAcmPort(const TUint aUnit, MAcmPortObserver& aObserver) 
   148  :	iCommNotification(iCommNotificationDes()),
   139  :	iCommNotification(iCommNotificationDes()),
   149 	iObserver(aObserver),
   140 	iObserver(aObserver),
   154  * @param aObserver The observer of the port, to be notified when the port 
   145  * @param aObserver The observer of the port, to be notified when the port 
   155  * closes.
   146  * closes.
   156  * @param aUnit The port number.
   147  * @param aUnit The port number.
   157  */
   148  */
   158 	{
   149 	{
   159 	OstTraceFunctionEntry0( CACMPORT_CACMPORT_CONS_ENTRY );
       
   160 	OstTraceFunctionExit0( CACMPORT_CACMPORT_DES_EXIT );
       
   161 	}
   150 	}
   162 
   151 
   163 void CAcmPort::StartRead(const TAny* aClientBuffer, TInt aLength)
   152 void CAcmPort::StartRead(const TAny* aClientBuffer, TInt aLength)
   164 /**
   153 /**
   165  * Downcall from C32. Queue a read.
   154  * Downcall from C32. Queue a read.
   166  *
   155  *
   167  * @param aClientBuffer pointer to the client's buffer
   156  * @param aClientBuffer pointer to the client's buffer
   168  * @param aLength number of bytes to read
   157  * @param aLength number of bytes to read
   169  */
   158  */
   170 	{
   159 	{
   171 	OstTraceFunctionEntry0( CACMPORT_STARTREAD_ENTRY );
   160 	LOG_LINE
   172 	OstTraceExt2( TRACE_NORMAL, CACMPORT_STARTREAD, "CAcmPort::StartRead;aClientBuffer=%p;aLength=%d", aClientBuffer, aLength );
   161 	LOG_FUNC
   173 
   162 	LOGTEXT3(_L8("\taClientBuffer=0x%08x, aLength=%d"),
   174 	if ( !iAcm )
   163 		aClientBuffer, aLength);
   175 		{
   164 
   176 		OstTrace0( TRACE_NORMAL, CACMPORT_STARTREAD_DUP1, "CAcmPort::StartRead;\t***access denied" );
   165 	if ( !iAcm )
       
   166 		{
       
   167 		LOGTEXT(_L8("\t***access denied"));
   177 		ReadCompleted(KErrAccessDenied);
   168 		ReadCompleted(KErrAccessDenied);
   178 		OstTraceFunctionExit0( CACMPORT_STARTREAD_EXIT );
       
   179 		return;
   169 		return;
   180 		}
   170 		}
   181 
   171 
   182 	// Analyse the request and call the relevant API on the data reader. NB We 
   172 	// Analyse the request and call the relevant API on the data reader. NB We 
   183 	// do not pass requests for zero bytes to the data reader. They are an 
   173 	// do not pass requests for zero bytes to the data reader. They are an 
   184 	// RComm oddity we should handle here.
   174 	// RComm oddity we should handle here.
   185 	if (!iReader)
   175 	__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   186 		{
       
   187 		OstTraceExt1( TRACE_FATAL, CACMPORT_STARTREAD_DUP3, "CAcmPort::StartRead;iReader=%p", iReader );
       
   188 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   189 		}
       
   190 
   176 
   191 	if(iReader->IsNotifyDataAvailableQueryPending())
   177 	if(iReader->IsNotifyDataAvailableQueryPending())
   192 		{
   178 		{
   193 		ReadCompleted(KErrInUse);
   179 		ReadCompleted(KErrInUse);
   194 		OstTraceFunctionExit0( CACMPORT_STARTREAD_EXIT_DUP1 );
       
   195 		return;
   180 		return;
   196 		}
   181 		}
   197 
   182 
   198 	if ( aLength < 0 )
   183 	if ( aLength < 0 )
   199 		{
   184 		{
   205 		}
   190 		}
   206 	else
   191 	else
   207 		{
   192 		{
   208 		// Obscure RComm API feature- complete zero-length Read immediately, 
   193 		// Obscure RComm API feature- complete zero-length Read immediately, 
   209 		// to indicate that the hardware is powered up.
   194 		// to indicate that the hardware is powered up.
   210 		OstTrace0( TRACE_NORMAL, CACMPORT_STARTREAD_DUP2, "CAcmPort::StartRead;\tcompleting immediately with KErrNone" );
   195 		LOGTEXT(_L8("\tcompleting immediately with KErrNone"));
   211 		ReadCompleted(KErrNone);
   196 		ReadCompleted(KErrNone);
   212 		}
   197 		}
   213 	OstTraceFunctionExit0( CACMPORT_STARTREAD_EXIT_DUP2 );
       
   214 	}
   198 	}
   215 
   199 
   216 void CAcmPort::ReadCancel()
   200 void CAcmPort::ReadCancel()
   217 /**
   201 /**
   218  * Downcall from C32. Cancel a read.
   202  * Downcall from C32. Cancel a read.
   219  */
   203  */
   220 	{
   204 	{
   221 	OstTraceFunctionEntry0( CACMPORT_READCANCEL_ENTRY );
   205 	LOG_LINE
   222 	if ( !iAcm )
   206 	LOG_FUNC
   223 		{
   207 
   224 		OstTrace0( TRACE_NORMAL, CACMPORT_READCANCEL, "CAcmPort::ReadCancel;\t***access denied" );
   208 	if ( !iAcm )
   225 		OstTraceFunctionExit0( CACMPORT_READCANCEL_EXIT );
   209 		{
       
   210 		LOGTEXT(_L8("\t***access denied"));
   226 		return;
   211 		return;
   227 		}
   212 		}
   228 
   213 
   229 	if (!iReader)
   214 	__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   230 		{
       
   231 		OstTraceExt1( TRACE_FATAL, CACMPORT_READCANCEL_DUP1, "CAcmPort::ReadCancel;iReader=%p", iReader );
       
   232 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   233 		}
       
   234 	iReader->ReadCancel();
   215 	iReader->ReadCancel();
   235 	OstTraceFunctionExit0( CACMPORT_READCANCEL_EXIT_DUP1 );
       
   236 	}
   216 	}
   237 
   217 
   238 TInt CAcmPort::QueryReceiveBuffer(TInt& aLength) const
   218 TInt CAcmPort::QueryReceiveBuffer(TInt& aLength) const
   239 /**
   219 /**
   240  * Downcall from C32. Get the amount of data in the receive buffer.
   220  * Downcall from C32. Get the amount of data in the receive buffer.
   241  *
   221  *
   242  * @param aLength reference to where the amount will be written to
   222  * @param aLength reference to where the amount will be written to
   243  * @return Error.
   223  * @return Error.
   244  */
   224  */
   245 	{
   225 	{
   246 	OstTraceFunctionEntry0( CACMPORT_QUERYRECEIVEBUFFER_ENTRY );
   226 	LOG_LINE
       
   227 	LOG_FUNC
   247 	
   228 	
   248 	if ( !iAcm )
   229 	if ( !iAcm )
   249 		{
   230 		{
   250 		OstTrace0( TRACE_NORMAL, CACMPORT_QUERYRECEIVEBUFFER, "CAcmPort::QueryReceiveBuffer;\t***access denied" );
   231 		LOGTEXT(_L8("\t***access denied"));
   251 		OstTraceFunctionExit0( CACMPORT_QUERYRECEIVEBUFFER_EXIT );
       
   252 		return KErrAccessDenied;
   232 		return KErrAccessDenied;
   253 		}
   233 		}
   254 
   234 
   255 	if (!iReader)
   235 	__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   256 		{
       
   257 		OstTraceExt1( TRACE_FATAL, CACMPORT_QUERYRECEIVEBUFFER_DUP2, "CAcmPort::QueryReceiveBuffer;iReader=%p", iReader );
       
   258 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   259 		}
       
   260 	aLength = static_cast<TInt>(iReader->BufLen());
   236 	aLength = static_cast<TInt>(iReader->BufLen());
   261 	OstTrace1( TRACE_NORMAL, CACMPORT_QUERYRECEIVEBUFFER_DUP1, "CAcmPort::QueryReceiveBuffer;aLength=%d", aLength );
   237 	LOGTEXT2(_L8("\tlength=%d"), aLength);
   262 	OstTraceFunctionExit0( CACMPORT_QUERYRECEIVEBUFFER_EXIT_DUP1 );
       
   263 	return KErrNone;
   238 	return KErrNone;
   264 	}
   239 	}
   265 
   240 
   266 void CAcmPort::ResetBuffers(TUint aFlags)
   241 void CAcmPort::ResetBuffers(TUint aFlags)
   267 /**
   242 /**
   268  * Downcall from C32. Reset zero or more of the Tx and Rx buffers.
   243  * Downcall from C32. Reset zero or more of the Tx and Rx buffers.
   269  *
   244  *
   270  * @param aFlags Flags indicating which buffer(s) to reset.
   245  * @param aFlags Flags indicating which buffer(s) to reset.
   271  */
   246  */
   272 	{
   247 	{
   273 	OstTraceFunctionEntry0( CACMPORT_RESETBUFFERS_ENTRY );
   248 	LOG_LINE
   274 	OstTrace1( TRACE_NORMAL, CACMPORT_RESETBUFFERS, "CAcmPort::ResetBuffers;aFlags=%d", aFlags );
   249 	LOGTEXT2(_L8(">>CAcmPort::ResetBuffers aFlags = %d"), aFlags);
   275 
   250 
   276 	if ( aFlags & KCommResetRx )
   251 	if ( aFlags & KCommResetRx )
   277 		{
   252 		{
   278 		OstTrace0( TRACE_NORMAL, CACMPORT_RESETBUFFERS_DUP1, "CAcmPort::ResetBuffers;\tresetting Rx buffer" );
   253 		LOGTEXT(_L8("\tresetting Rx buffer"));
   279 		if (!iReader)
   254 		__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   280 			{
       
   281 			OstTraceExt1( TRACE_FATAL, CACMPORT_RESETBUFFERS_DUP3, "CAcmPort::ResetBuffers;iReader=%p", iReader );
       
   282 			__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   283 			}
       
   284 		iReader->ResetBuffer();
   255 		iReader->ResetBuffer();
   285 		}
   256 		}
   286 
   257 
   287 	if ( aFlags & KCommResetTx )
   258 	if ( aFlags & KCommResetTx )
   288 		{
   259 		{
   289 		OstTrace0( TRACE_NORMAL, CACMPORT_RESETBUFFERS_DUP2, "CAcmPort::ResetBuffers;\tresetting Tx buffer" );
   260 		LOGTEXT(_L8("\tresetting Tx buffer"));
   290 		if (!iWriter)
   261 		__ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   291 			{
       
   292 			OstTraceExt1( TRACE_FATAL, CACMPORT_RESETBUFFERS_DUP4, "CAcmPort::ResetBuffers;iWriter=%p", iWriter );
       
   293 			__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   294 			}
       
   295 		iWriter->ResetBuffer();
   262 		iWriter->ResetBuffer();
   296 		}
   263 		}
   297 
   264 
   298 	OstTraceFunctionExit0( CACMPORT_RESETBUFFERS_EXIT );
   265 	LOGTEXT(_L8("<<CAcmPort::ResetBuffers"));
   299 	}
   266 	}
   300 
   267 
   301 void CAcmPort::StartWrite(const TAny* aClientBuffer, TInt aLength)
   268 void CAcmPort::StartWrite(const TAny* aClientBuffer, TInt aLength)
   302 /**
   269 /**
   303  * Downcall from C32. Queue a write
   270  * Downcall from C32. Queue a write
   304  *
   271  *
   305  * @param aClientBuffer pointer to the Client's buffer
   272  * @param aClientBuffer pointer to the Client's buffer
   306  * @param aLength number of bytes to write
   273  * @param aLength number of bytes to write
   307  */
   274  */
   308 	{
   275 	{
   309 	OstTraceFunctionEntry0( CACMPORT_STARTWRITE_ENTRY );
   276 	LOG_LINE
   310 	OstTraceExt2( TRACE_NORMAL, CACMPORT_STARTWRITE, "CAcmPort::StartWrite;aClientBuffer=%p;aLength=%d", aClientBuffer, aLength );
   277 	LOG_FUNC
   311 
   278 	LOGTEXT3(_L8("\taClientBuffer=0x%08x, aLength=%d"),
   312 	if ( !iAcm )
   279 		aClientBuffer, aLength);
   313 		{
   280 
   314 		OstTrace0( TRACE_NORMAL, CACMPORT_STARTWRITE_DUP1, "CAcmPort::StartWrite;\t***access denied" );
   281 	if ( !iAcm )
       
   282 		{
       
   283 		LOGTEXT(_L8("\t***access denied"));
   315 		WriteCompleted(KErrAccessDenied);
   284 		WriteCompleted(KErrAccessDenied);
   316 		OstTraceFunctionExit0( CACMPORT_STARTWRITE_EXIT );
       
   317 		return;
   285 		return;
   318 		}
   286 		}
   319 
   287 
   320 	if ( aLength < 0 )
   288 	if ( aLength < 0 )
   321 		{
   289 		{
   322 		// Negative length makes no sense.
   290 		// Negative length makes no sense.
   323 		OstTrace0( TRACE_NORMAL, CACMPORT_STARTWRITE_DUP2, "CAcmPort::StartWrite;\taLength is negative-completing immediately with KErrArgument" );
   291 		LOGTEXT(_L8("\taLength is negative- "
       
   292 			"completing immediately with KErrArgument"));
   324 		WriteCompleted(KErrArgument);
   293 		WriteCompleted(KErrArgument);
   325 		OstTraceFunctionExit0( CACMPORT_STARTWRITE_EXIT_DUP1 );
       
   326 		return;
   294 		return;
   327 		}
   295 		}
   328 
   296 
   329 	// NB We pass zero-byte writes down to the LDD as normal. This results in 
   297 	// NB We pass zero-byte writes down to the LDD as normal. This results in 
   330 	// a zero-length packet being sent to the host.
   298 	// a zero-length packet being sent to the host.
   331 	if (!iWriter)
   299 
   332 		{
   300 	__ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   333 		OstTraceExt1( TRACE_FATAL, CACMPORT_STARTWRITE_DUP3, "CAcmPort::StartWrite;iWriter=%p", iWriter );
       
   334 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   335 		}
       
   336 	iWriter->Write(aClientBuffer, static_cast<TUint>(aLength));
   301 	iWriter->Write(aClientBuffer, static_cast<TUint>(aLength));
   337 	OstTraceFunctionExit0( CACMPORT_STARTWRITE_EXIT_DUP2 );
       
   338 	}
   302 	}
   339 
   303 
   340 void CAcmPort::WriteCancel()
   304 void CAcmPort::WriteCancel()
   341 /**
   305 /**
   342  * Downcall from C32. Cancel a pending write
   306  * Downcall from C32. Cancel a pending write
   343  */
   307  */
   344 	{
   308 	{
   345 	OstTraceFunctionEntry0( CACMPORT_WRITECANCEL_ENTRY );
   309 	LOG_LINE
       
   310 	LOG_FUNC
   346 	
   311 	
   347 	if ( !iAcm )
   312 	if ( !iAcm )
   348 		{
   313 		{
   349 		OstTrace0( TRACE_NORMAL, CACMPORT_WRITECANCEL, "CAcmPort::WriteCancel;\t***access denied" );
   314 		LOGTEXT(_L8("\t***access denied"));
   350 		OstTraceFunctionExit0( CACMPORT_WRITECANCEL_EXIT );
       
   351 		return;
   315 		return;
   352 		}
   316 		}
   353 
   317 
   354 	if (!iWriter)
   318 	__ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   355 		{
       
   356 		OstTraceExt1( TRACE_FATAL,CACMPORT_WRITECANCEL_DUP1, "CAcmPort::WriteCancel;iWriter=%p", iWriter );
       
   357 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   358 		}
       
   359 	iWriter->WriteCancel();
   319 	iWriter->WriteCancel();
   360 	OstTraceFunctionExit0( CACMPORT_WRITECANCEL_EXIT_DUP1 );
       
   361 	}
   320 	}
   362 
   321 
   363 void CAcmPort::Break(TInt aTime)
   322 void CAcmPort::Break(TInt aTime)
   364 /**
   323 /**
   365  * Downcall from C32. Send a break signal to the host.
   324  * Downcall from C32. Send a break signal to the host.
   367  * break signals sent from the host.
   326  * break signals sent from the host.
   368  *
   327  *
   369  * @param aTime Length of break in microseconds
   328  * @param aTime Length of break in microseconds
   370  */
   329  */
   371 	{
   330 	{
   372 	OstTraceFunctionEntry0( CACMPORT_BREAK_ENTRY );
   331 	LOG_LINE
   373 	OstTrace1( TRACE_NORMAL, CACMPORT_BREAK, "CAcmPort::Break;\taTime=%d (microseconds)", aTime );
   332 	LOG_FUNC
   374 
   333 	LOGTEXT2(_L8("\taTime=%d (microseconds)"), aTime);
   375 	if ( !iAcm )
   334 
   376 		{
   335 	if ( !iAcm )
   377 		OstTrace0( TRACE_NORMAL, CACMPORT_BREAK_DUP1, "CAcmPort::Break;\t***access denied" );
   336 		{
   378 		OstTraceFunctionExit0( CACMPORT_BREAK_EXIT );
   337 		LOGTEXT(_L8("\t***access denied"));
   379 		return;
   338 		return;
   380 		}
   339 		}
   381 
   340 
   382 	iBreak = ETrue;
   341 	iBreak = ETrue;
   383 	iCancellingBreak = EFalse;
   342 	iCancellingBreak = EFalse;
   385 	// Use the time value directly as microseconds are given. We are a USB 
   344 	// Use the time value directly as microseconds are given. We are a USB 
   386 	// 'device' so the RComm client is always on the device side.
   345 	// 'device' so the RComm client is always on the device side.
   387 	TInt err = iAcm->BreakRequest(CBreakController::EDevice,
   346 	TInt err = iAcm->BreakRequest(CBreakController::EDevice,
   388 		CBreakController::ETiming,
   347 		CBreakController::ETiming,
   389 		TTimeIntervalMicroSeconds32(aTime));
   348 		TTimeIntervalMicroSeconds32(aTime));
   390 	OstTrace1( TRACE_NORMAL, CACMPORT_BREAK_DUP2, "CAcmPort::Break;\tBreakRequest = %d", err );
   349 	LOGTEXT2(_L8("\tBreakRequest = %d"), err);
   391 	// Note that the break controller may refuse our request if a host-driven 
   350 	// Note that the break controller may refuse our request if a host-driven 
   392 	// break is outstanding.
   351 	// break is outstanding.
   393 	if ( err )
   352 	if ( err )
   394 		{
   353 		{
   395 		OstTrace1( TRACE_NORMAL, CACMPORT_BREAK_DUP3, "CAcmPort::Break;\tcalling BreakCompleted with %d", err );
   354 		LOGTEXT2(_L8("\tcalling BreakCompleted with %d"), err);
   396 		iBreak = EFalse;
   355 		iBreak = EFalse;
   397 		BreakCompleted(err);
   356 		BreakCompleted(err);
   398 		}						
   357 		}						
   399 	OstTraceFunctionExit0( CACMPORT_BREAK_EXIT_DUP1 );
       
   400 	}
   358 	}
   401 
   359 
   402 void CAcmPort::BreakCancel()
   360 void CAcmPort::BreakCancel()
   403 /**
   361 /**
   404  * Downcall from C32. Cancel a pending break.
   362  * Downcall from C32. Cancel a pending break.
   405  */
   363  */
   406 	{
   364 	{
   407 	OstTraceFunctionEntry0( CACMPORT_BREAKCANCEL_ENTRY );
   365 	LOG_LINE
   408 	if ( !iAcm )
   366 	LOG_FUNC
   409 		{
   367 
   410 		OstTrace0( TRACE_NORMAL, CACMPORT_BREAKCANCEL, "CAcmPort::BreakCancel;\t***access denied" );
   368 	if ( !iAcm )
   411 		OstTraceFunctionExit0( CACMPORT_BREAKCANCEL_EXIT );
   369 		{
       
   370 		LOGTEXT(_L8("\t***access denied"));
   412 		return;
   371 		return;
   413 		}
   372 		}
   414 	
   373 	
   415 	iCancellingBreak = ETrue;
   374 	iCancellingBreak = ETrue;
       
   375 
   416 	TInt err = iAcm->BreakRequest(CBreakController::EDevice,
   376 	TInt err = iAcm->BreakRequest(CBreakController::EDevice,
   417 		CBreakController::EInactive);
   377 		CBreakController::EInactive);
   418 	// Note that the device cannot turn off a break if there's a host-driven 
   378 	// Note that the device cannot turn off a break if there's a host-driven 
   419 	// break in progress.
   379 	// break in progress.
   420 	OstTrace1( TRACE_NORMAL, CACMPORT_BREAKCANCEL_DUP1, "CAcmPort::BreakCancel;\tBreakRequest = %d", err );
   380 	LOGTEXT2(_L8("\tBreakRequest = %d"), err);
   421 	if ( err )
   381 	if ( err )
   422 		{
   382 		{
   423 		iCancellingBreak = EFalse;
   383 		iCancellingBreak = EFalse;
   424 		}
   384 		}
   425 
   385 
   426 	// Whether BreakOff worked or not, reset our flag saying we're no longer 
   386 	// Whether BreakOff worked or not, reset our flag saying we're no longer 
   427 	// interested in any subsequent completion anyway.
   387 	// interested in any subsequent completion anyway.
   428 	iBreak = EFalse;
   388 	iBreak = EFalse;
   429 	OstTraceFunctionExit0( CACMPORT_BREAKCANCEL_EXIT_DUP1 );
       
   430 	}
   389 	}
   431 
   390 
   432 TInt CAcmPort::GetConfig(TDes8& aDes) const
   391 TInt CAcmPort::GetConfig(TDes8& aDes) const
   433 /**
   392 /**
   434  * Downcall from C32. Pass a config request. Only supports V01.
   393  * Downcall from C32. Pass a config request. Only supports V01.
   435  *
   394  *
   436  * @param aDes config will be written to this descriptor 
   395  * @param aDes config will be written to this descriptor 
   437  * @return Error.
   396  * @return Error.
   438  */
   397  */
   439 	{
   398 	{
   440 	OstTraceFunctionEntry0( CACMPORT_GETCONFIG_ENTRY );
   399 	LOG_LINE
   441 	if ( !iAcm )
   400 	LOG_FUNC
   442 		{
   401 
   443 		OstTrace0( TRACE_NORMAL, CACMPORT_GETCONFIG, "CAcmPort::GetConfig;\t***access denied" );
   402 	if ( !iAcm )
   444 		OstTraceFunctionExit0( CACMPORT_GETCONFIG_EXIT );
   403 		{
       
   404 		LOGTEXT(_L8("\t***access denied"));
   445 		return KErrAccessDenied;
   405 		return KErrAccessDenied;
   446 		}
   406 		}
   447 
   407 
   448 	if ( aDes.Length() < static_cast<TInt>(sizeof(TCommConfigV01)) )
   408 	if ( aDes.Length() < static_cast<TInt>(sizeof(TCommConfigV01)) )
   449 		{
   409 		{
   450 		OstTrace0( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP12, "CAcmPort::GetConfig;\t***not supported" );
   410 		LOGTEXT(_L8("\t***not supported"));
   451 		OstTraceFunctionExit0( CACMPORT_GETCONFIG_EXIT_DUP1 );
       
   452 		return KErrNotSupported;
   411 		return KErrNotSupported;
   453 		}
   412 		}
   454 
   413 
   455 	TCommConfig commConfigPckg;
   414 	TCommConfig commConfigPckg;
   456 	TCommConfigV01& commConfig = commConfigPckg();
   415 	TCommConfigV01& commConfig = commConfigPckg();
   457 	commConfig = iCommConfig;
   416 	commConfig = iCommConfig;
       
   417 	
   458 	aDes.Copy(commConfigPckg);
   418 	aDes.Copy(commConfigPckg);
   459 	
   419 
   460 	OstTrace1( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP1, "CAcmPort::GetConfig;\tiCommConfig.iRate=%d", iCommConfig.iRate );
   420 	LOGTEXT2(_L8("\tiCommConfig.iRate = %d"), iCommConfig.iRate);
   461 	OstTrace1( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP2, "CAcmPort::GetConfig;\tiCommConfig.iDataBits = %d", iCommConfig.iDataBits );
   421 	LOGTEXT2(_L8("\tiCommConfig.iDataBits = %d"), iCommConfig.iDataBits);
   462 	OstTrace1( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP3, "CAcmPort::GetConfig;\tiCommConfig.iStopBits = %d", iCommConfig.iStopBits );
   422 	LOGTEXT2(_L8("\tiCommConfig.iStopBits = %d"), iCommConfig.iStopBits);
   463 	OstTrace1( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP4, "CAcmPort::GetConfig;\tiCommConfig.iParity = %d", iCommConfig.iParity );
   423 	LOGTEXT2(_L8("\tiCommConfig.iParity = %d"), iCommConfig.iParity);
   464 	OstTrace1( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP5, "CAcmPort::GetConfig;\tiCommConfig.iHandshake = %d", iCommConfig.iHandshake );
   424 	LOGTEXT2(_L8("\tiCommConfig.iHandshake = %d"), iCommConfig.iHandshake);
   465 	OstTrace1( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP6, "CAcmPort::GetConfig;\tiCommConfig.iParityError = %d", iCommConfig.iParityError );
   425 	LOGTEXT2(_L8("\tiCommConfig.iParityError = %d"), 
   466 	OstTrace1( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP7, "CAcmPort::GetConfig;\tiCommConfig.iFifo = %d", iCommConfig.iFifo );
   426 		iCommConfig.iParityError);
   467 	OstTrace1( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP8, "CAcmPort::GetConfig;\tiCommConfig.iSpecialRate = %d", iCommConfig.iSpecialRate );
   427 	LOGTEXT2(_L8("\tiCommConfig.iFifo = %d"), iCommConfig.iFifo);
   468 	OstTrace1( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP9, "CAcmPort::GetConfig;\tiCommConfig.iTerminatorCount = %d", iCommConfig.iTerminatorCount );
   428 	LOGTEXT2(_L8("\tiCommConfig.iSpecialRate = %d"), 
   469 	OstTrace1( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP10, "CAcmPort::GetConfig;\tiCommConfig.iSIREnable = %d", iCommConfig.iSIREnable );
   429 		iCommConfig.iSpecialRate);
   470 	OstTrace1( TRACE_NORMAL, CACMPORT_GETCONFIG_DUP11, "CAcmPort::GetConfig;\tiCommConfig.iSIRSettings = %d", iCommConfig.iSIRSettings );
   430 	LOGTEXT2(_L8("\tiCommConfig.iTerminatorCount = %d"), 
   471 
   431 		iCommConfig.iTerminatorCount);
   472 	OstTraceFunctionExit0( CACMPORT_GETCONFIG_EXIT_DUP2 );
   432 	LOGTEXT2(_L8("\tiCommConfig.iSIREnable = %d"), iCommConfig.iSIREnable);
       
   433 	LOGTEXT2(_L8("\tiCommConfig.iSIRSettings = %d"), 
       
   434 		iCommConfig.iSIRSettings);
       
   435 
   473 	return KErrNone;
   436 	return KErrNone;
   474 	}
   437 	}
   475 
   438 
   476 TInt CAcmPort::SetConfig(const TDesC8& aDes)
   439 TInt CAcmPort::SetConfig(const TDesC8& aDes)
   477 /**
   440 /**
   479  *
   442  *
   480  * @param aDes descriptor containing the new config
   443  * @param aDes descriptor containing the new config
   481  * @return Error
   444  * @return Error
   482  */
   445  */
   483 	{
   446 	{
   484 	OstTraceFunctionEntry0( CACMPORT_SETCONFIG_ENTRY );
   447 	LOG_LINE
   485 	if ( !iAcm )
   448 	LOG_FUNC
   486 		{
   449 
   487 		OstTrace0( TRACE_NORMAL, CACMPORT_SETCONFIG, "CAcmPort::SetConfig;\t***access denied" );
   450 	if ( !iAcm )
   488 		OstTraceFunctionExit0( CACMPORT_SETCONFIG_EXIT );
   451 		{
       
   452 		LOGTEXT(_L8("\t***access denied"));
   489 		return KErrAccessDenied;
   453 		return KErrAccessDenied;
   490 		}
   454 		}
   491 
   455 
   492 	OstTraceExt3( TRACE_NORMAL, CACMPORT_SETCONFIG_DUP1, "CAcmPort::SetConfig;\tlength of argument=%d;TCommConfigV01=%d;TCommConfigV02=%d", aDes.Length(), (TInt)sizeof(TCommConfigV01), (TInt)sizeof(TCommConfigV02) );
   456 	LOGTEXT4(_L8("\tlength of argument %d, TCommConfigV01 %d, "
   493 	
   457 		"TCommConfigV02 %d"), 
       
   458 		aDes.Length(), 
       
   459 		(TInt)sizeof(TCommConfigV01),
       
   460 		(TInt)sizeof(TCommConfigV02));
       
   461 
   494 	if ( aDes.Length() < static_cast<TInt>(sizeof(TCommConfigV01)) )
   462 	if ( aDes.Length() < static_cast<TInt>(sizeof(TCommConfigV01)) )
   495 		{
   463 		{
   496 		OstTrace0( TRACE_NORMAL, CACMPORT_SETCONFIG_DUP2, "CAcmPort::SetConfig;\t***not supported" );
   464 		LOGTEXT(_L8("\t***not supported"));
   497 		OstTraceFunctionExit0( CACMPORT_SETCONFIG_EXIT_DUP1 );
       
   498 		return KErrNotSupported;
   465 		return KErrNotSupported;
   499 		}
   466 		}
   500 
   467 
   501 	TCommConfig configPckg;
   468 	TCommConfig configPckg;
   502 	configPckg.Copy(aDes);
   469 	configPckg.Copy(aDes);
   503 	TCommConfigV01& config = configPckg();
   470 	TCommConfigV01& config = configPckg();
   504 
   471 
   505 	OstTrace1( TRACE_DUMP, CACMPORT_SETCONFIG_DUP3, "CAcmPort::SetConfig;\tconfig.iRate=%d", config.iRate );
   472 	LOGTEXT2(_L8("\tiCommConfig.iRate = %d"), config.iRate);
   506 	OstTrace1( TRACE_DUMP, CACMPORT_SETCONFIG_DUP4, "CAcmPort::SetConfig;\tconfig.iDataBits=%d", config.iDataBits );
   473 	LOGTEXT2(_L8("\tiCommConfig.iDataBits = %d"), config.iDataBits);
   507 	OstTrace1( TRACE_DUMP, CACMPORT_SETCONFIG_DUP5, "CAcmPort::SetConfig;\tconfig.iStopBits=%d", config.iStopBits );
   474 	LOGTEXT2(_L8("\tiCommConfig.iStopBits = %d"), config.iStopBits);
   508 	OstTrace1( TRACE_DUMP, CACMPORT_SETCONFIG_DUP6, "CAcmPort::SetConfig;\tconfig.iParity=%d", config.iParity );
   475 	LOGTEXT2(_L8("\tiCommConfig.iParity = %d"), config.iParity);
   509 	OstTrace1( TRACE_DUMP, CACMPORT_SETCONFIG_DUP7, "CAcmPort::SetConfig;\tconfig.iHandshake=%d", config.iHandshake );
   476 	LOGTEXT2(_L8("\tiCommConfig.iHandshake = %d"), config.iHandshake);
   510 	OstTrace1( TRACE_DUMP, CACMPORT_SETCONFIG_DUP8, "CAcmPort::SetConfig;\tconfig.iParityError=%d", config.iParityError );
   477 	LOGTEXT2(_L8("\tiCommConfig.iParityError = %d"), config.iParityError);
   511 	OstTrace1( TRACE_DUMP, CACMPORT_SETCONFIG_DUP9, "CAcmPort::SetConfig;\tconfig.iFifo=%d", config.iFifo );
   478 	LOGTEXT2(_L8("\tiCommConfig.iFifo = %d"), config.iFifo);
   512 	OstTrace1( TRACE_DUMP, CACMPORT_SETCONFIG_DUP10, "CAcmPort::SetConfig;\tconfig.iSpecialRate=%d", config.iSpecialRate );
   479 	LOGTEXT2(_L8("\tiCommConfig.iSpecialRate = %d"), config.iSpecialRate);
   513 	OstTrace1( TRACE_DUMP, CACMPORT_SETCONFIG_DUP11, "CAcmPort::SetConfig;\tconfig.iTerminatorCount=%d", config.iTerminatorCount );
   480 	LOGTEXT2(_L8("\tiCommConfig.iTerminatorCount = %d"), 
   514 	OstTrace1( TRACE_DUMP, CACMPORT_SETCONFIG_DUP12, "CAcmPort::SetConfig;\tconfig.iSIREnable=%d", config.iSIREnable );
   481 		config.iTerminatorCount);
   515 	OstTrace1( TRACE_DUMP, CACMPORT_SETCONFIG_DUP13, "CAcmPort::SetConfig;\tconfig.iSIRSettings=%d", config.iSIRSettings );
   482 	LOGTEXT2(_L8("\tiCommConfig.iSIREnable = %d"), config.iSIREnable);
       
   483 	LOGTEXT2(_L8("\tiCommConfig.iSIRSettings = %d"), config.iSIRSettings);
   516 
   484 
   517 	// Tell the reader object about the new terminators. Pass the whole config 
   485 	// Tell the reader object about the new terminators. Pass the whole config 
   518 	// struct by reference for ease.
   486 	// struct by reference for ease.
   519 	iReader->SetTerminators(config);
   487 	iReader->SetTerminators(config);
   520 
   488 
   523 		config.iParity,
   491 		config.iParity,
   524 		config.iStopBits,
   492 		config.iStopBits,
   525 		config.iHandshake);
   493 		config.iHandshake);
   526 	iCommConfig = config;
   494 	iCommConfig = config;
   527 
   495 
   528 	OstTraceFunctionExit0( CACMPORT_SETCONFIG_EXIT_DUP2 );
       
   529 	return KErrNone;
   496 	return KErrNone;
   530 	}
   497 	}
   531 
   498 
   532 void CAcmPort::HandleConfigNotification(TBps aRate,
   499 void CAcmPort::HandleConfigNotification(TBps aRate,
   533 										TDataBits aDataBits,
   500 										TDataBits aDataBits,
   541  * @param aParity		New parity check setting
   508  * @param aParity		New parity check setting
   542  * @param aStopBits 	New stop bit setting
   509  * @param aStopBits 	New stop bit setting
   543  * @param aHandshake	New handshake setting
   510  * @param aHandshake	New handshake setting
   544  */
   511  */
   545 	{
   512 	{
   546 	OstTraceFunctionEntry0( CACMPORT_HANDLECONFIGNOTIFICATION_ENTRY );
   513 	LOGTEXT(_L8(">>CAcmPort::HandleConfigNotification"));
   547 	
   514 	LOGTEXT2(_L8("\taRate = %d"), aRate);
   548 	OstTrace0( TRACE_DUMP, CACMPORT_HANDLECONFIGNOTIFICATION, "CAcmPort::HandleConfigNotification;>>CAcmPort::HandleConfigNotification" );
   515 	LOGTEXT2(_L8("\taDataBits = %d"), aDataBits);
   549 	OstTrace1( TRACE_DUMP, CACMPORT_HANDLECONFIGNOTIFICATION_DUP1, "CAcmPort::HandleConfigNotification;aRate=%d", aRate );
   516 	LOGTEXT2(_L8("\taStopBits = %d"), aStopBits);
   550 	OstTrace1( TRACE_DUMP, CACMPORT_HANDLECONFIGNOTIFICATION_DUP2, "CAcmPort::HandleConfigNotification;aDataBits=%d", aDataBits );
   517 	LOGTEXT2(_L8("\taParity = %d"), aParity);
   551 	OstTrace1( TRACE_DUMP, CACMPORT_HANDLECONFIGNOTIFICATION_DUP3, "CAcmPort::HandleConfigNotification;aStopBits=%d", aStopBits );
   518 	LOGTEXT2(_L8("\taHandshake = %d"), aHandshake);
   552 	OstTrace1( TRACE_DUMP, CACMPORT_HANDLECONFIGNOTIFICATION_DUP4, "CAcmPort::HandleConfigNotification;aParity=%d", aParity );
       
   553 	OstTrace1( TRACE_DUMP, CACMPORT_HANDLECONFIGNOTIFICATION_DUP5, "CAcmPort::HandleConfigNotification;aHandshake=%d", aHandshake );
       
   554 			
   519 			
   555 	iCommNotification.iChangedMembers = 0;
   520 	iCommNotification.iChangedMembers = 0;
   556 
   521 
   557 	iCommNotification.iRate = aRate;
   522 	iCommNotification.iRate = aRate;
   558 	if ( iCommConfig.iRate != aRate )
   523 	if ( iCommConfig.iRate != aRate )
   584 		iCommNotification.iChangedMembers |= KHandshakeChanged;
   549 		iCommNotification.iChangedMembers |= KHandshakeChanged;
   585 		}
   550 		}
   586 
   551 
   587 	if ( iCommNotification.iChangedMembers )
   552 	if ( iCommNotification.iChangedMembers )
   588 		{
   553 		{
   589 		OstTrace0( TRACE_NORMAL, CACMPORT_HANDLECONFIGNOTIFICATION_DUP6, "CAcmPort::HandleConfigNotification;\tcalling ConfigChangeCompleted with KErrNone" );
   554 		LOGTEXT(_L8("\tcalling ConfigChangeCompleted with KErrNone"));
   590 		ConfigChangeCompleted(iCommNotificationDes,KErrNone);
   555 		ConfigChangeCompleted(iCommNotificationDes,KErrNone);
   591 		iNotifyConfigChange = EFalse;
   556 		iNotifyConfigChange = EFalse;
   592 		}
   557 		}
   593 
   558 
   594 	OstTraceFunctionExit0( CACMPORT_HANDLECONFIGNOTIFICATION_EXIT );
   559 	LOGTEXT(_L8("<<CAcmPort::HandleConfigNotification"));
   595 	}
   560 	}
   596 
   561 
   597 TInt CAcmPort::SetServerConfig(const TDesC8& aDes)
   562 TInt CAcmPort::SetServerConfig(const TDesC8& aDes)
   598 /**
   563 /**
   599  * Downcall from C32. Set server config using a TCommServerConfigV01 package.
   564  * Downcall from C32. Set server config using a TCommServerConfigV01 package.
   600  *
   565  *
   601  * @param aDes package with new server configurations
   566  * @param aDes package with new server configurations
   602  * @return Error.
   567  * @return Error.
   603  */
   568  */
   604 	{
   569 	{
   605 	OstTraceFunctionEntry0( CACMPORT_SETSERVERCONFIG_ENTRY );
   570 	LOG_LINE
   606 	if ( !iAcm )
   571 	LOG_FUNC
   607 		{
   572 
   608 		OstTrace0( TRACE_NORMAL, CACMPORT_SETSERVERCONFIG, "CAcmPort::SetServerConfig;\t***access denied" );
   573 	if ( !iAcm )
   609 		OstTraceFunctionExit0( CACMPORT_SETSERVERCONFIG_EXIT );
   574 		{
       
   575 		LOGTEXT(_L8("\t***access denied"));
   610 		return KErrAccessDenied;
   576 		return KErrAccessDenied;
   611 		}
   577 		}
   612 
   578 
   613 	if ( aDes.Length() < static_cast<TInt>(sizeof(TCommServerConfigV01)) )
   579 	if ( aDes.Length() < static_cast<TInt>(sizeof(TCommServerConfigV01)) )
   614 		{
   580 		{
   615 		OstTrace0( TRACE_NORMAL, CACMPORT_SETSERVERCONFIG_DUP1, "CAcmPort::SetServerConfig;\t***not supported" );
   581 		LOGTEXT(_L8("\t***not supported"));
   616 		OstTraceFunctionExit0( CACMPORT_SETSERVERCONFIG_EXIT_DUP1 );
       
   617 		return KErrNotSupported;
   582 		return KErrNotSupported;
   618 		}
   583 		}
   619 
   584 
   620 	TCommServerConfig serverConfigPckg;
   585 	TCommServerConfig serverConfigPckg;
   621 	serverConfigPckg.Copy(aDes);
   586 	serverConfigPckg.Copy(aDes);
   622 	TCommServerConfigV01& serverConfig = serverConfigPckg();
   587 	TCommServerConfigV01& serverConfig = serverConfigPckg();
   623 
   588 
   624 	if ( serverConfig.iBufFlags != KCommBufferFull )
   589 	if ( serverConfig.iBufFlags != KCommBufferFull )
   625 		{
   590 		{
   626 		OstTrace0( TRACE_NORMAL, CACMPORT_SETSERVERCONFIG_DUP2, "CAcmPort::SetServerConfig;\t***not supported" );
   591 		LOGTEXT(_L8("\t***not supported"));
   627 		OstTraceFunctionExit0( CACMPORT_SETSERVERCONFIG_EXIT_DUP2 );
       
   628 		return KErrNotSupported;
   592 		return KErrNotSupported;
   629 		}
   593 		}
   630 
   594 
   631 	// Apply the buffer size setting to Rx and Tx buffers. 
   595 	// Apply the buffer size setting to Rx and Tx buffers. 
   632 	TInt err = DoSetBufferLengths(serverConfig.iBufSize);
   596 	TInt err = DoSetBufferLengths(serverConfig.iBufSize);
   633 	if ( err )
   597 	if ( err )
   634 		{
   598 		{
   635 		// Failure- the buffer lengths will have been left as they were, so 
   599 		// Failure- the buffer lengths will have been left as they were, so 
   636 		// just return error.
   600 		// just return error.
   637 		OstTrace1( TRACE_NORMAL, CACMPORT_SETSERVERCONFIG_DUP3, "CAcmPort::SetServerConfig;\t***DoSetBufferLengths=%d", err );
   601 		LOGTEXT2(_L8("\t***DoSetBufferLengths=%d"), err);
   638 		OstTraceFunctionExit0( CACMPORT_SETSERVERCONFIG_EXIT_DUP3 );
       
   639 		return err;
   602 		return err;
   640 		}
   603 		}
   641 
   604 
   642 	// Changed buffer sizes OK. Note that new config.
   605 	// Changed buffer sizes OK. Note that new config.
   643 	iCommServerConfig = serverConfig;
   606 	iCommServerConfig = serverConfig;
   644 	OstTraceFunctionExit0( CACMPORT_SETSERVERCONFIG_EXIT_DUP4 );
       
   645 	return KErrNone;
   607 	return KErrNone;
   646 	}
   608 	}
   647 
   609 
   648 TInt CAcmPort::GetServerConfig(TDes8& aDes)
   610 TInt CAcmPort::GetServerConfig(TDes8& aDes)
   649 /**
   611 /**
   651  *
   613  *
   652  * @param aDes server configs will be written to this descriptor
   614  * @param aDes server configs will be written to this descriptor
   653  * @return Error.
   615  * @return Error.
   654  */
   616  */
   655 	{
   617 	{
   656 	OstTraceFunctionEntry0( CACMPORT_GETSERVERCONFIG_ENTRY );
   618 	LOG_LINE
   657 	if ( !iAcm )
   619 	LOG_FUNC
   658 		{
   620 
   659 		OstTrace0( TRACE_NORMAL, CACMPORT_GETSERVERCONFIG, "CAcmPort::GetServerConfig;\t***access denied" );	
   621 	if ( !iAcm )
   660 		OstTraceFunctionExit0( CACMPORT_GETSERVERCONFIG_EXIT );
   622 		{
       
   623 		LOGTEXT(_L8("\t***access denied"));
   661 		return KErrAccessDenied;
   624 		return KErrAccessDenied;
   662 		}
   625 		}
   663 
   626 
   664 	if ( aDes.Length() < static_cast<TInt>(sizeof(TCommServerConfigV01)) )
   627 	if ( aDes.Length() < static_cast<TInt>(sizeof(TCommServerConfigV01)) )
   665 		{
   628 		{
   666 		OstTrace0( TRACE_NORMAL, CACMPORT_GETSERVERCONFIG_DUP1, "CAcmPort::GetServerConfig;\t***not supported" );
   629 		LOGTEXT(_L8("\t***not supported"));
   667 		OstTraceFunctionExit0( CACMPORT_GETSERVERCONFIG_EXIT_DUP1 );
       
   668 		return KErrNotSupported;
   630 		return KErrNotSupported;
   669 		}
   631 		}
   670 
   632 
   671 	TCommServerConfig* serverConfigPckg = 
   633 	TCommServerConfig* serverConfigPckg = 
   672 		reinterpret_cast<TCommServerConfig*>(&aDes);
   634 		reinterpret_cast<TCommServerConfig*>(&aDes);
   673 	TCommServerConfigV01& serverConfig = (*serverConfigPckg)();
   635 	TCommServerConfigV01& serverConfig = (*serverConfigPckg)();
   674 
   636 
   675 	serverConfig = iCommServerConfig;
   637 	serverConfig = iCommServerConfig;
   676 	OstTraceFunctionExit0( CACMPORT_GETSERVERCONFIG_EXIT_DUP2 );
       
   677 	return KErrNone;
   638 	return KErrNone;
   678 	}
   639 	}
   679 
   640 
   680 TInt CAcmPort::GetCaps(TDes8& aDes)
   641 TInt CAcmPort::GetCaps(TDes8& aDes)
   681 /**
   642 /**
   683  *
   644  *
   684  * @param aDes caps will be written to this descriptor
   645  * @param aDes caps will be written to this descriptor
   685  * @return Error.
   646  * @return Error.
   686  */
   647  */
   687 	{
   648 	{
   688 	OstTraceFunctionEntry0( CACMPORT_GETCAPS_ENTRY );
   649 	LOG_LINE
   689 	
   650 	LOG_FUNC
   690 	if ( !iAcm )
   651 
   691 		{
   652 	if ( !iAcm )
   692 		OstTrace0( TRACE_NORMAL, CACMPORT_GETCAPS, "CAcmPort::GetCaps;\t***access denied" );
   653 		{
   693 		OstTraceFunctionExit0( CACMPORT_GETCAPS_EXIT );
   654 		LOGTEXT(_L8("\t***access denied"));
   694 		return KErrAccessDenied;
   655 		return KErrAccessDenied;
   695 		}
   656 		}
   696 
   657 
   697 	TCommCaps2 capsPckg;
   658 	TCommCaps2 capsPckg;
   698 	TCommCapsV02& caps = capsPckg();
   659 	TCommCapsV02& caps = capsPckg();
   718 		caps.iSIR = KCapsSIR;
   679 		caps.iSIR = KCapsSIR;
   719 		}
   680 		}
   720 		break;
   681 		break;
   721 	default:
   682 	default:
   722 		{
   683 		{
   723 		OstTrace0( TRACE_NORMAL, CACMPORT_GETCAPS_DUP1, "CAcmPort::GetCaps;\t***bad argument" );
   684 		LOGTEXT(_L8("\t***bad argument"));
   724 		OstTraceFunctionExit0( CACMPORT_GETCAPS_EXIT_DUP1 );
       
   725 		return KErrArgument;
   685 		return KErrArgument;
   726 		}
   686 		}
   727 		}
   687 		}
   728 
   688 
   729 	aDes.Copy(capsPckg.Left(aDes.Length()));
   689 	aDes.Copy(capsPckg.Left(aDes.Length()));
   730 
   690 
   731 	OstTraceFunctionExit0( CACMPORT_GETCAPS_EXIT_DUP2 );
       
   732 	return KErrNone;
   691 	return KErrNone;
   733 	}
   692 	}
   734 
   693 
   735 TInt CAcmPort::GetSignals(TUint& aSignals)
   694 TInt CAcmPort::GetSignals(TUint& aSignals)
   736 /**
   695 /**
   738  *
   697  *
   739  * @param aSignals signals will be written to this descriptor
   698  * @param aSignals signals will be written to this descriptor
   740  * @return Error.
   699  * @return Error.
   741  */
   700  */
   742 	{
   701 	{
   743 	OstTraceFunctionEntry0( CACMPORT_GETSIGNALS_ENTRY );
   702 	LOG_LINE
   744 	if ( !iAcm )
   703 	LOG_FUNC
   745 		{
   704 
   746 		OstTrace0( TRACE_NORMAL, CACMPORT_GETSIGNALS, "CAcmPort::GetSignals;\t***access denied" );
   705 	if ( !iAcm )
   747 		OstTraceFunctionExit0( CACMPORT_GETSIGNALS_EXIT );
   706 		{
       
   707 		LOGTEXT(_L8("\t***access denied"));
   748 		return KErrAccessDenied;
   708 		return KErrAccessDenied;
   749 		}
   709 		}
   750 
   710 
   751 	aSignals = ConvertSignals(iSignals);
   711 	aSignals = ConvertSignals(iSignals);
   752 
   712 
   753 	OstTraceExt2( TRACE_NORMAL, CACMPORT_GETSIGNALS_DUP1, "CAcmPort::GetSignals;iSignals=%x;aSignals=%x", iSignals, (TUint32)aSignals );
   713 	LOGTEXT3(_L8("iSignals=0x%x, aSignals=0x%x"),
   754 	OstTraceFunctionExit0( CACMPORT_GETSIGNALS_EXIT_DUP1 );
   714 		iSignals, aSignals);
   755 	return KErrNone;
   715 	return KErrNone;
   756 	}
   716 	}
   757 
   717 
   758 TInt CAcmPort::SetSignalsToMark(TUint aSignals)
   718 TInt CAcmPort::SetSignalsToMark(TUint aSignals)
   759 /**
   719 /**
   761  *
   721  *
   762  * @param aSignals bitmask with the signals to be set
   722  * @param aSignals bitmask with the signals to be set
   763  * @return Error.
   723  * @return Error.
   764  */
   724  */
   765 	{
   725 	{
   766 	OstTraceFunctionEntry0( CACMPORT_SETSIGNALSTOMARK_ENTRY );
   726 	LOG_LINE
   767 	if ( !iAcm )
   727 	LOG_FUNC
   768 		{
   728 
   769 		OstTrace0( TRACE_NORMAL, CACMPORT_SETSIGNALSTOMARK, "CAcmPort::SetSignalsToMark;\t***access denied" );
   729 	if ( !iAcm )
   770 		OstTraceFunctionExit0( CACMPORT_SETSIGNALSTOMARK_EXIT );
   730 		{
       
   731 		LOGTEXT(_L8("\t***access denied"));
   771 		return KErrAccessDenied;
   732 		return KErrAccessDenied;
   772 		}
   733 		}
   773 
   734 
   774 	TUint32 newSignals = iSignals | ConvertAndFilterSignals(aSignals);
   735 	TUint32 newSignals = iSignals | ConvertAndFilterSignals(aSignals);
   775 	TInt err = SetSignals(newSignals);
   736 	TInt err = SetSignals(newSignals);
   776 	if ( err )
   737 	if ( err )
   777 		{
   738 		{
   778 		OstTrace1( TRACE_NORMAL, CACMPORT_SETSIGNALSTOMARK_DUP1, "CAcmPort::SetSignalsToMark;***SetSignals = %d", err );
   739 		LOGTEXT2(_L8("***SetSignals = %d"), err);
   779 		OstTraceFunctionExit0( CACMPORT_SETSIGNALSTOMARK_EXIT_DUP1 );
       
   780 		return err;
   740 		return err;
   781 		}
   741 		}
   782 
   742 
   783 	OstTraceExt2( TRACE_NORMAL, CACMPORT_SETSIGNALSTOMARK_DUP2, "CAcmPort::SetSignalsToMark;iSignals=%x;aSignals=%x", iSignals, (TUint32)aSignals );
   743 	LOGTEXT3(_L8("iSignals=0x%x, aSignals=0x%x"),
   784 	OstTraceFunctionExit0( CACMPORT_SETSIGNALSTOMARK_EXIT_DUP2 );
   744 		iSignals, aSignals);
   785 	return KErrNone;
   745 	return KErrNone;
   786 	}
   746 	}
   787 
   747 
   788 TInt CAcmPort::SetSignalsToSpace(TUint aSignals)
   748 TInt CAcmPort::SetSignalsToSpace(TUint aSignals)
   789 /**
   749 /**
   791  *
   751  *
   792  * @param aSignals bitmask with the signals to be cleared
   752  * @param aSignals bitmask with the signals to be cleared
   793  * @return Error.
   753  * @return Error.
   794  */
   754  */
   795 	{
   755 	{
   796 	OstTraceFunctionEntry0( CACMPORT_SETSIGNALSTOSPACE_ENTRY );
   756 	LOG_LINE
   797 	if ( !iAcm )
   757 	LOG_FUNC
   798 		{
   758 
   799 		OstTrace0( TRACE_NORMAL, CACMPORT_SETSIGNALSTOSPACE, "CAcmPort::SetSignalsToSpace;\t***access denied" );
   759 	if ( !iAcm )
   800 		OstTraceFunctionExit0( CACMPORT_SETSIGNALSTOSPACE_EXIT );
   760 		{
       
   761 		LOGTEXT(_L8("\t***access denied"));
   801 		return KErrAccessDenied;
   762 		return KErrAccessDenied;
   802 		}
   763 		}
   803 
   764 
   804 	TUint32 newSignals = iSignals & ~ConvertAndFilterSignals(aSignals);
   765 	TUint32 newSignals = iSignals & ~ConvertAndFilterSignals(aSignals);
   805 	TInt err = SetSignals(newSignals);
   766 	TInt err = SetSignals(newSignals);
   806 	if ( err )
   767 	if ( err )
   807 		{
   768 		{
   808 		OstTrace1( TRACE_NORMAL, CACMPORT_SETSIGNALSTOSPACE_DUP1, "CAcmPort::SetSignalsToSpace;***SetSignals = %d", err );
   769 		LOGTEXT2(_L8("***SetSignals = %d"), err);
   809 		OstTraceFunctionExit0( CACMPORT_SETSIGNALSTOSPACE_EXIT_DUP1 );
       
   810 		return err;
   770 		return err;
   811 		}
   771 		}
   812 
   772 
   813 	OstTraceExt2( TRACE_NORMAL, CACMPORT_SETSIGNALSTOSPACE_DUP2, "CAcmPort::SetSignalsToSpace;iSignals=%x;aSignals=%x", iSignals, (TUint32)aSignals );
   773 	LOGTEXT3(_L8("iSignals=0x%x, aSignals=0x%x"),
   814 	OstTraceFunctionExit0( CACMPORT_SETSIGNALSTOSPACE_EXIT_DUP2 );
   774 		iSignals, aSignals);
   815 	return KErrNone;
   775 	return KErrNone;
   816 	}
   776 	}
   817 
   777 
   818 TInt CAcmPort::SetSignals(TUint32 aNewSignals)
   778 TInt CAcmPort::SetSignals(TUint32 aNewSignals)
   819 /**
   779 /**
   823  *
   783  *
   824  * @param aSignals bitmask with the signals to be set
   784  * @param aSignals bitmask with the signals to be set
   825  * @return Error.
   785  * @return Error.
   826  */
   786  */
   827 	{
   787 	{
   828 	OstTraceFunctionEntry0( CACMPORT_SETSIGNALS_ENTRY );
   788 	LOG_FUNC
   829 
   789 
   830 	TBool ring =((aNewSignals & KSignalRNG)==KSignalRNG);
   790 	TBool ring =((aNewSignals & KSignalRNG)==KSignalRNG);
   831 	TBool dsr  =((aNewSignals & KSignalDSR)==KSignalDSR);
   791 	TBool dsr  =((aNewSignals & KSignalDSR)==KSignalDSR);
   832 	TBool dcd  =((aNewSignals & KSignalDCD)==KSignalDCD);
   792 	TBool dcd  =((aNewSignals & KSignalDCD)==KSignalDCD);
   833  
   793  
       
   794  
   834  	if ( !iAcm )
   795  	if ( !iAcm )
   835 		{
   796 		{
   836 		OstTrace0( TRACE_NORMAL, CACMPORT_SETSIGNALS, "CAcmPort::SetSignals;\t***access denied" );
   797 		LOGTEXT(_L8("\t***access denied"));
   837 		OstTraceFunctionExit0( CACMPORT_SETSIGNALS_EXIT );
       
   838 		return KErrAccessDenied;
   798 		return KErrAccessDenied;
   839 		}
   799 		}
   840 
   800 
   841 	TInt err = iAcm->SendSerialState(ring,dsr,dcd);
   801 	TInt err = iAcm->SendSerialState(ring,dsr,dcd);
   842 	if ( err )
   802 	if ( err )
   843 		{
   803 		{
   844 		OstTrace1( TRACE_NORMAL, CACMPORT_SETSIGNALS_DUP1, "CAcmPort::SetSignals;\t***SendSerialState = %d- returning", err );
   804 		LOGTEXT2(_L8("\t***SendSerialState = %d- returning"), err);
   845 		OstTraceFunctionExit0( CACMPORT_SETSIGNALS_EXIT_DUP1 );
       
   846 		return err;
   805 		return err;
   847 		}
   806 		}
   848 
   807 
   849 	// Report the new signals if they have changed and notification mask shows
   808 	// Report the new signals if they have changed and notification mask shows
   850 	// the upper layer wanted to be sensitive to these signals
   809 	// the upper layer wanted to be sensitive to these signals
   870 				{
   829 				{
   871 				changedSignalsMask |= KDSRChanged;
   830 				changedSignalsMask |= KDSRChanged;
   872 				}
   831 				}
   873 
   832 
   874 			// Report correctly mapped signals that client asked for
   833 			// Report correctly mapped signals that client asked for
   875 			OstTrace0( TRACE_NORMAL, CACMPORT_SETSIGNALS_DUP2, "CAcmPort::SetSignals;\tcalling SignalChangeCompleted with KErrNone" );
   834 			LOGTEXT(_L8("\tcalling SignalChangeCompleted with KErrNone"));
   876 			TUint32 signals = ConvertSignals ( changedSignalsMask | ( aNewSignals & iNotifySignalMask ) );
   835 			TUint32 signals = ConvertSignals ( changedSignalsMask | ( aNewSignals & iNotifySignalMask ) );
   877 			SignalChangeCompleted ( signals, KErrNone );
   836 			SignalChangeCompleted ( signals, KErrNone );
   878 			iNotifySignalChange = EFalse;
   837 			iNotifySignalChange = EFalse;
   879 			}
   838 			}
   880 		}
   839 		}
   881 
   840 
   882 	// Store new signals in iSignals
   841 	// Store new signals in iSignals
   883 	iSignals = aNewSignals;
   842 	iSignals = aNewSignals;
   884 	OstTraceFunctionExit0( CACMPORT_SETSIGNALS_EXIT_DUP2 );
   843 
   885 	return KErrNone;
   844 	return KErrNone;
   886 	}
   845 	}
   887 
   846 
   888 TUint32 CAcmPort::ConvertAndFilterSignals(TUint32 aSignals) const
   847 TUint32 CAcmPort::ConvertAndFilterSignals(TUint32 aSignals) const
   889 /**
   848 /**
   898  * @param aSignals Input signals.
   857  * @param aSignals Input signals.
   899  * @return The signals, with the lines switched round according to the port's 
   858  * @return The signals, with the lines switched round according to the port's 
   900  * role.
   859  * role.
   901  */
   860  */
   902 	{
   861 	{
   903 	OstTraceFunctionEntry0( CACMPORT_CONVERTANDFILTERSIGNALS_ENTRY );
   862 	LOG_FUNC
   904 	
   863 
   905 	TUint32 signals = 0;
   864 	TUint32 signals = 0;
       
   865 
   906 	// note that this never allows the client to use this method
   866 	// note that this never allows the client to use this method
   907 	// to diddle the BREAK state
   867 	// to diddle the BREAK state
   908 
   868 
   909 	// handle role-specific mapping
   869 	// handle role-specific mapping
   910 	if ( iRole == ECommRoleDTE )
   870 	if ( iRole == ECommRoleDTE )
   932 			|	KSignalCTS
   892 			|	KSignalCTS
   933 			|	KSignalDCD
   893 			|	KSignalDCD
   934 			|	KSignalRNG);
   894 			|	KSignalRNG);
   935 		}
   895 		}
   936 
   896 
   937 	OstTraceFunctionExit0( CACMPORT_CONVERTANDFILTERSIGNALS_EXIT );
       
   938 	return signals;
   897 	return signals;
   939 	}
   898 	}
   940 
   899 
   941 TUint32 CAcmPort::ConvertSignals(TUint32 aSignals) const
   900 TUint32 CAcmPort::ConvertSignals(TUint32 aSignals) const
   942 /**
   901 /**
   955  * @param aSignals Input signals (internal or client).
   914  * @param aSignals Input signals (internal or client).
   956  * @return Output signals.
   915  * @return Output signals.
   957  * port is.
   916  * port is.
   958  */
   917  */
   959 	{
   918 	{
   960 	OstTraceFunctionEntry0( CACMPORT_CONVERTSIGNALS_ENTRY );
   919 	LOG_FUNC
   961 	
   920 
   962 	// Swap signals around if the client is expecting DTE signalling
   921 	// Swap signals around if the client is expecting DTE signalling
   963 	if ( iRole == ECommRoleDTE )
   922 	if ( iRole == ECommRoleDTE )
   964 		{
   923 		{
   965 		TUint32 swappedSignals = 0;
   924 		TUint32 swappedSignals = 0;
   966 
   925 
  1004 		const TUint32 KSwapSignals = KSignalDSR | KSignalDTR | KSignalCTS | KSignalRTS
   963 		const TUint32 KSwapSignals = KSignalDSR | KSignalDTR | KSignalCTS | KSignalRTS
  1005 									| KDSRChanged | KDTRChanged | KCTSChanged | KRTSChanged;
   964 									| KDSRChanged | KDTRChanged | KCTSChanged | KRTSChanged;
  1006 		aSignals = ( aSignals & ~KSwapSignals ) | swappedSignals;
   965 		aSignals = ( aSignals & ~KSwapSignals ) | swappedSignals;
  1007 		}
   966 		}
  1008 
   967 
  1009 	OstTraceFunctionExit0( CACMPORT_CONVERTSIGNALS_EXIT );
       
  1010 	return aSignals;
   968 	return aSignals;
  1011 	}
   969 	}
  1012 
   970 
  1013 TInt CAcmPort::GetReceiveBufferLength(TInt& aLength) const
   971 TInt CAcmPort::GetReceiveBufferLength(TInt& aLength) const
  1014 /**
   972 /**
  1019  *
   977  *
  1020  * @param aLength reference to where the length will be written to
   978  * @param aLength reference to where the length will be written to
  1021  * @return Error.
   979  * @return Error.
  1022  */
   980  */
  1023 	{
   981 	{
  1024 	OstTraceFunctionEntry0( CACMPORT_GETRECEIVEBUFFERLENGTH_ENTRY );
   982 	LOG_LINE
  1025 	
   983 	LOG_FUNC
  1026 	if ( !iAcm )
   984 
  1027 		{
   985 	if ( !iAcm )
  1028 		OstTrace0( TRACE_NORMAL, CACMPORT_GETRECEIVEBUFFERLENGTH, "CAcmPort::GetReceiveBufferLength;\t***access denied" );
   986 		{
  1029 		OstTraceFunctionExit0( CACMPORT_GETRECEIVEBUFFERLENGTH_EXIT );
   987 		LOGTEXT(_L8("\t***access denied"));
  1030 		return KErrAccessDenied;
   988 		return KErrAccessDenied;
  1031 		}
   989 		}
  1032 
   990 
  1033 	if (!iReader)
   991 	__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
  1034 		{
       
  1035 		OstTraceExt1( TRACE_FATAL, CACMPORT_GETRECEIVEBUFFERLENGTH_DUP2, "CAcmPort::GetReceiveBufferLength;iReader=%p", iReader );
       
  1036 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
  1037 		}
       
  1038 	aLength = static_cast<TInt>(iReader->BufSize());
   992 	aLength = static_cast<TInt>(iReader->BufSize());
  1039 	OstTrace1( TRACE_NORMAL, CACMPORT_GETRECEIVEBUFFERLENGTH_DUP1, "CAcmPort::GetReceiveBufferLength;aLength=%d", aLength );
   993 	LOGTEXT2(_L8("\tlength=%d"), aLength);
  1040 	OstTraceFunctionExit0( CACMPORT_GETRECEIVEBUFFERLENGTH_EXIT_DUP1 );
       
  1041 	return KErrNone;
   994 	return KErrNone;
  1042 	}
   995 	}
  1043 
   996 
  1044 TInt CAcmPort::DoSetBufferLengths(TUint aLength)
   997 TInt CAcmPort::DoSetBufferLengths(TUint aLength)
  1045 /**
   998 /**
  1048  *
  1001  *
  1049  * @param aLength The size required.
  1002  * @param aLength The size required.
  1050  * @return Error.
  1003  * @return Error.
  1051  */
  1004  */
  1052 	{
  1005 	{
  1053 	OstTraceFunctionEntry0( CACMPORT_DOSETBUFFERLENGTHS_ENTRY );
  1006 	LOG_FUNC
  1054 	OstTrace1( TRACE_NORMAL, CACMPORT_DOSETBUFFERLENGTHS, "CAcmPort::DoSetBufferLengths;aLength=%d", aLength );
  1007 	LOGTEXT2(_L8("\taLength=%d"), aLength);
  1055 
  1008 
  1056 	if (!iReader)
  1009 	__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
  1057 		{
       
  1058 		OstTraceExt1( TRACE_FATAL, CACMPORT_DOSETBUFFERLENGTHS_DUP5, "CAcmPort::DoSetBufferLengths;iReader=%p", iReader );
       
  1059 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
  1060 		}
       
  1061 	// Sart trying to resize buffers. Start with the reader. 
  1010 	// Sart trying to resize buffers. Start with the reader. 
  1062 	// Before we start though, set some stuff up we may need later (see 
  1011 	// Before we start though, set some stuff up we may need later (see 
  1063 	// comments below).
  1012 	// comments below).
  1064 	const TUint oldSize = iReader->BufSize();
  1013 	const TUint oldSize = iReader->BufSize();
  1065 	HBufC* dummyBuffer = HBufC::New(static_cast<TInt>(oldSize));
  1014 	HBufC* dummyBuffer = HBufC::New(static_cast<TInt>(oldSize));
  1066 	if ( !dummyBuffer )
  1015 	if ( !dummyBuffer )
  1067 		{
  1016 		{
  1068 		// If we can't allocate the dummy buffer, we can't guarantee that we 
  1017 		// If we can't allocate the dummy buffer, we can't guarantee that we 
  1069 		// can roll back this API safely if it fails halfway through. So abort 
  1018 		// can roll back this API safely if it fails halfway through. So abort 
  1070 		// the entire operation.
  1019 		// the entire operation.
  1071 		OstTrace0( TRACE_NORMAL, CACMPORT_DOSETBUFFERLENGTHS_DUP1, "CAcmPort::DoSetBufferLengths;\t***failed to allocate dummy buffer- returning KErrNoMemory" );
  1020 		LOGTEXT(_L8("\t***failed to allocate dummy buffer- "
  1072 		OstTraceFunctionExit0( CACMPORT_DOSETBUFFERLENGTHS_EXIT );
  1021 			"returning KErrNoMemory"));
  1073 		return KErrNoMemory;
  1022 		return KErrNoMemory;
  1074 		}
  1023 		}
  1075 
  1024 
  1076 	TInt ret = iReader->SetBufSize(aLength);
  1025 	TInt ret = iReader->SetBufSize(aLength);
  1077 	if ( ret )
  1026 	if ( ret )
  1078 		{
  1027 		{
  1079 		// A failure in SetBufSize will have maintained the old buffer 
  1028 		// A failure in SetBufSize will have maintained the old buffer 
  1080 		// (i.e. at its old size). This is a safe failure case- simply 
  1029 		// (i.e. at its old size). This is a safe failure case- simply 
  1081 		// clean up and return the error to the client.
  1030 		// clean up and return the error to the client.
  1082 		delete dummyBuffer;
  1031 		delete dummyBuffer;
  1083 		OstTrace1( TRACE_NORMAL, CACMPORT_DOSETBUFFERLENGTHS_DUP2, "CAcmPort::DoSetBufferLengths;\t***SetBufSize on reader failed with %d", ret );
  1032 		LOGTEXT2(_L8("\t***SetBufSize on reader failed with %d"), ret);
  1084 		OstTraceFunctionExit0( CACMPORT_DOSETBUFFERLENGTHS_EXIT_DUP1 );
       
  1085 		return ret;
  1033 		return ret;
  1086 		}
  1034 		}
  1087 
  1035 
  1088 	// OK, the Rx buffer has been resized, now for the Tx buffer...
  1036 	// OK, the Rx buffer has been resized, now for the Tx buffer...
  1089 	if (!iWriter)
  1037 	__ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
  1090 		{
       
  1091 		OstTraceExt1( TRACE_FATAL, CACMPORT_DOSETBUFFERLENGTHS_DUP6, "CAcmPort::DoSetBufferLengths;iWriter=%p", iWriter );
       
  1092 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
  1093 		}
       
  1094 	ret = iWriter->SetBufSize(aLength);
  1038 	ret = iWriter->SetBufSize(aLength);
  1095 	if ( ret )
  1039 	if ( ret )
  1096 		{
  1040 		{
  1097 		// Failure! The Tx buffer is still safe, at its old size. However, 
  1041 		// Failure! The Tx buffer is still safe, at its old size. However, 
  1098 		// to maintain the integrity of the API we need to reset the Rx 
  1042 		// to maintain the integrity of the API we need to reset the Rx 
  1099 		// buffer back to the old size. To make sure that this will work, free 
  1043 		// buffer back to the old size. To make sure that this will work, free 
  1100 		// the dummy buffer we initially allocated.
  1044 		// the dummy buffer we initially allocated.
  1101 		delete dummyBuffer;
  1045 		delete dummyBuffer;
  1102 		OstTrace1( TRACE_NORMAL, CACMPORT_DOSETBUFFERLENGTHS_DUP3, "CAcmPort::DoSetBufferLengths;\t***SetBufSize on writer failed with %d", ret );
  1046 		LOGTEXT2(_L8("\t***SetBufSize on writer failed with %d"), ret);
  1103 		TInt err = iReader->SetBufSize(oldSize);
  1047 		TInt err = iReader->SetBufSize(oldSize);
  1104 		if (err)
  1048 		__ASSERT_DEBUG(!err, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
  1105 			{
       
  1106 			OstTrace1( TRACE_FATAL, CACMPORT_DOSETBUFFERLENGTHS_DUP7, "CAcmPort::DoSetBufferLengths;err=%d", err );
       
  1107 			__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
  1108 			}
       
  1109 		static_cast<void>(err);
  1049 		static_cast<void>(err);
  1110 		// Now both buffers are at the size they started at, and the 
  1050 		// Now both buffers are at the size they started at, and the 
  1111 		// request failed with error code 'ret'.
  1051 		// request failed with error code 'ret'.
  1112 		OstTraceFunctionExit0( CACMPORT_DOSETBUFFERLENGTHS_EXIT_DUP2 );
       
  1113 		return ret;
  1052 		return ret;
  1114 		}
  1053 		}
  1115 
  1054 
  1116 	// We seem to have successfully resized both buffers... clean up and 
  1055 	// We seem to have successfully resized both buffers... clean up and 
  1117 	// return.
  1056 	// return.
  1118 	delete dummyBuffer;
  1057 	delete dummyBuffer;
  1119 	OstTrace0( TRACE_NORMAL, CACMPORT_DOSETBUFFERLENGTHS_DUP4, "CAcmPort::DoSetBufferLengths;\treturning KErrNone" );
  1058 	
  1120 	OstTraceFunctionExit0( CACMPORT_DOSETBUFFERLENGTHS_EXIT_DUP3 );
  1059 	LOGTEXT(_L8("\treturning KErrNone"));
  1121 	return KErrNone;
  1060 	return KErrNone;
  1122 	}
  1061 	}
  1123 
  1062 
  1124 TInt CAcmPort::SetReceiveBufferLength(TInt aLength)
  1063 TInt CAcmPort::SetReceiveBufferLength(TInt aLength)
  1125 /**
  1064 /**
  1129  *
  1068  *
  1130  * @param aLength new length of Tx and Rx buffer
  1069  * @param aLength new length of Tx and Rx buffer
  1131  * @return Error.
  1070  * @return Error.
  1132  */
  1071  */
  1133 	{
  1072 	{
  1134 	OstTraceFunctionEntry0( CACMPORT_SETRECEIVEBUFFERLENGTH_ENTRY );
  1073 	LOG_LINE
  1135 	OstTrace1( TRACE_NORMAL, CACMPORT_SETRECEIVEBUFFERLENGTH, "CAcmPort::SetReceiveBufferLength;aLength=%d", aLength );
  1074 	LOG_FUNC
  1136 	if ( !iAcm )
  1075 	LOGTEXT2(_L8("\taLength=%d"), aLength);
  1137 		{
  1076 
  1138 		OstTrace0( TRACE_NORMAL, CACMPORT_SETRECEIVEBUFFERLENGTH_DUP1, "CAcmPort::SetReceiveBufferLength;\t***access denied" );
  1077 	if ( !iAcm )
  1139 		OstTraceFunctionExit0( CACMPORT_SETRECEIVEBUFFERLENGTH_EXIT );
  1078 		{
       
  1079 		LOGTEXT(_L8("\t***access denied"));
  1140 		return KErrAccessDenied;
  1080 		return KErrAccessDenied;
  1141 		}
  1081 		}
  1142 
  1082 
  1143 	TInt ret = DoSetBufferLengths(static_cast<TUint>(aLength));
  1083 	TInt ret = DoSetBufferLengths(static_cast<TUint>(aLength));
  1144 	OstTrace1( TRACE_NORMAL, CACMPORT_SETRECEIVEBUFFERLENGTH_DUP2, "CAcmPort::SetReceiveBufferLength;\tDoSetBufferLengths = return value = %d", ret );
  1084 	LOGTEXT2(_L8("\tDoSetBufferLengths=%d"), ret);
  1145 	OstTraceFunctionExit0( CACMPORT_SETRECEIVEBUFFERLENGTH_EXIT_DUP1 );
  1085 	LOGTEXT2(_L8("\treturning %d"), ret);
  1146 	return ret;
  1086 	return ret;
  1147 	}
  1087 	}
  1148 
  1088 
  1149 void CAcmPort::Destruct()
  1089 void CAcmPort::Destruct()
  1150 /**
  1090 /**
  1151  * Downcall from C32. Destruct - we must (eventually) call delete this
  1091  * Downcall from C32. Destruct - we must (eventually) call delete this
  1152  */
  1092  */
  1153 	{
  1093 	{
  1154 	OstTraceFunctionEntry0( CACMPORT_DESTRUCT_ENTRY );
  1094 	LOG_FUNC
       
  1095 
  1155 	delete this;
  1096 	delete this;
  1156 	OstTraceFunctionExit0( CACMPORT_DESTRUCT_EXIT );
       
  1157 	}
  1097 	}
  1158 
  1098 
  1159 void CAcmPort::FreeMemory()
  1099 void CAcmPort::FreeMemory()
  1160 /**
  1100 /**
  1161  * Downcall from C32. Attempt to reduce our memory foot print.
  1101  * Downcall from C32. Attempt to reduce our memory foot print.
  1162  * Implemented to do nothing.
  1102  * Implemented to do nothing.
  1163  */
  1103  */
  1164 	{
  1104 	{
  1165 	OstTraceFunctionEntry0( CACMPORT_FREEMEMORY_ENTRY );
  1105 	LOG_LINE
  1166 	OstTraceFunctionExit0( CACMPORT_FREEMEMORY_EXIT );
  1106 	LOG_FUNC
  1167 	}
  1107 	}
  1168 
  1108 
  1169 void CAcmPort::NotifyDataAvailable()
  1109 void CAcmPort::NotifyDataAvailable()
  1170 /**
  1110 /**
  1171  * Downcall from C32. Notify client when data is available. 
  1111  * Downcall from C32. Notify client when data is available. 
  1172  */
  1112  */
  1173 	{
  1113 	{
  1174 	OstTraceFunctionEntry0( CACMPORT_NOTIFYDATAAVAILABLE_ENTRY );
  1114 	LOG_LINE
  1175 	if ( !iAcm )
  1115 	LOG_FUNC
  1176 		{
  1116 
  1177 		OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYDATAAVAILABLE, "CAcmPort::NotifyDataAvailable;\t***access denied" );
  1117 	if ( !iAcm )
       
  1118 		{
       
  1119 		LOGTEXT(_L8("\t***access denied"));
  1178 		NotifyDataAvailableCompleted(KErrAccessDenied);
  1120 		NotifyDataAvailableCompleted(KErrAccessDenied);
  1179 		OstTraceFunctionExit0( CACMPORT_NOTIFYDATAAVAILABLE_EXIT );
       
  1180 		return;
  1121 		return;
  1181 		}
  1122 		}
  1182 	
  1123 	__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
  1183 	if (!iReader)
  1124 
  1184 		{
       
  1185 		OstTraceExt1( TRACE_FATAL, CACMPORT_NOTIFYDATAAVAILABLE_DUP1, "CAcmPort::NotifyDataAvailable;iReader=%p", iReader );
       
  1186 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
  1187 		}
       
  1188 	iReader->NotifyDataAvailable();		
  1125 	iReader->NotifyDataAvailable();		
  1189 	OstTraceFunctionExit0( CACMPORT_NOTIFYDATAAVAILABLE_EXIT_DUP1 );
       
  1190 	}
  1126 	}
  1191 
  1127 
  1192 void CAcmPort::NotifyDataAvailableCancel()
  1128 void CAcmPort::NotifyDataAvailableCancel()
  1193 /**
  1129 /**
  1194  * Downcall from C32. Cancel an outstanding data available notification. Note 
  1130  * Downcall from C32. Cancel an outstanding data available notification. Note 
  1195  * that C32 actually completes the client's request for us.
  1131  * that C32 actually completes the client's request for us.
  1196  */
  1132  */
  1197 	{
  1133 	{
  1198 	OstTraceFunctionEntry0( CACMPORT_NOTIFYDATAAVAILABLECANCEL_ENTRY );
  1134 	LOG_LINE
  1199 	
  1135 	LOG_FUNC
  1200 	if ( !iAcm )
  1136 
  1201 		{
  1137 	if ( !iAcm )
  1202 		OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYDATAAVAILABLECANCEL, "CAcmPort::NotifyDataAvailableCancel;\t***access denied" );
  1138 		{
  1203 		OstTraceFunctionExit0( CACMPORT_NOTIFYDATAAVAILABLECANCEL_EXIT );
  1139 		LOGTEXT(_L8("\t***access denied"));
  1204 		return;
  1140 		return;
  1205 		}
  1141 		}
  1206 
  1142 	__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
  1207 	if (!iReader)
  1143 
  1208 		{
       
  1209 		OstTraceExt1( TRACE_FATAL, CACMPORT_NOTIFYDATAAVAILABLECANCEL_DUP1, "CAcmPort::NotifyDataAvailableCancel;iReader=%p", iReader );
       
  1210 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
  1211 		}
       
  1212 	iReader->NotifyDataAvailableCancel();
  1144 	iReader->NotifyDataAvailableCancel();
  1213 	OstTraceFunctionExit0( CACMPORT_NOTIFYDATAAVAILABLECANCEL_EXIT_DUP1 );
       
  1214 	}
  1145 	}
  1215 
  1146 
  1216 TInt CAcmPort::GetFlowControlStatus(TFlowControl& /*aFlowControl*/)
  1147 TInt CAcmPort::GetFlowControlStatus(TFlowControl& /*aFlowControl*/)
  1217 /**
  1148 /**
  1218  * Downcall from C32. Get the flow control status. NB This is not supported.
  1149  * Downcall from C32. Get the flow control status. NB This is not supported.
  1219  *
  1150  *
  1220  * @param aFlowControl flow control status will be written to this descriptor
  1151  * @param aFlowControl flow control status will be written to this descriptor
  1221  * @return Error.
  1152  * @return Error.
  1222  */
  1153  */
  1223 	{
  1154 	{
  1224 	OstTraceFunctionEntry0( CACMPORT_GETFLOWCONTROLSTATUS_ENTRY );
  1155 	LOG_LINE
  1225 	
  1156 	LOG_FUNC
  1226 	if ( !iAcm )
  1157 
  1227 		{
  1158 	if ( !iAcm )
  1228 		OstTrace0( TRACE_NORMAL, CACMPORT_GETFLOWCONTROLSTATUS, "CAcmPort::GetFlowControlStatus;\t***access denied" );
  1159 		{
  1229 		OstTraceFunctionExit0( CACMPORT_GETFLOWCONTROLSTATUS_EXIT );
  1160 		LOGTEXT(_L8("\t***access denied"));
  1230 		return KErrAccessDenied;
  1161 		return KErrAccessDenied;
  1231 		}
  1162 		}
  1232 
  1163 
  1233 	OstTrace0( TRACE_NORMAL, CACMPORT_GETFLOWCONTROLSTATUS_DUP1, "CAcmPort::GetFlowControlStatus;\t***not supported" );
  1164 	LOGTEXT(_L8("\t***not supported"));
  1234 	OstTraceFunctionExit0( CACMPORT_GETFLOWCONTROLSTATUS_EXIT_DUP1 );
       
  1235 	return KErrNotSupported;
  1165 	return KErrNotSupported;
  1236 	}
  1166 	}
  1237 
  1167 
  1238 void CAcmPort::NotifyOutputEmpty()
  1168 void CAcmPort::NotifyOutputEmpty()
  1239 /**
  1169 /**
  1241  * that this is not supported. Write requests only complete when the data has 
  1171  * that this is not supported. Write requests only complete when the data has 
  1242  * been sent to the LDD (KConfigWriteBufferedComplete is not supported) so 
  1172  * been sent to the LDD (KConfigWriteBufferedComplete is not supported) so 
  1243  * it's not very useful.
  1173  * it's not very useful.
  1244  */
  1174  */
  1245 	{
  1175 	{
  1246 	OstTraceFunctionEntry0( CACMPORT_NOTIFYOUTPUTEMPTY_ENTRY );
  1176 	LOG_LINE
  1247 	
  1177 	LOG_FUNC
  1248 	if ( !iAcm )
  1178 
  1249 		{
  1179 	if ( !iAcm )
  1250 		OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYOUTPUTEMPTY, "CAcmPort::NotifyOutputEmpty;\t***access denied" );
  1180 		{
       
  1181 		LOGTEXT(_L8("\t***access denied"));
  1251 		NotifyOutputEmptyCompleted(KErrAccessDenied);
  1182 		NotifyOutputEmptyCompleted(KErrAccessDenied);
  1252 		OstTraceFunctionExit0( CACMPORT_NOTIFYOUTPUTEMPTY_EXIT );
       
  1253 		return;
  1183 		return;
  1254 		}
  1184 		}
  1255 
  1185 
  1256 	OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYOUTPUTEMPTY_DUP1, "CAcmPort::NotifyOutputEmpty;\t***not supported" );
  1186 	LOGTEXT(_L8("\t***not supported"));
  1257 	NotifyOutputEmptyCompleted(KErrNotSupported);
  1187 	NotifyOutputEmptyCompleted(KErrNotSupported);
  1258 	OstTraceFunctionExit0( CACMPORT_NOTIFYOUTPUTEMPTY_EXIT_DUP1 );
       
  1259 	}
  1188 	}
  1260 
  1189 
  1261 void CAcmPort::NotifyOutputEmptyCancel()
  1190 void CAcmPort::NotifyOutputEmptyCancel()
  1262 /**
  1191 /**
  1263  * Downcall from C32. Cancel a pending request to be notified when the output 
  1192  * Downcall from C32. Cancel a pending request to be notified when the output 
  1264  * buffer is empty. Note that C32 actually completes the client's request for 
  1193  * buffer is empty. Note that C32 actually completes the client's request for 
  1265  * us.
  1194  * us.
  1266  */
  1195  */
  1267 	{
  1196 	{
  1268 	OstTraceFunctionEntry0( CACMPORT_NOTIFYOUTPUTEMPTYCANCEL_ENTRY );
  1197 	LOG_LINE
  1269 	OstTraceFunctionExit0( CACMPORT_NOTIFYOUTPUTEMPTYCANCEL_EXIT );
  1198 	LOG_FUNC
  1270 	}
  1199 	}
  1271 
  1200 
  1272 void CAcmPort::NotifyBreak()
  1201 void CAcmPort::NotifyBreak()
  1273 /**
  1202 /**
  1274  * Downcall from C32. Notify a client of a host-driven break on the serial 
  1203  * Downcall from C32. Notify a client of a host-driven break on the serial 
  1275  * line.
  1204  * line.
  1276  */
  1205  */
  1277 	{
  1206 	{
  1278 	OstTraceFunctionEntry0( CACMPORT_NOTIFYBREAK_ENTRY );
  1207 	LOG_LINE
  1279 	
  1208 	LOG_FUNC
  1280 	if ( !iAcm )
  1209 
  1281 		{
  1210 	if ( !iAcm )
  1282 		OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYBREAK, "CAcmPort::NotifyBreak;\t***access denied" );
  1211 		{
       
  1212 		LOGTEXT(_L8("\t***access denied"));
  1283 		BreakNotifyCompleted(KErrAccessDenied);
  1213 		BreakNotifyCompleted(KErrAccessDenied);
  1284 		OstTraceFunctionExit0( CACMPORT_NOTIFYBREAK_EXIT );
       
  1285 		return;
  1214 		return;
  1286 		}
  1215 		}
  1287 
  1216 
  1288 	// C32 protects us against this.
  1217 	// C32 protects us against this.
  1289 	if (iNotifyBreak)
  1218 	__ASSERT_DEBUG(!iNotifyBreak, 
  1290 		{
  1219 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
  1291 		OstTrace1( TRACE_FATAL, CACMPORT_NOTIFYBREAK_DUP1, "CAcmPort::NotifyBreak;iNotifyBreak=%d", (TInt)iNotifyBreak );
       
  1292 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
  1293 		}
       
  1294 
  1220 
  1295 	iNotifyBreak = ETrue;
  1221 	iNotifyBreak = ETrue;
  1296 	OstTraceFunctionExit0( CACMPORT_NOTIFYBREAK_EXIT_DUP1 );
       
  1297 	}
  1222 	}
  1298 
  1223 
  1299 void CAcmPort::NotifyBreakCancel()
  1224 void CAcmPort::NotifyBreakCancel()
  1300 /**
  1225 /**
  1301  * Downcall from C32. Cancel a pending notification of a serial line break. 
  1226  * Downcall from C32. Cancel a pending notification of a serial line break. 
  1302  * Note that C32 actually completes the client's request for us.
  1227  * Note that C32 actually completes the client's request for us.
  1303  */
  1228  */
  1304 	{
  1229 	{
  1305 	OstTraceFunctionEntry0( CACMPORT_NOTIFYBREAKCANCEL_ENTRY );
  1230 	LOG_LINE
  1306 	if ( !iAcm )
  1231 	LOG_FUNC
  1307 		{
  1232 
  1308 		OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYBREAKCANCEL, "CAcmPort::NotifyBreakCancel;\t***access denied" );
  1233 	if ( !iAcm )
  1309 		OstTraceFunctionExit0( CACMPORT_NOTIFYBREAKCANCEL_EXIT );
  1234 		{
       
  1235 		LOGTEXT(_L8("\t***access denied"));
  1310 		return;
  1236 		return;
  1311 		}
  1237 		}
  1312 
  1238 
  1313 	iNotifyBreak = EFalse;
  1239 	iNotifyBreak = EFalse;
  1314 	OstTraceFunctionExit0( CACMPORT_NOTIFYBREAKCANCEL_EXIT_DUP1 );
       
  1315 	}
  1240 	}
  1316 
  1241 
  1317 void CAcmPort::BreakRequestCompleted()
  1242 void CAcmPort::BreakRequestCompleted()
  1318 /**
  1243 /**
  1319  * Callback for completion of a break request. 
  1244  * Callback for completion of a break request. 
  1320  * This is called when the break state next goes inactive after a break has 
  1245  * This is called when the break state next goes inactive after a break has 
  1321  * been requested from the ACM port. 
  1246  * been requested from the ACM port. 
  1322  * This is implemented to complete the RComm client's Break request.
  1247  * This is implemented to complete the RComm client's Break request.
  1323  */
  1248  */
  1324  	{
  1249  	{
  1325 	OstTraceFunctionEntry0( CACMPORT_BREAKREQUESTCOMPLETED_ENTRY );
  1250 	LOG_FUNC
  1326 	
       
  1327 
  1251 
  1328 	if ( !iCancellingBreak )
  1252 	if ( !iCancellingBreak )
  1329 		{
  1253 		{
  1330 		OstTrace0( TRACE_NORMAL, CACMPORT_BREAKREQUESTCOMPLETED, "CAcmPort::BreakRequestCompleted;\tcalling BreakCompleted with KErrNone" );
  1254 		LOGTEXT(_L8("\tcalling BreakCompleted with KErrNone"));
  1331 		BreakCompleted(KErrNone);
  1255 		BreakCompleted(KErrNone);
  1332 		}
  1256 		}
  1333 	else
  1257 	else
  1334 		{
  1258 		{
  1335 		OstTrace0( TRACE_NORMAL, CACMPORT_BREAKREQUESTCOMPLETED_DUP1, "CAcmPort::BreakRequestCompleted;\tbreak is being cancelled-letting C32 complete the request" );
  1259 		LOGTEXT(_L8("\tbreak is being cancelled- "
       
  1260 			"letting C32 complete the request"));
  1336 		}
  1261 		}
  1337 	// In the event of an RComm::BreakCancel, this function is called 
  1262 	// In the event of an RComm::BreakCancel, this function is called 
  1338 	// sychronously with CAcmPort::BreakCancel, and C32 will complete the 
  1263 	// sychronously with CAcmPort::BreakCancel, and C32 will complete the 
  1339 	// original RComm::Break request with KErrCancel when that returns. So we 
  1264 	// original RComm::Break request with KErrCancel when that returns. So we 
  1340 	// only need to complete it if there isn't a cancel going on.
  1265 	// only need to complete it if there isn't a cancel going on.
  1341 	iBreak = EFalse;
  1266 	iBreak = EFalse;
  1342 	iCancellingBreak = EFalse;
  1267 	iCancellingBreak = EFalse;
  1343 	OstTraceFunctionExit0( CACMPORT_BREAKREQUESTCOMPLETED_EXIT );
       
  1344 	}
  1268 	}
  1345 
  1269 
  1346 void CAcmPort::BreakStateChange()
  1270 void CAcmPort::BreakStateChange()
  1347 /**
  1271 /**
  1348  * Callback for a change in the break state. 
  1272  * Callback for a change in the break state. 
  1351  * to.
  1275  * to.
  1352  * This is implemented to update our signal line flags, complete 
  1276  * This is implemented to update our signal line flags, complete 
  1353  * NotifySignalChange requests, and complete NotifyBreak requests.
  1277  * NotifySignalChange requests, and complete NotifyBreak requests.
  1354  */
  1278  */
  1355  	{
  1279  	{
  1356 	OstTraceFunctionEntry0( CACMPORT_BREAKSTATECHANGE_ENTRY );
  1280 	LOG_FUNC
       
  1281 
  1357 	// TODO: what if no iAcm?
  1282 	// TODO: what if no iAcm?
  1358 
  1283 
  1359 	// Take a copy of the current signal state for comparison later
  1284 	// Take a copy of the current signal state for comparison later
  1360 	TUint32 oldSignals = iSignals;
  1285 	TUint32 oldSignals = iSignals;
  1361 
  1286 
  1362 	// grab the state of the BREAK from the ACM class that manages
  1287 	// grab the state of the BREAK from the ACM class that manages
  1363 	// it and apply the appropriate flag state to the local iSignals
  1288 	// it and apply the appropriate flag state to the local iSignals
  1364 	if ( iAcm && iAcm->BreakActive() )
  1289 	if ( iAcm && iAcm->BreakActive() )
  1365 		{
  1290 		{
  1366 		OstTrace0( TRACE_NORMAL, CACMPORT_BREAKSTATECHANGE, "CAcmPort::BreakStateChange;\tbreak is active" );
  1291 		LOGTEXT(_L8("\tbreak is active"));
  1367 		iSignals |= KSignalBreak;
  1292 		iSignals |= KSignalBreak;
  1368 		}
  1293 		}
  1369 	else
  1294 	else
  1370 		{
  1295 		{
  1371 		OstTrace0( TRACE_NORMAL, CACMPORT_BREAKSTATECHANGE_DUP1, "CAcmPort::BreakStateChange;\tbreak is inactive" );
  1296 		LOGTEXT(_L8("\tbreak is inactive"));
  1372 		iSignals &= ~KSignalBreak;
  1297 		iSignals &= ~KSignalBreak;
  1373 		}
  1298 		}
  1374 
  1299 
  1375 	// first tell the client (if interested, and if it's not a client-driven 
  1300 	// first tell the client (if interested, and if it's not a client-driven 
  1376 	// break) that there has been a BREAK event of some sort (either into or 
  1301 	// break) that there has been a BREAK event of some sort (either into or 
  1377 	// out of the break-active condition...
  1302 	// out of the break-active condition...
  1378 	if ( iNotifyBreak && !iBreak )
  1303 	if ( iNotifyBreak && !iBreak )
  1379 		{
  1304 		{
  1380 		OstTrace0( TRACE_NORMAL, CACMPORT_BREAKSTATECHANGE_DUP2, "CAcmPort::BreakStateChange;\tcalling BreakNotifyCompleted with KErrNone" );
  1305 		LOGTEXT(_L8("\tcalling BreakNotifyCompleted with KErrNone"));
  1381 		BreakNotifyCompleted(KErrNone);
  1306 		BreakNotifyCompleted(KErrNone);
  1382 		iNotifyBreak = EFalse;
  1307 		iNotifyBreak = EFalse;
  1383 		}
  1308 		}
  1384 
  1309 
  1385 	// and now tell the client (again if interested) the new state
  1310 	// and now tell the client (again if interested) the new state
  1386 	// of the BREAK signal, if it has changed
  1311 	// of the BREAK signal, if it has changed
  1387 	if (	iNotifySignalChange
  1312 	if (	iNotifySignalChange
  1388 		&&	( ( iNotifySignalMask & ( iSignals ^ oldSignals ) ) != 0 ) )
  1313 		&&	( ( iNotifySignalMask & ( iSignals ^ oldSignals ) ) != 0 ) )
  1389 		{
  1314 		{
  1390 		// Report correctly mapped signals that client asked for
  1315 		// Report correctly mapped signals that client asked for
  1391 		OstTrace0( TRACE_NORMAL, CACMPORT_BREAKSTATECHANGE_DUP3, "CAcmPort::BreakStateChange;\tcalling SignalChangeCompleted with KErrNone" );
  1316 		LOGTEXT(_L8("\tcalling SignalChangeCompleted with KErrNone"));
  1392 		TUint32 signals = ConvertSignals ( KBreakChanged | ( iSignals & iNotifySignalMask ) );
  1317 		TUint32 signals = ConvertSignals ( KBreakChanged | ( iSignals & iNotifySignalMask ) );
  1393 		SignalChangeCompleted( signals, KErrNone);
  1318 		SignalChangeCompleted( signals, KErrNone);
  1394 		iNotifySignalChange = EFalse;
  1319 		iNotifySignalChange = EFalse;
  1395 		}
  1320 		}
  1396 	OstTraceFunctionExit0( CACMPORT_BREAKSTATECHANGE_EXIT );
       
  1397 	}
  1321 	}
  1398 
  1322 
  1399 void CAcmPort::NotifyFlowControlChange()
  1323 void CAcmPort::NotifyFlowControlChange()
  1400 /**
  1324 /**
  1401  * Downcall from C32. Notify a client of a change in the flow control state. 
  1325  * Downcall from C32. Notify a client of a change in the flow control state. 
  1402  * Note that this is not supported.
  1326  * Note that this is not supported.
  1403  */
  1327  */
  1404 	{
  1328 	{
  1405 	OstTraceFunctionEntry0( CACMPORT_NOTIFYFLOWCONTROLCHANGE_ENTRY );
  1329 	LOG_LINE
  1406 	
  1330 	LOG_FUNC
  1407 	if ( !iAcm )
  1331 
  1408 		{
  1332 	if ( !iAcm )
  1409 		OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYFLOWCONTROLCHANGE, "CAcmPort::NotifyFlowControlChange;\t***access denied" );
  1333 		{
       
  1334 		LOGTEXT(_L8("\t***access denied"));
  1410 		FlowControlChangeCompleted(EFlowControlOn, KErrAccessDenied);
  1335 		FlowControlChangeCompleted(EFlowControlOn, KErrAccessDenied);
  1411 		OstTraceFunctionExit0( CACMPORT_NOTIFYFLOWCONTROLCHANGE_EXIT );
       
  1412 		return;
  1336 		return;
  1413 		}
  1337 		}
  1414 
  1338 
  1415 	OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYFLOWCONTROLCHANGE_DUP1, "CAcmPort::NotifyFlowControlChange;\t***not supported" );
  1339 	LOGTEXT(_L8("\t***not supported"));
  1416 	FlowControlChangeCompleted(EFlowControlOn,KErrNotSupported);
  1340 	FlowControlChangeCompleted(EFlowControlOn,KErrNotSupported);
  1417 	OstTraceFunctionExit0( CACMPORT_NOTIFYFLOWCONTROLCHANGE_EXIT_DUP1 );
       
  1418 	}
  1341 	}
  1419 
  1342 
  1420 void CAcmPort::NotifyFlowControlChangeCancel()
  1343 void CAcmPort::NotifyFlowControlChangeCancel()
  1421 /**
  1344 /**
  1422  * Downcall from C32. Cancel a pending request to be notified when the flow 
  1345  * Downcall from C32. Cancel a pending request to be notified when the flow 
  1423  * control state changes. Note that C32 actually completes the client's 
  1346  * control state changes. Note that C32 actually completes the client's 
  1424  * request for us.
  1347  * request for us.
  1425  */
  1348  */
  1426 	{
  1349 	{
  1427 	OstTraceFunctionEntry0( CACMPORT_NOTIFYFLOWCONTROLCHANGECANCEL_ENTRY );
  1350 	LOG_LINE
  1428 	OstTraceFunctionExit0( CACMPORT_NOTIFYFLOWCONTROLCHANGECANCEL_EXIT );
  1351 	LOG_FUNC
  1429 	}
  1352 	}
  1430 
  1353 
  1431 void CAcmPort::NotifyConfigChange()
  1354 void CAcmPort::NotifyConfigChange()
  1432 /**
  1355 /**
  1433  * Downcall from C32. Notify a client of a change to the serial port 
  1356  * Downcall from C32. Notify a client of a change to the serial port 
  1434  * configuration.
  1357  * configuration.
  1435  */
  1358  */
  1436 	{
  1359 	{
  1437 	OstTraceFunctionEntry0( CACMPORT_NOTIFYCONFIGCHANGE_ENTRY );
  1360 	LOG_LINE
  1438 	
  1361 	LOG_FUNC
  1439 	if ( !iAcm )
  1362 
  1440 		{
  1363 	if ( !iAcm )
  1441 		OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYCONFIGCHANGE, "CAcmPort::NotifyConfigChange;\t***access denied" );
  1364 		{
       
  1365 		LOGTEXT(_L8("\t***access denied"));
  1442 		ConfigChangeCompleted(iCommNotificationDes, KErrAccessDenied);
  1366 		ConfigChangeCompleted(iCommNotificationDes, KErrAccessDenied);
  1443 		OstTraceFunctionExit0( CACMPORT_NOTIFYCONFIGCHANGE_EXIT );
       
  1444 		return;
  1367 		return;
  1445 		}
  1368 		}
  1446 
  1369 
  1447 	if ( iNotifyConfigChange )
  1370 	if ( iNotifyConfigChange )
  1448 		{
  1371 		{
  1449 		OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYCONFIGCHANGE_DUP1, "CAcmPort::NotifyConfigChange;\t***in use" );
  1372 		LOGTEXT(_L8("\t***in use"));
  1450 		ConfigChangeCompleted(iCommNotificationDes,KErrInUse);
  1373 		ConfigChangeCompleted(iCommNotificationDes,KErrInUse);
  1451 		}
  1374 		}
  1452 	else
  1375 	else
  1453 		{
  1376 		{
  1454 		iNotifyConfigChange = ETrue;
  1377 		iNotifyConfigChange = ETrue;
  1455 		}
  1378 		}
  1456 	OstTraceFunctionExit0( CACMPORT_NOTIFYCONFIGCHANGE_EXIT_DUP1 );
       
  1457 	}
  1379 	}
  1458 
  1380 
  1459 void CAcmPort::NotifyConfigChangeCancel()
  1381 void CAcmPort::NotifyConfigChangeCancel()
  1460 /**
  1382 /**
  1461  * Downcall from C32. Cancel a pending request to be notified of a change to 
  1383  * Downcall from C32. Cancel a pending request to be notified of a change to 
  1462  * the serial port configuration. Note that C32 actually completes the 
  1384  * the serial port configuration. Note that C32 actually completes the 
  1463  * client's request for us.
  1385  * client's request for us.
  1464  */
  1386  */
  1465 	{
  1387 	{
  1466 	OstTraceFunctionEntry0( CACMPORT_NOTIFYCONFIGCHANGECANCEL_ENTRY );
  1388 	LOG_LINE
  1467 	
  1389 	LOG_FUNC
  1468 	if ( !iAcm )
  1390 
  1469 		{
  1391 	if ( !iAcm )
  1470 		OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYCONFIGCHANGECANCEL, "CAcmPort::NotifyConfigChangeCancel;\t***access denied" );
  1392 		{
  1471 		OstTraceFunctionExit0( CACMPORT_NOTIFYCONFIGCHANGECANCEL_EXIT );
  1393 		LOGTEXT(_L8("\t***access denied"));
  1472 		return;
  1394 		return;
  1473 		}
  1395 		}
  1474 
  1396 
  1475 	iNotifyConfigChange = EFalse;
  1397 	iNotifyConfigChange = EFalse;
  1476 	OstTraceFunctionExit0( CACMPORT_NOTIFYCONFIGCHANGECANCEL_EXIT_DUP1 );
       
  1477 	}
  1398 	}
  1478 
  1399 
  1479 void CAcmPort::HostConfigChange(const TCommConfigV01& aConfig)
  1400 void CAcmPort::HostConfigChange(const TCommConfigV01& aConfig)
  1480 /**
  1401 /**
  1481  * Callback from a "host-pushed" configuration change packet.
  1402  * Callback from a "host-pushed" configuration change packet.
  1482  *
  1403  *
  1483  * @param aConfig	New configuration data.
  1404  * @param aConfig	New configuration data.
  1484  */
  1405  */
  1485 	{
  1406 	{
  1486 	OstTraceFunctionEntry0( CACMPORT_HOSTCONFIGCHANGE_ENTRY );
  1407 	LOG_FUNC
       
  1408 
  1487 	HandleConfigNotification(aConfig.iRate,
  1409 	HandleConfigNotification(aConfig.iRate,
  1488 		aConfig.iDataBits,
  1410 		aConfig.iDataBits,
  1489 		aConfig.iParity,
  1411 		aConfig.iParity,
  1490 		aConfig.iStopBits,
  1412 		aConfig.iStopBits,
  1491 		iCommConfig.iHandshake);
  1413 		iCommConfig.iHandshake);
  1492 	iCommConfig.iRate = aConfig.iRate;
  1414 	iCommConfig.iRate = aConfig.iRate;
  1493 	iCommConfig.iDataBits = aConfig.iDataBits;
  1415 	iCommConfig.iDataBits = aConfig.iDataBits;
  1494 	iCommConfig.iParity = aConfig.iParity;
  1416 	iCommConfig.iParity = aConfig.iParity;
  1495 	iCommConfig.iStopBits = aConfig.iStopBits;
  1417 	iCommConfig.iStopBits = aConfig.iStopBits;
  1496 	OstTraceFunctionExit0( CACMPORT_HOSTCONFIGCHANGE_EXIT );
       
  1497 	}
  1418 	}
  1498 
  1419 
  1499 void CAcmPort::NotifySignalChange(TUint aSignalMask)
  1420 void CAcmPort::NotifySignalChange(TUint aSignalMask)
  1500 /**
  1421 /**
  1501  * Downcall from C32. Notify a client of a change to the signal lines.
  1422  * Downcall from C32. Notify a client of a change to the signal lines.
  1502  */
  1423  */
  1503 	{
  1424 	{
  1504 	OstTraceFunctionEntry0( CACMPORT_NOTIFYSIGNALCHANGE_ENTRY );
  1425 	LOG_LINE
  1505 	OstTrace1( TRACE_NORMAL, CACMPORT_NOTIFYSIGNALCHANGE, "CAcmPort::NotifySignalChange;>>CAcmPort::NotifySignalChange aSignalMask=0x%08x", aSignalMask );
  1426 	LOGTEXT2(_L8(">>CAcmPort::NotifySignalChange aSignalMask=0x%08x"), 
       
  1427 		aSignalMask);
       
  1428 
  1506 	if ( iNotifySignalChange )
  1429 	if ( iNotifySignalChange )
  1507 		{
  1430 		{
  1508 		if ( !iAcm )
  1431 		if ( !iAcm )
  1509 			{
  1432 			{
  1510 			OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYSIGNALCHANGE_DUP1, "CAcmPort::NotifySignalChange;\t***access denied" );
  1433 			LOGTEXT(_L8("\t***access denied"));
  1511 			SignalChangeCompleted(0, KErrAccessDenied);
  1434 			SignalChangeCompleted(0, KErrAccessDenied);
  1512 			}
  1435 			}
  1513 		else
  1436 		else
  1514 			{
  1437 			{
  1515 			OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYSIGNALCHANGE_DUP2, "CAcmPort::NotifySignalChange;\t***in use" );
  1438 			LOGTEXT(_L8("\t***in use"));
  1516 			SignalChangeCompleted(0, KErrInUse);
  1439 			SignalChangeCompleted(0, KErrInUse);
  1517 			}
  1440 			}
  1518 		}
  1441 		}
  1519 	else
  1442 	else
  1520 		{
  1443 		{
  1522 		// convert signals to internal format
  1445 		// convert signals to internal format
  1523 		// no need to filter as can notify on inputs or outputs
  1446 		// no need to filter as can notify on inputs or outputs
  1524 		iNotifySignalMask = ConvertSignals(aSignalMask);
  1447 		iNotifySignalMask = ConvertSignals(aSignalMask);
  1525 		}
  1448 		}
  1526 
  1449 
  1527 	OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYSIGNALCHANGE_DUP3, "CAcmPort::NotifySignalChange;<<CAcmPort::NotifySignalChange" );
  1450 	LOGTEXT(_L8("<<CAcmPort::NotifySignalChange"));
  1528 	OstTraceFunctionExit0( CACMPORT_NOTIFYSIGNALCHANGE_EXIT );
       
  1529 	}
  1451 	}
  1530 
  1452 
  1531 void CAcmPort::NotifySignalChangeCancel()
  1453 void CAcmPort::NotifySignalChangeCancel()
  1532 /**
  1454 /**
  1533  * Downcall from C32. Cancel a pending client request to be notified about a 
  1455  * Downcall from C32. Cancel a pending client request to be notified about a 
  1534  * change to the signal lines. Note that C32 actually completes the client's 
  1456  * change to the signal lines. Note that C32 actually completes the client's 
  1535  * request for us.
  1457  * request for us.
  1536  */
  1458  */
  1537 	{
  1459 	{
  1538 	OstTraceFunctionEntry0( CACMPORT_NOTIFYSIGNALCHANGECANCEL_ENTRY );
  1460 	LOG_LINE
  1539 	
  1461 	LOG_FUNC
  1540 	if ( !iAcm )
  1462 
  1541 		{
  1463 	if ( !iAcm )
  1542 		OstTrace0( TRACE_NORMAL, CACMPORT_NOTIFYSIGNALCHANGECANCEL, "CAcmPort::NotifySignalChangeCancel;\t***access denied" );
  1464 		{
  1543 		OstTraceFunctionExit0( CACMPORT_NOTIFYSIGNALCHANGECANCEL_EXIT );
  1465 		LOGTEXT(_L8("\t***access denied"));
  1544 		return;
  1466 		return;
  1545 		}
  1467 		}
  1546 
  1468 
  1547 	iNotifySignalChange = EFalse;
  1469 	iNotifySignalChange = EFalse;
  1548 	OstTraceFunctionExit0( CACMPORT_NOTIFYSIGNALCHANGECANCEL_EXIT_DUP1 );
       
  1549 	}
  1470 	}
  1550 
  1471 
  1551 void CAcmPort::HostSignalChange(TBool aDtr, TBool aRts)
  1472 void CAcmPort::HostSignalChange(TBool aDtr, TBool aRts)
  1552 /**
  1473 /**
  1553  * Callback from a "host-pushed" line state change.
  1474  * Callback from a "host-pushed" line state change.
  1554  *
  1475  *
  1555  * @param aDtr The state of the DTR signal.
  1476  * @param aDtr The state of the DTR signal.
  1556  * @param aRts The state of the RTS signal.
  1477  * @param aRts The state of the RTS signal.
  1557  */
  1478  */
  1558 	{
  1479 	{
  1559 	OstTraceFunctionEntry0( CACMPORT_HOSTSIGNALCHANGE_ENTRY );
  1480 	LOGTEXT3(_L8(">>CAcmPort::HostSignalChange aDtr=%d, aRts=%d"), aDtr, aRts);
  1560 	OstTraceExt2( TRACE_NORMAL, CACMPORT_HOSTSIGNALCHANGE, "CAcmPort::HostSignalChange;>>CAcmPort::HostSignalChange aDtr=%d, aRts=%d", aDtr, aRts );
  1481 
  1561 	
       
  1562 	// Take a copy of the current signal state for comparison later
  1482 	// Take a copy of the current signal state for comparison later
  1563 	TUint32 oldSignals = iSignals;
  1483 	TUint32 oldSignals = iSignals;
  1564 
  1484 
  1565 	if ( aDtr )
  1485 	if ( aDtr )
  1566 		{
  1486 		{
  1584 	// and the mask shows the upper layer wanted to be sensitive to these signals.
  1504 	// and the mask shows the upper layer wanted to be sensitive to these signals.
  1585 	if ( iNotifySignalChange )
  1505 	if ( iNotifySignalChange )
  1586 		{
  1506 		{
  1587 		// Create bitfield of changed signals that client is interested in
  1507 		// Create bitfield of changed signals that client is interested in
  1588 		TUint32 changedSignals = ( iSignals ^ oldSignals ) & iNotifySignalMask;
  1508 		TUint32 changedSignals = ( iSignals ^ oldSignals ) & iNotifySignalMask;
  1589 		OstTraceExt4( TRACE_NORMAL, CACMPORT_HOSTSIGNALCHANGE_DUP1, "CAcmPort::HostSignalChange;iSignals=%x;oldSignals=%x;changedSignals=%x;iNotifySignalMask=%x", iSignals, oldSignals, changedSignals, (TUint32)iNotifySignalMask );
  1509 		LOGTEXT5(_L8("\tiSignals=%x, oldSignals=%x, changedSignals=%x, iNotifySignalMask=%x")
       
  1510 						,iSignals, oldSignals, changedSignals, iNotifySignalMask);
  1590 		if ( changedSignals != 0 )
  1511 		if ( changedSignals != 0 )
  1591 			{
  1512 			{
  1592 			// Mark which signals have changed
  1513 			// Mark which signals have changed
  1593 			TUint32 changedSignalsMask = 0;
  1514 			TUint32 changedSignalsMask = 0;
  1594 			if ( ( changedSignals & KSignalDTR ) != 0 )
  1515 			if ( ( changedSignals & KSignalDTR ) != 0 )
  1597 				}
  1518 				}
  1598 			if ( ( changedSignals & KSignalRTS ) != 0 )
  1519 			if ( ( changedSignals & KSignalRTS ) != 0 )
  1599 				{
  1520 				{
  1600 				changedSignalsMask |= KRTSChanged;
  1521 				changedSignalsMask |= KRTSChanged;
  1601 				}
  1522 				}
  1602 			
  1523 			LOGTEXT2(_L8("\tchangedSignalsMask=%x"), changedSignalsMask);
  1603 			OstTrace1( TRACE_NORMAL, CACMPORT_HOSTSIGNALCHANGE_DUP2, "CAcmPort::HostSignalChange;changedSignalsMask=%x", changedSignalsMask );
  1524 
  1604 			// Report correctly mapped signals that client asked for
  1525 			// Report correctly mapped signals that client asked for
  1605 			TUint32 signals = ConvertSignals ( changedSignalsMask | ( iSignals & iNotifySignalMask ) );
  1526 			TUint32 signals = ConvertSignals ( changedSignalsMask | ( iSignals & iNotifySignalMask ) );
  1606 			OstTrace1( TRACE_NORMAL, CACMPORT_HOSTSIGNALCHANGE_DUP3, "CAcmPort::HostSignalChange;signals=%x", signals );
  1527 			LOGTEXT2(_L8("\tcalling SignalChangeCompleted with KErrNone, signals=%x"), signals);
  1607 			SignalChangeCompleted( signals, KErrNone);
  1528 			SignalChangeCompleted( signals, KErrNone);
  1608 			iNotifySignalChange = EFalse;
  1529 			iNotifySignalChange = EFalse;
  1609 			}
  1530 			}
  1610 		}
  1531 		}
  1611 
  1532 
  1612 	OstTrace0( TRACE_NORMAL, CACMPORT_HOSTSIGNALCHANGE_DUP4, "CAcmPort::HostSignalChange;<<CAcmPort::HostSignalChange" );
  1533 	LOGTEXT(_L8("<<CAcmPort::HostSignalChange"));
  1613 	OstTraceFunctionExit0( CACMPORT_HOSTSIGNALCHANGE_EXIT );
       
  1614 	}
  1534 	}
  1615 
  1535 
  1616 TInt CAcmPort::GetRole(TCommRole& aRole)
  1536 TInt CAcmPort::GetRole(TCommRole& aRole)
  1617 /**
  1537 /**
  1618  * Downcall from C32. Get the role of this port unit
  1538  * Downcall from C32. Get the role of this port unit
  1619  *
  1539  *
  1620  * @param aRole reference to where the role will be written to
  1540  * @param aRole reference to where the role will be written to
  1621  * @return Error.
  1541  * @return Error.
  1622  */
  1542  */
  1623 	{
  1543 	{
  1624 	OstTraceFunctionEntry0( CACMPORT_GETROLE_ENTRY );
  1544 	LOG_LINE
  1625 	
  1545 	LOG_FUNC
  1626 	if ( !iAcm )
  1546 
  1627 		{
  1547 	if ( !iAcm )
  1628 		OstTrace0( TRACE_NORMAL, CACMPORT_GETROLE, "CAcmPort::GetRole;\t***access denied" );
  1548 		{
  1629 		OstTraceFunctionExit0( CACMPORT_GETROLE_EXIT );
  1549 		LOGTEXT(_L8("\t***access denied"));
  1630 		return KErrAccessDenied;
  1550 		return KErrAccessDenied;
  1631 		}
  1551 		}
  1632 
  1552 
  1633 	aRole = iRole;
  1553 	aRole = iRole;
  1634 	OstTrace1( TRACE_NORMAL, CACMPORT_GETROLE_DUP1, "CAcmPort::GetRole;\trole=%d", aRole );
  1554 	LOGTEXT2(_L8("\trole=%d"), aRole);
  1635 	OstTraceFunctionExit0( DUP1_CACMPORT_GETROLE_EXIT );
       
  1636 	return KErrNone;
  1555 	return KErrNone;
  1637 	}
  1556 	}
  1638 
  1557 
  1639 TInt CAcmPort::SetRole(TCommRole aRole)
  1558 TInt CAcmPort::SetRole(TCommRole aRole)
  1640 /**
  1559 /**
  1642  *
  1561  *
  1643  * @param aRole the new role
  1562  * @param aRole the new role
  1644  * @return Error.
  1563  * @return Error.
  1645  */
  1564  */
  1646 	{
  1565 	{
  1647 	OstTraceFunctionEntry0( CACMPORT_SETROLE_ENTRY );
  1566 	LOG_LINE
  1648 	OstTrace1( TRACE_NORMAL, CACMPORT_SETROLE, "CAcmPort::SetRole;>>CAcmPort::SetRole aRole=%d", aRole );
  1567 	LOGTEXT2(_L8(">>CAcmPort::SetRole aRole=%d"), aRole);
       
  1568 
  1649 	TInt ret = KErrNone;
  1569 	TInt ret = KErrNone;
  1650 	
       
  1651 	if ( !iAcm )
  1570 	if ( !iAcm )
  1652 		{
  1571 		{
  1653 		ret = KErrAccessDenied;
  1572 		ret = KErrAccessDenied;
  1654 		}
  1573 		}
  1655 	else
  1574 	else
  1656 		{
  1575 		{
  1657 		iRole = aRole;
  1576 		iRole = aRole;
  1658 		}
  1577 		}
  1659 
  1578 
  1660 	OstTrace1( TRACE_NORMAL, CACMPORT_SETROLE_DUP1, "CAcmPort::SetRole;<<CAcmPort::SetRole ret=%d", ret );
  1579 	LOGTEXT2(_L8("<<CAcmPort::SetRole ret=%d"), ret);
  1661 	OstTraceFunctionExit0( CACMPORT_SETROLE_EXIT );
       
  1662 	return ret;
  1580 	return ret;
  1663 	}
  1581 	}
  1664 
  1582 
  1665 void CAcmPort::SetAcm(CCdcAcmClass* aAcm)
  1583 void CAcmPort::SetAcm(CCdcAcmClass* aAcm)
  1666 /**
  1584 /**
  1674  * client requests onto the bus.
  1592  * client requests onto the bus.
  1675  *
  1593  *
  1676  * @param aAcm The new ACM (may be NULL).
  1594  * @param aAcm The new ACM (may be NULL).
  1677  */
  1595  */
  1678 	{
  1596 	{
  1679 	OstTraceFunctionEntry0( CACMPORT_SETACM_ENTRY );
  1597 	LOGTEXT3(_L8(">>CAcmPort::SetAcm aAcm = 0x%08x, iAcm = 0x%08x"), aAcm, iAcm);
  1680 	OstTrace1( TRACE_NORMAL, CACMPORT_SETACM, "CAcmPort::SetAcm;>>CAcmPort::SetAcm aAcm = 0x%08x", aAcm );
       
  1681 	OstTrace1( TRACE_NORMAL, CACMPORT_SETACM_DUP3, "CAcmPort::SetAcm;iAcm=0x%08x", iAcm );
       
  1682 	
       
  1683 	
  1598 	
  1684 	if ( !aAcm )
  1599 	if ( !aAcm )
  1685 		{
  1600 		{
  1686 		// Cancel any outstanding operations on the reader and writer.
  1601 		// Cancel any outstanding operations on the reader and writer.
  1687 		if (!iReader)
  1602 		__ASSERT_DEBUG(iReader, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
  1688 			{
       
  1689 			OstTraceExt1( TRACE_FATAL, CACMPORT_SETACM_DUP4, "CAcmPort::SetAcm;iReader=%p", iReader );
       
  1690 			__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
  1691 			}
       
  1692 		iReader->ReadCancel();
  1603 		iReader->ReadCancel();
  1693 		if (!iWriter)
  1604 		__ASSERT_DEBUG(iWriter, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
  1694 			{
       
  1695 			OstTraceExt1( TRACE_FATAL, CACMPORT_SETACM_DUP5, "CAcmPort::SetAcm;iWriter=%p", iWriter );
       
  1696 			__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
  1697 			}
       
  1698 		iWriter->WriteCancel();
  1605 		iWriter->WriteCancel();
  1699 
  1606 
  1700 		// Complete any outstanding requests
  1607 		// Complete any outstanding requests
  1701 		OstTrace0( TRACE_NORMAL, CACMPORT_SETACM_DUP1, "CAcmPort::SetAcm;\tcompleting outstanding requests with KErrAccessDenied" );
  1608 		LOGTEXT(_L8("\tcompleting outstanding requests with KErrAccessDenied"));
  1702 		SignalChangeCompleted(iSignals,KErrAccessDenied);
  1609 		SignalChangeCompleted(iSignals,KErrAccessDenied);
  1703 		ReadCompleted(KErrAccessDenied);
  1610 		ReadCompleted(KErrAccessDenied);
  1704 		WriteCompleted(KErrAccessDenied);
  1611 		WriteCompleted(KErrAccessDenied);
  1705 		ConfigChangeCompleted(iCommNotificationDes,KErrAccessDenied);
  1612 		ConfigChangeCompleted(iCommNotificationDes,KErrAccessDenied);
  1706 		NotifyDataAvailableCompleted(KErrAccessDenied);
  1613 		NotifyDataAvailableCompleted(KErrAccessDenied);
  1708 		BreakNotifyCompleted(KErrAccessDenied);
  1615 		BreakNotifyCompleted(KErrAccessDenied);
  1709 		FlowControlChangeCompleted(EFlowControlOn, KErrAccessDenied);
  1616 		FlowControlChangeCompleted(EFlowControlOn, KErrAccessDenied);
  1710 		}
  1617 		}
  1711 	else
  1618 	else
  1712 		{
  1619 		{
  1713 		if (iAcm)
  1620 		__ASSERT_DEBUG(!iAcm, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
  1714 			{
       
  1715 			OstTraceExt1( TRACE_FATAL, CACMPORT_SETACM_DUP6, "CAcmPort::SetAcm;iAcm=%p", iAcm );
       
  1716 			__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
  1717 			}
       
  1718 		aAcm->SetCallback(this);
  1621 		aAcm->SetCallback(this);
  1719 		// Set the port as the observer of break events.
  1622 		// Set the port as the observer of break events.
  1720 		aAcm->SetBreakCallback(this);
  1623 		aAcm->SetBreakCallback(this);
  1721 		}
  1624 		}
  1722 
  1625 
  1723 	iAcm = aAcm;
  1626 	iAcm = aAcm;
  1724 	OstTrace0( TRACE_NORMAL, CACMPORT_SETACM_DUP2, "CAcmPort::SetAcm;<<CAcmPort::SetAcm" );
  1627 	
  1725 	OstTraceFunctionExit0( CACMPORT_SETACM_EXIT );
  1628 	LOGTEXT(_L8("<<CAcmPort::SetAcm"));
  1726 	}
  1629 	}
  1727 
  1630 
  1728 CAcmPort::~CAcmPort()
  1631 CAcmPort::~CAcmPort()
  1729 /**
  1632 /**
  1730  * Destructor.
  1633  * Destructor.
  1731  */
  1634  */
  1732 	{
  1635 	{
  1733 	OstTraceFunctionEntry0( CACMPORT_CACMPORT_DESTRUCTRURE_ENTRY );
  1636 	LOG_FUNC
  1734 	
  1637 
  1735 	delete iReader;
  1638 	delete iReader;
  1736 	delete iWriter;
  1639 	delete iWriter;
  1737 	
  1640 	
  1738 	// Remove this as a sink for the ACM class to call back about host-pushed 
  1641 	// Remove this as a sink for the ACM class to call back about host-pushed 
  1739 	// changes.
  1642 	// changes.
  1740 	if ( iAcm )
  1643 	if ( iAcm )
  1741 		{
  1644 		{
  1742 		OstTrace0( TRACE_NORMAL, CACMPORT_CACMPORT_DESTRUCTRURE, "CAcmPort::~CAcmPort;\tiAcm exists- calling SetCallback(NULL)" );
  1645 		LOGTEXT(_L8("\tiAcm exists- calling SetCallback(NULL)"));
  1743 		iAcm->SetCallback(NULL);
  1646 		iAcm->SetCallback(NULL);
  1744 		}
  1647 		}
  1745 
  1648 
  1746 	OstTrace0( TRACE_NORMAL, CACMPORT_CACMPORT_DESTRUCTRURE_DUP1, "CAcmPort::~CAcmPort;\tcalling AcmPortClosed on observer" );
  1649 	LOGTEXT(_L8("\tcalling AcmPortClosed on observer"));
  1747 	iObserver.AcmPortClosed(iUnit);
  1650 	iObserver.AcmPortClosed(iUnit);
  1748 	OstTraceFunctionExit0( CACMPORT_CACMPORT_DESTRUCTRURE_EXIT );
       
  1749 	}
  1651 	}
  1750 
  1652 
  1751 //
  1653 //
  1752 // End of file
  1654 // End of file