basebandadaptationplugins/basebandchanneladaptorforc32/src/C32Bca.cpp
branchRCL_3
changeset 20 07a122eea281
parent 19 630d2f34d719
equal deleted inserted replaced
19:630d2f34d719 20:07a122eea281
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    19 /**
    19 /**
    20  @file
    20  @file
    21  @internalComponent
    21  @internalComponent
    22 */
    22 */
    23 
    23 
    24 
       
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "C32BcaTraces.h"
       
    28 #endif
       
    29 
       
    30 #include "C32Bca.h"
    24 #include "C32Bca.h"
    31 #include <cdbcols.h>
    25 #include <cdbcols.h>
    32 #include <commsdat_partner.h>
    26 #include <commsdat_partner.h>
    33 
    27 
    34 using namespace BasebandChannelAdaptation;
    28 using namespace BasebandChannelAdaptation;
    48 	CActive(aAoPriority),
    42 	CActive(aAoPriority),
    49 	iUser(aUser),
    43 	iUser(aUser),
    50 	iPort(aPort)
    44 	iPort(aPort)
    51 	{
    45 	{
    52 	CActiveScheduler::Add(this);
    46 	CActiveScheduler::Add(this);
       
    47 	__FLOG_OPEN(KC32BcaLogFolder, KC32BcaLogFile); // Connect to the BCA logger			
    53 	}
    48 	}
    54 		
    49 		
    55 /**
    50 /**
    56 C++ destructor */		
    51 C++ destructor */		
    57 CCommBase::~CCommBase()
    52 CCommBase::~CCommBase()
    58 	{
    53 	{
       
    54 	__FLOG_CLOSE;
    59 	}
    55 	}
    60 
    56 
    61 /**
    57 /**
    62 C++ constructor 
    58 C++ constructor 
    63 The comm-reader has a higher priority than the comm-writer, to
    59 The comm-reader has a higher priority than the comm-writer, to
   175 @param aMask DTE or DCE: determines when the link is considered to be down.
   171 @param aMask DTE or DCE: determines when the link is considered to be down.
   176 */
   172 */
   177 void CCommLinkMonitor::Setup(TUint32 aMask)
   173 void CCommLinkMonitor::Setup(TUint32 aMask)
   178 	{
   174 	{
   179 	iNotifyChangeSignalMask = aMask;	
   175 	iNotifyChangeSignalMask = aMask;	
   180 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCOMMLINKMONITOR_SETUP_1, "CommLinkMonitor setup: Notify on signal mask [0x%X]",iNotifyChangeSignalMask);
   176 	__FLOG_1(_L8("CommLinkMonitor setup: Notify on signal mask [0x%X]"),iNotifyChangeSignalMask);
   181 	}
   177 	}
   182 
   178 
   183 /**
   179 /**
   184 Requests to be notified when the link is down.
   180 Requests to be notified when the link is down.
   185 
   181 
   191 		
   187 		
   192 	// get the current state of the line so when we get notification we can tell if it really has changed	
   188 	// get the current state of the line so when we get notification we can tell if it really has changed	
   193 	iSavedSignalState = iPort.Signals(iNotifyChangeSignalMask) & iNotifyChangeSignalMask;
   189 	iSavedSignalState = iPort.Signals(iNotifyChangeSignalMask) & iNotifyChangeSignalMask;
   194 	iPort.NotifySignalChange(iStatus, iSignals, iNotifyChangeSignalMask);
   190 	iPort.NotifySignalChange(iStatus, iSignals, iNotifyChangeSignalMask);
   195 
   191 
   196 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCOMMLINKMONITOR_NOTIFYLINKDOWN_1, "CommLinkMonitor::NotifyLinkDown: initial signals: [0x%X]", iSavedSignalState);
   192 	__FLOG_1(_L8("CommLinkMonitor::NotifyLinkDown: initial signals: [0x%X]"), iSavedSignalState);
   197 	
   193 	
   198 	SetActive();
   194 	SetActive();
   199 	}
   195 	}
   200 
   196 
   201 /**	
   197 /**	
   202 Called when EIA-232 signals change,i.e. on potential link failure
   198 Called when EIA-232 signals change,i.e. on potential link failure
   203 */
   199 */
   204 void CCommLinkMonitor::RunL()
   200 void CCommLinkMonitor::RunL()
   205 	{
   201 	{
   206 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCOMMLINKMONITOR_RUNL_1, "CommLinkMonitor::RunL: Signals changed [0x%X]; new signals [0x%X]", iSignals & (~0x1F), iSignals & 0x1F);
   202 	__FLOG_2(_L8("CommLinkMonitor::RunL: Signals changed [0x%X]; new signals [0x%X]"), iSignals & (~0x1F), iSignals & 0x1F);
   207 	
   203 	
   208 	// We report link failure if and only if a monitored line went from high to low.
   204 	// We report link failure if and only if a monitored line went from high to low.
   209 	// Method: mask the saved signals using inverted monitored bits in the signal bitmask,
   205 	// Method: mask the saved signals using inverted monitored bits in the signal bitmask,
   210 	// to filter out all transitions except for high -> low. 
   206 	// to filter out all transitions except for high -> low. 
   211 	// 1 & ~0 = 1;    1 & ~1 = 0; 0 & ~1 = 0; 0 & ~0 = 0
   207 	// 1 & ~0 = 1;    1 & ~1 = 0; 0 & ~1 = 0; 0 & ~0 = 0
   222 
   218 
   223 /**
   219 /**
   224 Cancels notification request of link failure */	
   220 Cancels notification request of link failure */	
   225 void CCommLinkMonitor::DoCancel()
   221 void CCommLinkMonitor::DoCancel()
   226 	{
   222 	{
   227 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCOMMLINKMONITOR_DOCANCEL_1, "CommLinkMonitor::DoCancel: Cancelling signal change notification.");
   223 	__FLOG(_L8("CommLinkMonitor::DoCancel: Cancelling signal change notification."));
   228 	iPort.NotifySignalChangeCancel();
   224 	iPort.NotifySignalChangeCancel();
   229 	}
   225 	}
   230 	
   226 	
   231 
   227 
   232 
   228 
   235 /**
   231 /**
   236 * default constructor to create a C32Bca instance.
   232 * default constructor to create a C32Bca instance.
   237 */
   233 */
   238 CC32Bca::CC32Bca()	
   234 CC32Bca::CC32Bca()	
   239 	{
   235 	{
   240 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CTOR_1, "====== CC32Bca::CC32Bca: Shim BCA for C32 [Vesion: major= %d minor= %d] Constructed. ======", KC32BcaMajorVersionNumber, KC32BcaMinorVersionNumber);
   236 	__FLOG_OPEN(KC32BcaLogFolder,KC32BcaLogFile);
       
   237 	__FLOG_2(_L8("====== CC32Bca::CC32Bca: Shim BCA for C32 [Vesion: major= %d minor= %d] Constructed. ======"), KC32BcaMajorVersionNumber, KC32BcaMinorVersionNumber);
   241 	}
   238 	}
   242 
   239 
   243 /**
   240 /**
   244 2nd phase of construction: allocates member objects 
   241 2nd phase of construction: allocates member objects 
   245 
   242 
   261 * Destructor 
   258 * Destructor 
   262 */	
   259 */	
   263 CC32Bca::~CC32Bca()
   260 CC32Bca::~CC32Bca()
   264 	
   261 	
   265 	{
   262 	{
   266 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_DTOR_1, "CC32Bca::~CC32Bca: releasing resources...");
   263 	__FLOG(_L8("CC32Bca::~CC32Bca: releasing resources..."));
   267 		
   264 		
   268 	CloseCommDbConnection(); 
   265 	CloseCommDbConnection(); 
   269 	CloseCommPort(); 	// Cancels reader / writer / monitor
   266 	CloseCommPort(); 	// Cancels reader / writer / monitor
   270 	
   267 	
   271 	// N.B.: 
   268 	// N.B.: 
   273 	// causing C32 to panic. 
   270 	// causing C32 to panic. 
   274 	delete iReader;
   271 	delete iReader;
   275 	delete iWriter;
   272 	delete iWriter;
   276 	delete iLinkMonitor; // Note: may have never been created.
   273 	delete iLinkMonitor; // Note: may have never been created.
   277 
   274 
   278 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_DTOR_2, "CC32Bca::~CC32Bca: CC32Bca destroyed.");
   275 	__FLOG(_L8("CC32Bca::~CC32Bca: CC32Bca destroyed."));
       
   276 	__FLOG_CLOSE;
   279 	}
   277 	}
   280 	
   278 	
   281 /** This method deletes the BCA itself.*/
   279 /** This method deletes the BCA itself.*/
   282 void CC32Bca::Release()
   280 void CC32Bca::Release()
   283 	{
   281 	{
   284 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_RELEASE_1, "CC32Bca::Release");
   282 	__FLOG(_L8("CC32Bca::Release"));
   285 	delete this;
   283 	delete this;
   286 	}
   284 	}
   287 	
   285 	
   288 /**
   286 /**
   289 * Informs that the BCA is required by the client(for instance, Raw IP NIF).Comms Server is
   287 * Informs that the BCA is required by the client(for instance, Raw IP NIF).Comms Server is
   299 	aStatus = KRequestPending;
   297 	aStatus = KRequestPending;
   300 	// avoid compiler warning.
   298 	// avoid compiler warning.
   301 	TRequestStatus* ptrStatus = &aStatus;
   299 	TRequestStatus* ptrStatus = &aStatus;
   302 	if(iCommPortOpen)
   300 	if(iCommPortOpen)
   303 		{
   301 		{
   304 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_OPEN_1, "Warning: C32Bca is already Opened.");
   302 		__FLOG(_L8("Warning: C32Bca is already Opened."));
   305 	
   303 	
   306 		User::RequestComplete(ptrStatus,KErrNone);
   304 		User::RequestComplete(ptrStatus,KErrNone);
   307 		return;	
   305 		return;	
   308 		}
   306 		}
   309 	
   307 	
   320 		// emty descriptor as a port name. As of December 2004, C32 does not allow that, however, this
   318 		// emty descriptor as a port name. As of December 2004, C32 does not allow that, however, this
   321 		// may change in the future.
   319 		// may change in the future.
   322 		// So, we just log a warning.
   320 		// So, we just log a warning.
   323 		if(KErrNone == commPortErr && iCommPort.Size() == 0)
   321 		if(KErrNone == commPortErr && iCommPort.Size() == 0)
   324 			{
   322 			{
   325 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_OPEN_2, "Warning: Null string read from CommDB. Will try to open Comm Port anyway.");
   323 			__FLOG(_L8("Warning: Null string read from CommDB. Will try to open Comm Port anyway."));
   326 			}		
   324 			}		
   327 		
   325 		
   328 		if(KErrNone != commPortErr) // Fatal: we do not have a port name. Can't open RComm.
   326 		if(KErrNone != commPortErr) // Fatal: we do not have a port name. Can't open RComm.
   329 			{
   327 			{
   330 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_OPEN_3, "Error: Failed to get C32 PortName from CommDB ");
   328 			__FLOG(_L8("Error: Failed to get C32 PortName from CommDB "));
   331 			CloseCommDbConnection();
   329 			CloseCommDbConnection();
   332 			User::RequestComplete(ptrStatus, commPortErr);
   330 			User::RequestComplete(ptrStatus, commPortErr);
   333 			return;
   331 			return;
   334 			}		
   332 			}		
   335 		}
   333 		}
   338 		_LIT(KDoubleColon, "::");
   336 		_LIT(KDoubleColon, "::");
   339 		TInt len1 = aChannelId.Find(KDoubleColon);
   337 		TInt len1 = aChannelId.Find(KDoubleColon);
   340 
   338 
   341 		if (len1 < KErrNone)
   339 		if (len1 < KErrNone)
   342 			{
   340 			{
   343 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_OPEN_4, "** ERROR: No :: (Double Colon) in aChannelId **");
   341 			__FLOG(_L8("** ERROR: No :: (Double Colon) in aChannelId **"));
   344 			User::RequestComplete(ptrStatus, KErrBadName);
   342 			User::RequestComplete(ptrStatus, KErrBadName);
   345 			return;	
   343 			return;	
   346 			}
   344 			}
   347 		else
   345 		else
   348 			{
   346 			{
   369 		TRAPD(getCsyErr, ReadCsyNameFromCommDbL(iCsyName));
   367 		TRAPD(getCsyErr, ReadCsyNameFromCommDbL(iCsyName));
   370 		if(KErrNone != getCsyErr) // Fatal: we do not have a CSY name. Can't load CSY module.
   368 		if(KErrNone != getCsyErr) // Fatal: we do not have a CSY name. Can't load CSY module.
   371 			{
   369 			{
   372 			// We do not use a hardcoded value (e.g. ECUART), because the client code or the environment are
   370 			// We do not use a hardcoded value (e.g. ECUART), because the client code or the environment are
   373 			// confused - it is better to fail them, rather than mask their problems.
   371 			// confused - it is better to fail them, rather than mask their problems.
   374 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_OPEN_5, "Error: Failed to get CSY name from CommDB ");
   372 			__FLOG(_L8("Error: Failed to get CSY name from CommDB "));
   375 			CloseCommDbConnection();
   373 			CloseCommDbConnection();
   376 			User::RequestComplete(ptrStatus,getCsyErr);
   374 			User::RequestComplete(ptrStatus,getCsyErr);
   377 			return;
   375 			return;
   378 			}
   376 			}
   379 		}
   377 		}
   399 	// Open the actual C32 session:
   397 	// Open the actual C32 session:
   400 	
   398 	
   401 	TInt ret = iCommServ.Connect();
   399 	TInt ret = iCommServ.Connect();
   402 	if(ret)
   400 	if(ret)
   403 		{
   401 		{
   404 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_OPEN_6, "Open: C32 Server connection error %d", ret);
   402 		__FLOG_1(_L8("Open: C32 Server connection error %d"), ret);
   405 		User::RequestComplete(ptrStatus,ret);
   403 		User::RequestComplete(ptrStatus,ret);
   406 		return;
   404 		return;
   407 		}
   405 		}
   408 	ret = iCommServ.LoadCommModule(iCsyName);
   406 	ret = iCommServ.LoadCommModule(iCsyName);
   409 	
   407 	
   410 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_OPEN_7,"Open: CSY module [%S] loaded with error %d", iCsyName, ret);
   408 	__FLOG_2(_L16("Open: CSY module [%S] loaded with error %d"), &iCsyName, ret);
   411 		
   409 		
   412 	if(ret)
   410 	if(ret)
   413 		{
   411 		{
   414 		User::RequestComplete(ptrStatus,ret);
   412 		User::RequestComplete(ptrStatus,ret);
   415 		return;
   413 		return;
   422 	else
   420 	else
   423 		{
   421 		{
   424 		ret = iComm.Open(iCommServ, iCommPort, ECommShared, iCommRole);	
   422 		ret = iComm.Open(iCommServ, iCommPort, ECommShared, iCommRole);	
   425 		}
   423 		}
   426 	
   424 	
   427 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_OPEN_8,"Open: C32 port [%S] opened with error %d", iCommPort, ret);
   425 	__FLOG_2(_L16("Open: C32 port [%S] opened with error %d"), &iCommPort, ret);
   428 					
   426 					
   429 	if(ret)
   427 	if(ret)
   430 		{
   428 		{
   431 		User::RequestComplete(ptrStatus,ret);
   429 		User::RequestComplete(ptrStatus,ret);
   432 		return;
   430 		return;
   460 	
   458 	
   461 	// Don't notify reader / writer / monitor. Read / Write should not be called after this anyway. Let C32 panic.
   459 	// Don't notify reader / writer / monitor. Read / Write should not be called after this anyway. Let C32 panic.
   462 	
   460 	
   463 	TRequestStatus* request = &aStatus;
   461 	TRequestStatus* request = &aStatus;
   464 	User::RequestComplete(request, KErrNone);
   462 	User::RequestComplete(request, KErrNone);
   465 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_SHUTDOWN_1, "C32Bca::Shutdown: BCA shut down with error %d", KErrNone);
   463 	__FLOG_1(_L8("C32Bca::Shutdown: BCA shut down with error %d"), KErrNone);
   466 	}
   464 	}
   467 
   465 
   468 /**
   466 /**
   469 * Closes the BCA immediately. BCA releases its resources.
   467 * Closes the BCA immediately. BCA releases its resources.
   470 * cancels all Writes, Reads and Controls.
   468 * cancels all Writes, Reads and Controls.
   471 */	
   469 */	
   472 void CC32Bca::Close()
   470 void CC32Bca::Close()
   473 	{
   471 	{
   474 	CloseCommPort();
   472 	CloseCommPort();
   475 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CLOSE_1, "C32Bca::Close:Close: BCA closed with error %d", KErrNone);
   473 	__FLOG_1(_L8("C32Bca::Close:Close: BCA closed with error %d"), KErrNone);
   476 	}
   474 	}
   477 
   475 
   478 /**
   476 /**
   479 * Queues a Read on C32 serial port.
   477 * Queues a Read on C32 serial port.
   480 
   478 
   525  Cancels the outstanding Read operation.(best effort operation: the read may have been completed already.)
   523  Cancels the outstanding Read operation.(best effort operation: the read may have been completed already.)
   526 */	
   524 */	
   527 void CC32Bca:: CancelRead()
   525 void CC32Bca:: CancelRead()
   528 	
   526 	
   529 	{
   527 	{
   530 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CANCELREAD_1, "CancelRead: Read is cancelled by client.");
   528 	__FLOG(_L8("CancelRead: Read is cancelled by client."));
   531 	iReader->Cancel();
   529 	iReader->Cancel();
   532 
   530 
   533 	if(iReadRequest != NULL)
   531 	if(iReadRequest != NULL)
   534 		{
   532 		{
   535 		User::RequestComplete(iReadRequest, KErrCancel);
   533 		User::RequestComplete(iReadRequest, KErrCancel);
   540  Cancels all Write operations.(best effort attempt: the write may have been completed already.)
   538  Cancels all Write operations.(best effort attempt: the write may have been completed already.)
   541 */	
   539 */	
   542 void CC32Bca::CancelWrite()
   540 void CC32Bca::CancelWrite()
   543 
   541 
   544     {
   542     {
   545     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CANCELWRITE_1, "CancelWrite: Write is cancelled by client.");
   543     __FLOG(_L8("CancelWrite: Write is cancelled by client."));
   546 
   544 
   547     iWriter->Cancel();
   545     iWriter->Cancel();
   548 
   546 
   549     if(iWriteRequest != NULL)
   547     if(iWriteRequest != NULL)
   550     	{
   548     	{
   552     	}
   550     	}
   553     }
   551     }
   554     
   552     
   555 
   553 
   556 // Debug dumps:
   554 // Debug dumps:
   557 #ifdef OST_TRACE_COMPILER_IN_USE
   555 #ifdef __FLOG_ACTIVE
   558 
   556 
   559 _LIT8(KLitOptLevelGeneric,    "KBcaOptLevelGeneric");
   557 _LIT8(KLitOptLevelGeneric,    "KBcaOptLevelGeneric");
   560 _LIT8(KLitOptLevelExtSerial,   "KBcaOptLevelExtSerial");
   558 _LIT8(KLitOptLevelExtSerial,   "KBcaOptLevelExtSerial");
   561 _LIT8(KLitOptLevelUnsupported, "**Unsupported**");
   559 _LIT8(KLitOptLevelUnsupported, "**Unsupported**");
   562 
   560 
   637 			return KLitSerialSetControlLines;
   635 			return KLitSerialSetControlLines;
   638 		default:
   636 		default:
   639 			return KLitOptNameUnsupported;		
   637 			return KLitOptNameUnsupported;		
   640 		}
   638 		}
   641 	}
   639 	}
   642 #endif // OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_DEBUG
   640 #endif // __FLOG_ACTIVE
   643 
   641 
   644 
   642 
   645 
   643 #ifdef __FLOG_ACTIVE
   646 
   644 /**
       
   645 Print debug output of the TCommComfig parameters.
       
   646 
       
   647 @param The configuration whose parameters should be logged.
       
   648 */
       
   649 void CC32Bca::LogCommConfig(TCommConfig& c)
       
   650 	{
       
   651 	__FLOG_5(_L8("Rate[%d] DataBits[%d] StopBits[%d] Parity[%d] Handshake[0x%x]"), c().iRate, c().iDataBits, c().iStopBits, c().iParity, c().iHandshake);	
       
   652 	__FLOG_4(_L8("ParityError[%d] Fifo[%d] SpecialRate[%d] terminatorCount[%d]"), c().iParityError, c().iFifo, c().iSpecialRate, c().iTerminatorCount);	
       
   653 	__FLOG_1(_L8("Terminator[0x%x]"), c().iTerminator);	
       
   654 	}
       
   655 #endif // __FLOG_ACTIVE
   647 
   656 
   648 
   657 
   649 /**
   658 /**
   650 * Ioctl: asynchronously controls the C32Bca.
   659 * Ioctl: asynchronously controls the C32Bca.
   651 
   660 
   655 * @param aOpt an optional parameter,holds the option value on return or the option value to be set.
   664 * @param aOpt an optional parameter,holds the option value on return or the option value to be set.
   656 */  
   665 */  
   657 void CC32Bca::Ioctl(TRequestStatus& aStatus, TUint aOptLevel, TUint aOptName, TDes8& aOpt)
   666 void CC32Bca::Ioctl(TRequestStatus& aStatus, TUint aOptLevel, TUint aOptName, TDes8& aOpt)
   658 
   667 
   659 	{
   668 	{
   660 	OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_1, "Ioctl: Level[%s](0x%X) Name[%s](0x%X).", IoctlOptLevelStr(aOptLevel), aOptLevel, IoctlOptNameStr(aOptName), aOptName);
   669 	__FLOG_4(_L8("Ioctl: Level[%S](0x%X) Name[%S](0x%X)."), &IoctlOptLevelStr(aOptLevel), aOptLevel, &IoctlOptNameStr(aOptName), aOptName);	
   661 	
   670 	
   662 	aStatus = KRequestPending;
   671 	aStatus = KRequestPending;
   663 	
   672 	
   664 	TInt ret(KErrNone); // If operation fails, this will be set to the failure code explicitly.
   673 	TInt ret(KErrNone); // If operation fails, this will be set to the failure code explicitly.
   665 	
   674 	
   685 				
   694 				
   686 			case KBCASetIapId:
   695 			case KBCASetIapId:
   687 				{
   696 				{
   688 				TUint32 tempIapId = *(reinterpret_cast<const TUint32*>(aOpt.Ptr()));
   697 				TUint32 tempIapId = *(reinterpret_cast<const TUint32*>(aOpt.Ptr()));
   689 				
   698 				
   690 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_2, "Ioctl: IAP ID [%d] specified.",tempIapId);
   699 				__FLOG_1(_L8("Ioctl: IAP ID [%d] specified."),tempIapId);	
   691 				
   700 				
   692 				if(tempIapId < 1 )
   701 				if(tempIapId < 1 )
   693 					{
   702 					{
   694 					ret = KErrArgument;
   703 					ret = KErrArgument;
   695 					}
   704 					}
   734 			break;
   743 			break;
   735 			}
   744 			}
   736 			
   745 			
   737 		case KSerialConfig:
   746 		case KSerialConfig:
   738 			{
   747 			{
   739 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_3, "Ioctl: KSerialConfig");
   748 			__FLOG(_L8("Ioctl: KSerialConfig"));	
   740 
   749 
   741 			TCommConfig cfg;
   750 			TCommConfig cfg;
   742 			iComm.Config(cfg);
   751 			iComm.Config(cfg);
   743 
   752 
   744 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_4, "Rate[%d] DataBits[%d] StopBits[%d]", cfg().iRate, cfg().iDataBits, cfg().iStopBits);
   753 #ifdef __FLOG_ACTIVE
   745 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_5, "Parity[%d] Handshake[0x%x]", cfg().iParity, cfg().iHandshake);
   754 			LogCommConfig(cfg);
   746 			OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_6, "ParityError[%d] Fifo[%d] SpecialRate[%d] terminatorCount[%d]", cfg().iParityError, cfg().iFifo, cfg().iSpecialRate, cfg().iTerminatorCount);
   755 #endif // __FLOG_ACTIVE
   747             OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_7, "Terminator[0x%x]", cfg().iTerminator);
       
   748 
   756 
   749 			TPckgBuf<TCommConfig> cfgBuf(cfg);
   757 			TPckgBuf<TCommConfig> cfgBuf(cfg);
   750 			aOpt.Copy(cfgBuf);
   758 			aOpt.Copy(cfgBuf);
   751 			break;
   759 			break;
   752 			}
   760 			}
   753 
   761 
   754 		case KSerialSetConfig:
   762 		case KSerialSetConfig:
   755 			{
   763 			{
   756 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_8, "Ioctl: KSerialSetConfig");
   764 			__FLOG(_L8("Ioctl: KSerialSetConfig"));	
   757 
   765 
   758 			TCommConfig cfg(*(reinterpret_cast<const TCommConfig*>(aOpt.Ptr())));
   766 			TCommConfig cfg(*(reinterpret_cast<const TCommConfig*>(aOpt.Ptr())));
   759 
   767 
   760 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_9, "Rate[%d] DataBits[%d] StopBits[%d]", cfg().iRate, cfg().iDataBits, cfg().iStopBits);
   768 #ifdef __FLOG_ACTIVE
   761 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_10, "Parity[%d] Handshake[0x%x]", cfg().iParity, cfg().iHandshake);
   769 			LogCommConfig(cfg);
   762 			OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_11, "ParityError[%d] Fifo[%d] SpecialRate[%d] terminatorCount[%d]", cfg().iParityError, cfg().iFifo, cfg().iSpecialRate, cfg().iTerminatorCount);
   770 #endif // __FLOG_ACTIVE
   763 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_12, "Terminator[0x%x]", cfg().iTerminator);
   771 
   764 			
       
   765 			ret = iComm.SetConfig(cfg);
   772 			ret = iComm.SetConfig(cfg);
   766 			break;
   773 			break;
   767 			}
   774 			}
   768 			
   775 			
   769 		case KSerialPortName:
   776 		case KSerialPortName:
   778 				{
   785 				{
   779 				iCsyName.Copy(*(
   786 				iCsyName.Copy(*(
   780 			   				reinterpret_cast<const TName*>(aOpt.Ptr())
   787 			   				reinterpret_cast<const TName*>(aOpt.Ptr())
   781 			   				));
   788 			   				));
   782 				iCsyNameOverride = ETrue;
   789 				iCsyNameOverride = ETrue;
   783 				OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_13, "Ioctl: CSY Name set to [%S]", iCsyName);
   790 				__FLOG_1(_L8("Ioctl: CSY Name set to [%S]"), &iCsyName);	
   784 				}
   791 				}
   785 			else
   792 			else
   786 				{
   793 				{
   787 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_14, "Ioctl: Warning: Cannot set the CSY name because the Comm Port is already open.");
   794 				__FLOG(_L8("Ioctl: Warning: Cannot set the CSY name because the Comm Port is already open."));
   788 				ret = KErrAlreadyExists;
   795 				ret = KErrAlreadyExists;
   789 				}
   796 				}
   790 			
   797 			
   791 			break;
   798 			break;
   792 			}
   799 			}
   795 			{
   802 			{
   796 			if(!iCommPortOpen)
   803 			if(!iCommPortOpen)
   797 				{
   804 				{
   798 				iCommRole = *(reinterpret_cast<const TCommRole*>(aOpt.Ptr()));
   805 				iCommRole = *(reinterpret_cast<const TCommRole*>(aOpt.Ptr()));
   799 				iCommRoleOverride = ETrue;
   806 				iCommRoleOverride = ETrue;
   800 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_15, "Ioctl: Comm Role set to [%d]", iCommRole);
   807 				__FLOG_1(_L8("Ioctl: Comm Role set to [%d]"), iCommRole);	
   801 				}
   808 				}
   802 			else
   809 			else
   803 				{
   810 				{
   804 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_16, "Ioctl: Warning: Cannot set Comm Role because the Comm Port is already open.");
   811 				__FLOG(_L8("Ioctl: Warning: Cannot set Comm Role because the Comm Port is already open."));
   805 				ret = KErrAlreadyExists;
   812 				ret = KErrAlreadyExists;
   806 				}
   813 				}
   807 			break;	
   814 			break;	
   808 			}
   815 			}
   809 		
   816 		
   810 		case KSerialSetTxRxBufferSize:
   817 		case KSerialSetTxRxBufferSize:
   811 			{
   818 			{
   812 			TInt bufSize = *(reinterpret_cast<const TInt*>(aOpt.Ptr()));
   819 			TInt bufSize = *(reinterpret_cast<const TInt*>(aOpt.Ptr()));
   813 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_17, "Ioctl: Setting Rx Tx buffer size to [%d]", bufSize);
   820 			__FLOG_1(_L8("Ioctl: Setting Rx Tx buffer size to [%d]"), bufSize); 
   814 			
   821 			
   815 			iComm.SetReceiveBufferLength(bufSize);
   822 			iComm.SetReceiveBufferLength(bufSize);
   816 			break;
   823 			break;
   817 			}
   824 			}
   818 			
   825 			
   829 				ret = KErrArgument;
   836 				ret = KErrArgument;
   830 				}
   837 				}
   831 			else
   838 			else
   832 				{
   839 				{
   833 				const TSerialSetControlLines& lines = *(reinterpret_cast<const TSerialSetControlLines*>(aOpt.Ptr()));
   840 				const TSerialSetControlLines& lines = *(reinterpret_cast<const TSerialSetControlLines*>(aOpt.Ptr()));
   834 				OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_18, "Ioctl: Setting/clearing control lines %x/%x", lines.iSetMask, lines.iClearMask);
   841 				__FLOG_2(_L8("Ioctl: Setting/clearing control lines %x/%x"), lines.iSetMask, lines.iClearMask); 
   835 				iComm.SetSignals(lines.iSetMask, lines.iClearMask);
   842 				iComm.SetSignals(lines.iSetMask, lines.iClearMask);
   836 				ret = KErrNone;
   843 				ret = KErrNone;
   837 				}
   844 				}
   838 			break;
   845 			break;
   839 			}
   846 			}
   846 		{
   853 		{
   847 		ret = KErrNotSupported;
   854 		ret = KErrNotSupported;
   848 		}
   855 		}
   849 		
   856 		
   850 	
   857 	
   851 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_19, "Ioctl completed with error %d", ret);
   858 	__FLOG_1(_L8("Ioctl completed with error %d"), ret);			
   852 	
   859 	
   853 	TRequestStatus* ptrStatus = &aStatus;
   860 	TRequestStatus* ptrStatus = &aStatus;
   854 	User::RequestComplete(ptrStatus, ret);
   861 	User::RequestComplete(ptrStatus, ret);
   855 	}
   862 	}
   856 	
   863 	
   862 	
   869 	
   863 @leave if the monitoring object cannot be constructed, typically due to OOM.
   870 @leave if the monitoring object cannot be constructed, typically due to OOM.
   864 */
   871 */
   865 void CC32Bca::MonitorControlLinesL(TUint32 aArgMask)
   872 void CC32Bca::MonitorControlLinesL(TUint32 aArgMask)
   866 	{
   873 	{
   867 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_MONITORCONTROLLINESL_1, "Ioctl: argument bitmask = [0x%X] ", aArgMask);
   874 	__FLOG_1(_L8("Ioctl: argument bitmask = [0x%X] "), aArgMask);	
   868 			
   875 			
   869 	if(iLinkMonitor) // We may have never started...  
   876 	if(iLinkMonitor) // We may have never started...  
   870 			{
   877 			{
   871 			// We are called to either stop or change the monitoring options.
   878 			// We are called to either stop or change the monitoring options.
   872 			iLinkMonitor->Cancel(); // If we are not monitoring, this has no effect.
   879 			iLinkMonitor->Cancel(); // If we are not monitoring, this has no effect.
   873 			}
   880 			}
   874 	
   881 	
   875 	if(KMonitorOff == aArgMask) // Stop monitoring:
   882 	if(KMonitorOff == aArgMask) // Stop monitoring:
   876 		{
   883 		{
   877 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_MONITORCONTROLLINESL_2, "MonitorControlLinesL: Stopping Control Lines monitoring.");
   884 		__FLOG(_L8("MonitorControlLinesL: Stopping Control Lines monitoring."));
   878 		// We either never started, or we just cancelled above.
   885 		// We either never started, or we just cancelled above.
   879 		}
   886 		}
   880 	else // Start Monitoring, or change the monitored lines.
   887 	else // Start Monitoring, or change the monitored lines.
   881 		{
   888 		{
   882 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_MONITORCONTROLLINESL_3, "MonitorControlLinesL: Starting to monitor Control Lines.");
   889 		__FLOG(_L8("MonitorControlLinesL: Starting to monitor Control Lines."));	
   883 		
   890 		
   884 		if(!iLinkMonitor) // We are starting to monitor for the first time 
   891 		if(!iLinkMonitor) // We are starting to monitor for the first time 
   885 			{			
   892 			{			
   886 			iLinkMonitor = new (ELeave)CCommLinkMonitor(*this, iComm);
   893 			iLinkMonitor = new (ELeave)CCommLinkMonitor(*this, iComm);
   887 			}		
   894 			}		
   926 			}
   933 			}
   927 			
   934 			
   928 		iLinkMonitor->Setup(lineMask);
   935 		iLinkMonitor->Setup(lineMask);
   929 		iLinkMonitor->NotifyLinkDown();
   936 		iLinkMonitor->NotifyLinkDown();
   930 		
   937 		
   931 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_MONITORCONTROLLINESL_4, "MonitorControlLinesL: Control Lines monitoring started.");
   938 		__FLOG(_L8("MonitorControlLinesL: Control Lines monitoring started."));	
   932 		}				
   939 		}				
   933 	}
   940 	}
   934 
   941 
   935 /**
   942 /**
   936 Closes the connection to CommDB, if it is open */
   943 Closes the connection to CommDB, if it is open */
   944 Read Comm Port from CommDB bearer record 
   951 Read Comm Port from CommDB bearer record 
   945 @param aPortName
   952 @param aPortName
   946 @leave if the value could not be read */
   953 @leave if the value could not be read */
   947 void CC32Bca::ReadCommPortFromCommDbL(TDes& aPortName)
   954 void CC32Bca::ReadCommPortFromCommDbL(TDes& aPortName)
   948 	{
   955 	{
   949 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCOMMPORTFROMCOMMDBL_1, "CC32Bca::ReadCommPortFromCommDbL()");
   956 	__FLOG(_L8("CC32Bca::ReadCommPortFromCommDbL()"));
   950 	ConnectToCommDbBearerRecordL();
   957 	ConnectToCommDbBearerRecordL();
   951 
   958 
   952 	TInt ret(0);
   959 	TInt ret(0);
   953 	CMDBField<TDesC>* portField = new(ELeave) CMDBField<TDesC>(KCDTIdPortName);
   960 	CMDBField<TDesC>* portField = new(ELeave) CMDBField<TDesC>(KCDTIdPortName);
   954 	CleanupStack::PushL(portField);
   961 	CleanupStack::PushL(portField);
   957 	portField->SetMaxLengthL(KMaxTextLength);
   964 	portField->SetMaxLengthL(KMaxTextLength);
   958 	TRAP(ret,portField->LoadL(*iCommsDat));
   965 	TRAP(ret,portField->LoadL(*iCommsDat));
   959 
   966 
   960 	if(ret!=KErrNone)
   967 	if(ret!=KErrNone)
   961 		{
   968 		{
   962 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCOMMPORTFROMCOMMDBL_2, "portField->LoadL(*iCommsDat) left with[%d] ", ret);
   969 		__FLOG_1(_L8("portField->LoadL(*iCommsDat) left with[%d] "), ret);
   963 		User::Leave(ret);	
   970 		User::Leave(ret);	
   964 		}
   971 		}
   965 
   972 
   966 	aPortName = *portField;
   973 	aPortName = *portField;
   967 	CleanupStack::PopAndDestroy(portField);	
   974 	CleanupStack::PopAndDestroy(portField);	
   971 Read the CSY name from CommDB bearer record.
   978 Read the CSY name from CommDB bearer record.
   972 @param aCsyName the CSY name
   979 @param aCsyName the CSY name
   973 @leave if the value could not be read */
   980 @leave if the value could not be read */
   974 void CC32Bca::ReadCsyNameFromCommDbL(TDes& aCsyName)
   981 void CC32Bca::ReadCsyNameFromCommDbL(TDes& aCsyName)
   975 	{
   982 	{
   976 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCSYNAMEFROMCOMMDBL_1, "CC32Bca::ReadCsyNameFromCommDbL()");
   983 	__FLOG(_L8("CC32Bca::ReadCsyNameFromCommDbL()"));
   977 	ConnectToCommDbBearerRecordL();
   984 	ConnectToCommDbBearerRecordL();
   978 
   985 
   979 	TInt ret(0);
   986 	TInt ret(0);
   980 	CMDBField<TDesC>* csyField = new(ELeave) CMDBField<TDesC>(KCDTIdCsyName);
   987 	CMDBField<TDesC>* csyField = new(ELeave) CMDBField<TDesC>(KCDTIdCsyName);
   981 	CleanupStack::PushL(csyField);
   988 	CleanupStack::PushL(csyField);
   984 	csyField->SetMaxLengthL(KMaxTextLength);
   991 	csyField->SetMaxLengthL(KMaxTextLength);
   985 	TRAP(ret,csyField->LoadL(*iCommsDat));
   992 	TRAP(ret,csyField->LoadL(*iCommsDat));
   986 
   993 
   987 	if(ret!=KErrNone)
   994 	if(ret!=KErrNone)
   988 		{
   995 		{
   989 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCSYNAMEFROMCOMMDBL_2, "csyField->LoadL(*iCommsDat) left with[%d] ", ret);
   996 		__FLOG_1(_L8("csyField->LoadL(*iCommsDat) left with[%d] "), ret);
   990 		User::Leave(ret);	
   997 		User::Leave(ret);	
   991 		}
   998 		}
   992 
   999 
   993 	aCsyName = *csyField;
  1000 	aCsyName = *csyField;
   994 	CleanupStack::PopAndDestroy(csyField);
  1001 	CleanupStack::PopAndDestroy(csyField);
   999 
  1006 
  1000 @param aCommRole the specified role.
  1007 @param aCommRole the specified role.
  1001 @leave if the value could not be read */	
  1008 @leave if the value could not be read */	
  1002 void CC32Bca::ReadCommRoleFromCommDbL(TCommRole& aCommRole)
  1009 void CC32Bca::ReadCommRoleFromCommDbL(TCommRole& aCommRole)
  1003 	{
  1010 	{
  1004 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCOMMROLEFROMCOMMDBL_1, "CC32Bca::ReadCommRoleFromCommDbL()");
  1011 	__FLOG(_L8("CC32Bca::ReadCommRoleFromCommDbL()"));
  1005 	ConnectToCommDbBearerRecordL();
  1012 	ConnectToCommDbBearerRecordL();
  1006 	TUint32 role(0);
  1013 	TUint32 role(0);
  1007 
  1014 
  1008 	TInt ret(0);
  1015 	TInt ret(0);
  1009 	CMDBField<TUint32>* roleField = new(ELeave) CMDBField<TUint32>(KCDTIdCommRole);
  1016 	CMDBField<TUint32>* roleField = new(ELeave) CMDBField<TUint32>(KCDTIdCommRole);
  1012 	roleField->SetRecordId(iModemId);
  1019 	roleField->SetRecordId(iModemId);
  1013 	TRAP(ret,roleField->LoadL(*iCommsDat));
  1020 	TRAP(ret,roleField->LoadL(*iCommsDat));
  1014 
  1021 
  1015 	if(ret!=KErrNone)
  1022 	if(ret!=KErrNone)
  1016 		{
  1023 		{
  1017 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCOMMROLEFROMCOMMDBL_2, "roleField->LoadL(*iCommsDat) left with[%d] ", ret);
  1024 		__FLOG_1(_L8("roleField->LoadL(*iCommsDat) left with[%d] "), ret);
  1018 		User::Leave(ret);	
  1025 		User::Leave(ret);	
  1019 		}
  1026 		}
  1020 
  1027 
  1021 	role = *roleField;
  1028 	role = *roleField;
  1022 	CleanupStack::PopAndDestroy(roleField);
  1029 	CleanupStack::PopAndDestroy(roleField);
  1030 @leave KErrNotReady, if the provisioned IAP id is invalid. System-wide error code
  1037 @leave KErrNotReady, if the provisioned IAP id is invalid. System-wide error code
  1031        if the connection cannot be opened for some other reason.
  1038        if the connection cannot be opened for some other reason.
  1032 */
  1039 */
  1033 void CC32Bca::ConnectToCommDbBearerRecordL()
  1040 void CC32Bca::ConnectToCommDbBearerRecordL()
  1034 	{
  1041 	{
  1035 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CONNECTTOCOMMDBBEARERRECORDL_1, "CC32Bca::ConnectToCommDbBearerRecordL()");
  1042 	__FLOG(_L8("CC32Bca::ConnectToCommDbBearerRecordL()"));
  1036 	if(iCommsDat != NULL) // CommDB is already open, we don't need to do anything
  1043 	if(iCommsDat != NULL) // CommDB is already open, we don't need to do anything
  1037 		{
  1044 		{
  1038 		return;	
  1045 		return;	
  1039 		}
  1046 		}
  1040 	
  1047 	
  1041 	if(iIapId < 1) // Can't access CommDB if IAP ID is unknown
  1048 	if(iIapId < 1) // Can't access CommDB if IAP ID is unknown
  1042 		{
  1049 		{
  1043 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CONNECTTOCOMMDBBEARERRECORDL_2, "iIapId[%d] is unknown", iIapId);
  1050 		__FLOG_1(_L8("iIapId[%d] is unknown"), iIapId);
  1044 		User::Leave(KErrNotReady);	
  1051 		User::Leave(KErrNotReady);	
  1045 		}
  1052 		}
  1046 
  1053 
  1047 	//
  1054 	//
  1048 	// Open connecton to CommDB Bearer record specified by the IAP.
  1055 	// Open connecton to CommDB Bearer record specified by the IAP.
  1071 		}		  	
  1078 		}		  	
  1072   	
  1079   	
  1073   	TRAPD(ret,iapRecord->LoadL(*iCommsDat));
  1080   	TRAPD(ret,iapRecord->LoadL(*iCommsDat));
  1074 	if (ret != KErrNone)
  1081 	if (ret != KErrNone)
  1075 		{
  1082 		{
  1076 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CONNECTTOCOMMDBBEARERRECORDL_3, "iapRecord->LoadL(*iCommsDat) left with[%d] ", ret);
  1083 		__FLOG_1(_L8("iapRecord->LoadL(*iCommsDat) left with[%d] "), ret);
  1077 		User::Leave(ret);
  1084 		User::Leave(ret);
  1078 		}    
  1085 		}    
  1079     
  1086     
  1080     // If we enabled viewing hidden records now disable viewing them.
  1087     // If we enabled viewing hidden records now disable viewing them.
  1081     if(!hiddenAttributeMaskValue)
  1088     if(!hiddenAttributeMaskValue)
  1091 	iModemId = iapRecord->iBearer;
  1098 	iModemId = iapRecord->iBearer;
  1092 	CleanupStack::PopAndDestroy(iapRecord);
  1099 	CleanupStack::PopAndDestroy(iapRecord);
  1093 	
  1100 	
  1094 	if(iModemId == 0) // ID not found.
  1101 	if(iModemId == 0) // ID not found.
  1095 		{
  1102 		{
  1096 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CONNECTTOCOMMDBBEARERRECORDL_4, "iModemId[%d] is not found", iModemId);
  1103 		__FLOG_1(_L8("iModemId[%d] is not found"), iModemId);
  1097 		User::Leave(KErrNotFound);	
  1104 		User::Leave(KErrNotFound);	
  1098 		}
  1105 		}
  1099 	}
  1106 	}
  1100 
  1107 
  1101 
  1108 
  1102 /** Cancels an outstanding Ioctl, if any. */
  1109 /** Cancels an outstanding Ioctl, if any. */
  1103 void CC32Bca::CancelIoctl()
  1110 void CC32Bca::CancelIoctl()
  1104 	{
  1111 	{
  1105 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CANCELIOCTL_1, "CancelIoctl(): Ioctl cancel request. No Ioctl to cancel.");
  1112 	__FLOG(_L8("CancelIoctl(): Ioctl cancel request. No Ioctl to cancel."));
  1106 	}
  1113 	}
  1107 	
  1114 	
  1108 
  1115 
  1109 /** Closes the Comm port and Comm Server.*/
  1116 /** Closes the Comm port and Comm Server.*/
  1110 void CC32Bca::CloseCommPort()
  1117 void CC32Bca::CloseCommPort()
  1127 		{
  1134 		{
  1128 		iComm.Close(); 
  1135 		iComm.Close(); 
  1129 		iCommServ.Close();	
  1136 		iCommServ.Close();	
  1130 		iCommPortOpen = EFalse;
  1137 		iCommPortOpen = EFalse;
  1131 		}
  1138 		}
  1132 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CLOSECOMMPORT_1, "CloseCommPort(): Session with C32 & RComm closed.");
  1139 	__FLOG(_L8("CloseCommPort(): Session with C32 & RComm closed."));
  1133 	}
  1140 	}
  1134 
  1141 
  1135 /**
  1142 /**
  1136 C32Bca Panic function
  1143 C32Bca Panic function
  1137 @internalComponent
  1144 @internalComponent
  1138 */		
  1145 */		
  1139 void C32Bca::Panic(TC32BcaPanic aPanic)
  1146 void C32Bca::Panic(TC32BcaPanic aPanic)
  1140 	{
  1147 	{
  1141     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_PANIC_1, "%S Panic %d", KC32BcaPanic(), aPanic);
  1148 	__FLOG_STATIC2(KC32BcaLogFolder,KC32BcaLogFile,_L8("%S Panic %d"), &KC32BcaPanic(), aPanic);
  1142 	User::Panic(KC32BcaPanic, aPanic);
  1149 	User::Panic(KC32BcaPanic, aPanic);
  1143 	}
  1150 	}
  1144 	
  1151 	
  1145 
  1152 
  1146 // MC32User implementation:
  1153 // MC32User implementation:
  1164 	}
  1171 	}
  1165 
  1172 
  1166 // Upcall from the link monitor: Link has gone down.	
  1173 // Upcall from the link monitor: Link has gone down.	
  1167 void CC32Bca::CommLinkDown(TInt aErr)
  1174 void CC32Bca::CommLinkDown(TInt aErr)
  1168 	{
  1175 	{
  1169 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_COMMLINKDOWN_1, "CommLinkDown: Warning: serial link has gone down with error[%d]. Erroring the outstanding Read & Write.", aErr);
  1176 	__FLOG_1(_L8("CommLinkDown: Warning: serial link has gone down with error[%d]. Erroring the outstanding Read & Write."), aErr);
  1170 	
  1177 	
  1171 	__ASSERT_DEBUG(KErrNone != aErr, Panic(EGeneralLogicError)); // If KErrNone, use has no way to know that the read has failed.
  1178 	__ASSERT_DEBUG(KErrNone != aErr, Panic(EGeneralLogicError)); // If KErrNone, use has no way to know that the read has failed.
  1172 	if(iReader->IsActive())
  1179 	if(iReader->IsActive())
  1173 		{
  1180 		{
  1174 		CommReadComplete(aErr);
  1181 		CommReadComplete(aErr);