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". |
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_SETUP_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_NOTIFYLINKDOWN_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_RUNL_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 |
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_CTOR_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 |
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_DTOR_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_RELEASE_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_OPEN_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_OPEN_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_OPEN_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_OPEN_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_OPEN_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_OPEN_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_OPEN_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_OPEN_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_SHUTDOWN_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_CLOSE_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); |
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 |
645 |
644 /** |
646 |
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 |
647 |
657 |
648 |
658 /** |
649 /** |
659 * Ioctl: asynchronously controls the C32Bca. |
650 * Ioctl: asynchronously controls the C32Bca. |
660 |
651 |
664 * @param aOpt an optional parameter,holds the option value on return or the option value to be set. |
655 * @param aOpt an optional parameter,holds the option value on return or the option value to be set. |
665 */ |
656 */ |
666 void CC32Bca::Ioctl(TRequestStatus& aStatus, TUint aOptLevel, TUint aOptName, TDes8& aOpt) |
657 void CC32Bca::Ioctl(TRequestStatus& aStatus, TUint aOptLevel, TUint aOptName, TDes8& aOpt) |
667 |
658 |
668 { |
659 { |
669 __FLOG_4(_L8("Ioctl: Level[%S](0x%X) Name[%S](0x%X)."), &IoctlOptLevelStr(aOptLevel), aOptLevel, &IoctlOptNameStr(aOptName), aOptName); |
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); |
670 |
661 |
671 aStatus = KRequestPending; |
662 aStatus = KRequestPending; |
672 |
663 |
673 TInt ret(KErrNone); // If operation fails, this will be set to the failure code explicitly. |
664 TInt ret(KErrNone); // If operation fails, this will be set to the failure code explicitly. |
674 |
665 |
743 break; |
734 break; |
744 } |
735 } |
745 |
736 |
746 case KSerialConfig: |
737 case KSerialConfig: |
747 { |
738 { |
748 __FLOG(_L8("Ioctl: KSerialConfig")); |
739 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_3, "Ioctl: KSerialConfig"); |
749 |
740 |
750 TCommConfig cfg; |
741 TCommConfig cfg; |
751 iComm.Config(cfg); |
742 iComm.Config(cfg); |
752 |
743 |
753 #ifdef __FLOG_ACTIVE |
744 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_4, "Rate[%d] DataBits[%d] StopBits[%d]", cfg().iRate, cfg().iDataBits, cfg().iStopBits); |
754 LogCommConfig(cfg); |
745 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_5, "Parity[%d] Handshake[0x%x]", cfg().iParity, cfg().iHandshake); |
755 #endif // __FLOG_ACTIVE |
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); |
|
747 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_7, "Terminator[0x%x]", cfg().iTerminator); |
756 |
748 |
757 TPckgBuf<TCommConfig> cfgBuf(cfg); |
749 TPckgBuf<TCommConfig> cfgBuf(cfg); |
758 aOpt.Copy(cfgBuf); |
750 aOpt.Copy(cfgBuf); |
759 break; |
751 break; |
760 } |
752 } |
761 |
753 |
762 case KSerialSetConfig: |
754 case KSerialSetConfig: |
763 { |
755 { |
764 __FLOG(_L8("Ioctl: KSerialSetConfig")); |
756 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_8, "Ioctl: KSerialSetConfig"); |
765 |
757 |
766 TCommConfig cfg(*(reinterpret_cast<const TCommConfig*>(aOpt.Ptr()))); |
758 TCommConfig cfg(*(reinterpret_cast<const TCommConfig*>(aOpt.Ptr()))); |
767 |
759 |
768 #ifdef __FLOG_ACTIVE |
760 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_9, "Rate[%d] DataBits[%d] StopBits[%d]", cfg().iRate, cfg().iDataBits, cfg().iStopBits); |
769 LogCommConfig(cfg); |
761 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_10, "Parity[%d] Handshake[0x%x]", cfg().iParity, cfg().iHandshake); |
770 #endif // __FLOG_ACTIVE |
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); |
771 |
763 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_12, "Terminator[0x%x]", cfg().iTerminator); |
|
764 |
772 ret = iComm.SetConfig(cfg); |
765 ret = iComm.SetConfig(cfg); |
773 break; |
766 break; |
774 } |
767 } |
775 |
768 |
776 case KSerialPortName: |
769 case KSerialPortName: |
785 { |
778 { |
786 iCsyName.Copy(*( |
779 iCsyName.Copy(*( |
787 reinterpret_cast<const TName*>(aOpt.Ptr()) |
780 reinterpret_cast<const TName*>(aOpt.Ptr()) |
788 )); |
781 )); |
789 iCsyNameOverride = ETrue; |
782 iCsyNameOverride = ETrue; |
790 __FLOG_1(_L8("Ioctl: CSY Name set to [%S]"), &iCsyName); |
783 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_13, "Ioctl: CSY Name set to [%S]", iCsyName); |
791 } |
784 } |
792 else |
785 else |
793 { |
786 { |
794 __FLOG(_L8("Ioctl: Warning: Cannot set the CSY name because the Comm Port is already open.")); |
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."); |
795 ret = KErrAlreadyExists; |
788 ret = KErrAlreadyExists; |
796 } |
789 } |
797 |
790 |
798 break; |
791 break; |
799 } |
792 } |
802 { |
795 { |
803 if(!iCommPortOpen) |
796 if(!iCommPortOpen) |
804 { |
797 { |
805 iCommRole = *(reinterpret_cast<const TCommRole*>(aOpt.Ptr())); |
798 iCommRole = *(reinterpret_cast<const TCommRole*>(aOpt.Ptr())); |
806 iCommRoleOverride = ETrue; |
799 iCommRoleOverride = ETrue; |
807 __FLOG_1(_L8("Ioctl: Comm Role set to [%d]"), iCommRole); |
800 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_15, "Ioctl: Comm Role set to [%d]", iCommRole); |
808 } |
801 } |
809 else |
802 else |
810 { |
803 { |
811 __FLOG(_L8("Ioctl: Warning: Cannot set Comm Role because the Comm Port is already open.")); |
804 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_16, "Ioctl: Warning: Cannot set Comm Role because the Comm Port is already open."); |
812 ret = KErrAlreadyExists; |
805 ret = KErrAlreadyExists; |
813 } |
806 } |
814 break; |
807 break; |
815 } |
808 } |
816 |
809 |
817 case KSerialSetTxRxBufferSize: |
810 case KSerialSetTxRxBufferSize: |
818 { |
811 { |
819 TInt bufSize = *(reinterpret_cast<const TInt*>(aOpt.Ptr())); |
812 TInt bufSize = *(reinterpret_cast<const TInt*>(aOpt.Ptr())); |
820 __FLOG_1(_L8("Ioctl: Setting Rx Tx buffer size to [%d]"), bufSize); |
813 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_17, "Ioctl: Setting Rx Tx buffer size to [%d]", bufSize); |
821 |
814 |
822 iComm.SetReceiveBufferLength(bufSize); |
815 iComm.SetReceiveBufferLength(bufSize); |
823 break; |
816 break; |
824 } |
817 } |
825 |
818 |
836 ret = KErrArgument; |
829 ret = KErrArgument; |
837 } |
830 } |
838 else |
831 else |
839 { |
832 { |
840 const TSerialSetControlLines& lines = *(reinterpret_cast<const TSerialSetControlLines*>(aOpt.Ptr())); |
833 const TSerialSetControlLines& lines = *(reinterpret_cast<const TSerialSetControlLines*>(aOpt.Ptr())); |
841 __FLOG_2(_L8("Ioctl: Setting/clearing control lines %x/%x"), lines.iSetMask, lines.iClearMask); |
834 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_18, "Ioctl: Setting/clearing control lines %x/%x", lines.iSetMask, lines.iClearMask); |
842 iComm.SetSignals(lines.iSetMask, lines.iClearMask); |
835 iComm.SetSignals(lines.iSetMask, lines.iClearMask); |
843 ret = KErrNone; |
836 ret = KErrNone; |
844 } |
837 } |
845 break; |
838 break; |
846 } |
839 } |
853 { |
846 { |
854 ret = KErrNotSupported; |
847 ret = KErrNotSupported; |
855 } |
848 } |
856 |
849 |
857 |
850 |
858 __FLOG_1(_L8("Ioctl completed with error %d"), ret); |
851 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_IOCTL_19, "Ioctl completed with error %d", ret); |
859 |
852 |
860 TRequestStatus* ptrStatus = &aStatus; |
853 TRequestStatus* ptrStatus = &aStatus; |
861 User::RequestComplete(ptrStatus, ret); |
854 User::RequestComplete(ptrStatus, ret); |
862 } |
855 } |
863 |
856 |
869 |
862 |
870 @leave if the monitoring object cannot be constructed, typically due to OOM. |
863 @leave if the monitoring object cannot be constructed, typically due to OOM. |
871 */ |
864 */ |
872 void CC32Bca::MonitorControlLinesL(TUint32 aArgMask) |
865 void CC32Bca::MonitorControlLinesL(TUint32 aArgMask) |
873 { |
866 { |
874 __FLOG_1(_L8("Ioctl: argument bitmask = [0x%X] "), aArgMask); |
867 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_MONITORCONTROLLINESL_1, "Ioctl: argument bitmask = [0x%X] ", aArgMask); |
875 |
868 |
876 if(iLinkMonitor) // We may have never started... |
869 if(iLinkMonitor) // We may have never started... |
877 { |
870 { |
878 // We are called to either stop or change the monitoring options. |
871 // We are called to either stop or change the monitoring options. |
879 iLinkMonitor->Cancel(); // If we are not monitoring, this has no effect. |
872 iLinkMonitor->Cancel(); // If we are not monitoring, this has no effect. |
880 } |
873 } |
881 |
874 |
882 if(KMonitorOff == aArgMask) // Stop monitoring: |
875 if(KMonitorOff == aArgMask) // Stop monitoring: |
883 { |
876 { |
884 __FLOG(_L8("MonitorControlLinesL: Stopping Control Lines monitoring.")); |
877 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_MONITORCONTROLLINESL_2, "MonitorControlLinesL: Stopping Control Lines monitoring."); |
885 // We either never started, or we just cancelled above. |
878 // We either never started, or we just cancelled above. |
886 } |
879 } |
887 else // Start Monitoring, or change the monitored lines. |
880 else // Start Monitoring, or change the monitored lines. |
888 { |
881 { |
889 __FLOG(_L8("MonitorControlLinesL: Starting to monitor Control Lines.")); |
882 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_MONITORCONTROLLINESL_3, "MonitorControlLinesL: Starting to monitor Control Lines."); |
890 |
883 |
891 if(!iLinkMonitor) // We are starting to monitor for the first time |
884 if(!iLinkMonitor) // We are starting to monitor for the first time |
892 { |
885 { |
893 iLinkMonitor = new (ELeave)CCommLinkMonitor(*this, iComm); |
886 iLinkMonitor = new (ELeave)CCommLinkMonitor(*this, iComm); |
894 } |
887 } |
933 } |
926 } |
934 |
927 |
935 iLinkMonitor->Setup(lineMask); |
928 iLinkMonitor->Setup(lineMask); |
936 iLinkMonitor->NotifyLinkDown(); |
929 iLinkMonitor->NotifyLinkDown(); |
937 |
930 |
938 __FLOG(_L8("MonitorControlLinesL: Control Lines monitoring started.")); |
931 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_MONITORCONTROLLINESL_4, "MonitorControlLinesL: Control Lines monitoring started."); |
939 } |
932 } |
940 } |
933 } |
941 |
934 |
942 /** |
935 /** |
943 Closes the connection to CommDB, if it is open */ |
936 Closes the connection to CommDB, if it is open */ |
951 Read Comm Port from CommDB bearer record |
944 Read Comm Port from CommDB bearer record |
952 @param aPortName |
945 @param aPortName |
953 @leave if the value could not be read */ |
946 @leave if the value could not be read */ |
954 void CC32Bca::ReadCommPortFromCommDbL(TDes& aPortName) |
947 void CC32Bca::ReadCommPortFromCommDbL(TDes& aPortName) |
955 { |
948 { |
956 __FLOG(_L8("CC32Bca::ReadCommPortFromCommDbL()")); |
949 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCOMMPORTFROMCOMMDBL_1, "CC32Bca::ReadCommPortFromCommDbL()"); |
957 ConnectToCommDbBearerRecordL(); |
950 ConnectToCommDbBearerRecordL(); |
958 |
951 |
959 TInt ret(0); |
952 TInt ret(0); |
960 CMDBField<TDesC>* portField = new(ELeave) CMDBField<TDesC>(KCDTIdPortName); |
953 CMDBField<TDesC>* portField = new(ELeave) CMDBField<TDesC>(KCDTIdPortName); |
961 CleanupStack::PushL(portField); |
954 CleanupStack::PushL(portField); |
964 portField->SetMaxLengthL(KMaxTextLength); |
957 portField->SetMaxLengthL(KMaxTextLength); |
965 TRAP(ret,portField->LoadL(*iCommsDat)); |
958 TRAP(ret,portField->LoadL(*iCommsDat)); |
966 |
959 |
967 if(ret!=KErrNone) |
960 if(ret!=KErrNone) |
968 { |
961 { |
969 __FLOG_1(_L8("portField->LoadL(*iCommsDat) left with[%d] "), ret); |
962 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCOMMPORTFROMCOMMDBL_2, "portField->LoadL(*iCommsDat) left with[%d] ", ret); |
970 User::Leave(ret); |
963 User::Leave(ret); |
971 } |
964 } |
972 |
965 |
973 aPortName = *portField; |
966 aPortName = *portField; |
974 CleanupStack::PopAndDestroy(portField); |
967 CleanupStack::PopAndDestroy(portField); |
978 Read the CSY name from CommDB bearer record. |
971 Read the CSY name from CommDB bearer record. |
979 @param aCsyName the CSY name |
972 @param aCsyName the CSY name |
980 @leave if the value could not be read */ |
973 @leave if the value could not be read */ |
981 void CC32Bca::ReadCsyNameFromCommDbL(TDes& aCsyName) |
974 void CC32Bca::ReadCsyNameFromCommDbL(TDes& aCsyName) |
982 { |
975 { |
983 __FLOG(_L8("CC32Bca::ReadCsyNameFromCommDbL()")); |
976 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCSYNAMEFROMCOMMDBL_1, "CC32Bca::ReadCsyNameFromCommDbL()"); |
984 ConnectToCommDbBearerRecordL(); |
977 ConnectToCommDbBearerRecordL(); |
985 |
978 |
986 TInt ret(0); |
979 TInt ret(0); |
987 CMDBField<TDesC>* csyField = new(ELeave) CMDBField<TDesC>(KCDTIdCsyName); |
980 CMDBField<TDesC>* csyField = new(ELeave) CMDBField<TDesC>(KCDTIdCsyName); |
988 CleanupStack::PushL(csyField); |
981 CleanupStack::PushL(csyField); |
991 csyField->SetMaxLengthL(KMaxTextLength); |
984 csyField->SetMaxLengthL(KMaxTextLength); |
992 TRAP(ret,csyField->LoadL(*iCommsDat)); |
985 TRAP(ret,csyField->LoadL(*iCommsDat)); |
993 |
986 |
994 if(ret!=KErrNone) |
987 if(ret!=KErrNone) |
995 { |
988 { |
996 __FLOG_1(_L8("csyField->LoadL(*iCommsDat) left with[%d] "), ret); |
989 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCSYNAMEFROMCOMMDBL_2, "csyField->LoadL(*iCommsDat) left with[%d] ", ret); |
997 User::Leave(ret); |
990 User::Leave(ret); |
998 } |
991 } |
999 |
992 |
1000 aCsyName = *csyField; |
993 aCsyName = *csyField; |
1001 CleanupStack::PopAndDestroy(csyField); |
994 CleanupStack::PopAndDestroy(csyField); |
1006 |
999 |
1007 @param aCommRole the specified role. |
1000 @param aCommRole the specified role. |
1008 @leave if the value could not be read */ |
1001 @leave if the value could not be read */ |
1009 void CC32Bca::ReadCommRoleFromCommDbL(TCommRole& aCommRole) |
1002 void CC32Bca::ReadCommRoleFromCommDbL(TCommRole& aCommRole) |
1010 { |
1003 { |
1011 __FLOG(_L8("CC32Bca::ReadCommRoleFromCommDbL()")); |
1004 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCOMMROLEFROMCOMMDBL_1, "CC32Bca::ReadCommRoleFromCommDbL()"); |
1012 ConnectToCommDbBearerRecordL(); |
1005 ConnectToCommDbBearerRecordL(); |
1013 TUint32 role(0); |
1006 TUint32 role(0); |
1014 |
1007 |
1015 TInt ret(0); |
1008 TInt ret(0); |
1016 CMDBField<TUint32>* roleField = new(ELeave) CMDBField<TUint32>(KCDTIdCommRole); |
1009 CMDBField<TUint32>* roleField = new(ELeave) CMDBField<TUint32>(KCDTIdCommRole); |
1019 roleField->SetRecordId(iModemId); |
1012 roleField->SetRecordId(iModemId); |
1020 TRAP(ret,roleField->LoadL(*iCommsDat)); |
1013 TRAP(ret,roleField->LoadL(*iCommsDat)); |
1021 |
1014 |
1022 if(ret!=KErrNone) |
1015 if(ret!=KErrNone) |
1023 { |
1016 { |
1024 __FLOG_1(_L8("roleField->LoadL(*iCommsDat) left with[%d] "), ret); |
1017 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_READCOMMROLEFROMCOMMDBL_2, "roleField->LoadL(*iCommsDat) left with[%d] ", ret); |
1025 User::Leave(ret); |
1018 User::Leave(ret); |
1026 } |
1019 } |
1027 |
1020 |
1028 role = *roleField; |
1021 role = *roleField; |
1029 CleanupStack::PopAndDestroy(roleField); |
1022 CleanupStack::PopAndDestroy(roleField); |
1037 @leave KErrNotReady, if the provisioned IAP id is invalid. System-wide error code |
1030 @leave KErrNotReady, if the provisioned IAP id is invalid. System-wide error code |
1038 if the connection cannot be opened for some other reason. |
1031 if the connection cannot be opened for some other reason. |
1039 */ |
1032 */ |
1040 void CC32Bca::ConnectToCommDbBearerRecordL() |
1033 void CC32Bca::ConnectToCommDbBearerRecordL() |
1041 { |
1034 { |
1042 __FLOG(_L8("CC32Bca::ConnectToCommDbBearerRecordL()")); |
1035 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CONNECTTOCOMMDBBEARERRECORDL_1, "CC32Bca::ConnectToCommDbBearerRecordL()"); |
1043 if(iCommsDat != NULL) // CommDB is already open, we don't need to do anything |
1036 if(iCommsDat != NULL) // CommDB is already open, we don't need to do anything |
1044 { |
1037 { |
1045 return; |
1038 return; |
1046 } |
1039 } |
1047 |
1040 |
1048 if(iIapId < 1) // Can't access CommDB if IAP ID is unknown |
1041 if(iIapId < 1) // Can't access CommDB if IAP ID is unknown |
1049 { |
1042 { |
1050 __FLOG_1(_L8("iIapId[%d] is unknown"), iIapId); |
1043 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CONNECTTOCOMMDBBEARERRECORDL_2, "iIapId[%d] is unknown", iIapId); |
1051 User::Leave(KErrNotReady); |
1044 User::Leave(KErrNotReady); |
1052 } |
1045 } |
1053 |
1046 |
1054 // |
1047 // |
1055 // Open connecton to CommDB Bearer record specified by the IAP. |
1048 // Open connecton to CommDB Bearer record specified by the IAP. |
1078 } |
1071 } |
1079 |
1072 |
1080 TRAPD(ret,iapRecord->LoadL(*iCommsDat)); |
1073 TRAPD(ret,iapRecord->LoadL(*iCommsDat)); |
1081 if (ret != KErrNone) |
1074 if (ret != KErrNone) |
1082 { |
1075 { |
1083 __FLOG_1(_L8("iapRecord->LoadL(*iCommsDat) left with[%d] "), ret); |
1076 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CONNECTTOCOMMDBBEARERRECORDL_3, "iapRecord->LoadL(*iCommsDat) left with[%d] ", ret); |
1084 User::Leave(ret); |
1077 User::Leave(ret); |
1085 } |
1078 } |
1086 |
1079 |
1087 // If we enabled viewing hidden records now disable viewing them. |
1080 // If we enabled viewing hidden records now disable viewing them. |
1088 if(!hiddenAttributeMaskValue) |
1081 if(!hiddenAttributeMaskValue) |
1098 iModemId = iapRecord->iBearer; |
1091 iModemId = iapRecord->iBearer; |
1099 CleanupStack::PopAndDestroy(iapRecord); |
1092 CleanupStack::PopAndDestroy(iapRecord); |
1100 |
1093 |
1101 if(iModemId == 0) // ID not found. |
1094 if(iModemId == 0) // ID not found. |
1102 { |
1095 { |
1103 __FLOG_1(_L8("iModemId[%d] is not found"), iModemId); |
1096 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CONNECTTOCOMMDBBEARERRECORDL_4, "iModemId[%d] is not found", iModemId); |
1104 User::Leave(KErrNotFound); |
1097 User::Leave(KErrNotFound); |
1105 } |
1098 } |
1106 } |
1099 } |
1107 |
1100 |
1108 |
1101 |
1109 /** Cancels an outstanding Ioctl, if any. */ |
1102 /** Cancels an outstanding Ioctl, if any. */ |
1110 void CC32Bca::CancelIoctl() |
1103 void CC32Bca::CancelIoctl() |
1111 { |
1104 { |
1112 __FLOG(_L8("CancelIoctl(): Ioctl cancel request. No Ioctl to cancel.")); |
1105 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CANCELIOCTL_1, "CancelIoctl(): Ioctl cancel request. No Ioctl to cancel."); |
1113 } |
1106 } |
1114 |
1107 |
1115 |
1108 |
1116 /** Closes the Comm port and Comm Server.*/ |
1109 /** Closes the Comm port and Comm Server.*/ |
1117 void CC32Bca::CloseCommPort() |
1110 void CC32Bca::CloseCommPort() |
1134 { |
1127 { |
1135 iComm.Close(); |
1128 iComm.Close(); |
1136 iCommServ.Close(); |
1129 iCommServ.Close(); |
1137 iCommPortOpen = EFalse; |
1130 iCommPortOpen = EFalse; |
1138 } |
1131 } |
1139 __FLOG(_L8("CloseCommPort(): Session with C32 & RComm closed.")); |
1132 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_CLOSECOMMPORT_1, "CloseCommPort(): Session with C32 & RComm closed."); |
1140 } |
1133 } |
1141 |
1134 |
1142 /** |
1135 /** |
1143 C32Bca Panic function |
1136 C32Bca Panic function |
1144 @internalComponent |
1137 @internalComponent |
1145 */ |
1138 */ |
1146 void C32Bca::Panic(TC32BcaPanic aPanic) |
1139 void C32Bca::Panic(TC32BcaPanic aPanic) |
1147 { |
1140 { |
1148 __FLOG_STATIC2(KC32BcaLogFolder,KC32BcaLogFile,_L8("%S Panic %d"), &KC32BcaPanic(), aPanic); |
1141 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CC32BCA_PANIC_1, "%S Panic %d", KC32BcaPanic(), aPanic); |
1149 User::Panic(KC32BcaPanic, aPanic); |
1142 User::Panic(KC32BcaPanic, aPanic); |
1150 } |
1143 } |
1151 |
1144 |
1152 |
1145 |
1153 // MC32User implementation: |
1146 // MC32User implementation: |
1171 } |
1164 } |
1172 |
1165 |
1173 // Upcall from the link monitor: Link has gone down. |
1166 // Upcall from the link monitor: Link has gone down. |
1174 void CC32Bca::CommLinkDown(TInt aErr) |
1167 void CC32Bca::CommLinkDown(TInt aErr) |
1175 { |
1168 { |
1176 __FLOG_1(_L8("CommLinkDown: Warning: serial link has gone down with error[%d]. Erroring the outstanding Read & Write."), aErr); |
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); |
1177 |
1170 |
1178 __ASSERT_DEBUG(KErrNone != aErr, Panic(EGeneralLogicError)); // If KErrNone, use has no way to know that the read has failed. |
1171 __ASSERT_DEBUG(KErrNone != aErr, Panic(EGeneralLogicError)); // If KErrNone, use has no way to know that the read has failed. |
1179 if(iReader->IsActive()) |
1172 if(iReader->IsActive()) |
1180 { |
1173 { |
1181 CommReadComplete(aErr); |
1174 CommReadComplete(aErr); |