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