sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // code for the serial device derived class sl@0: // sl@0: // sl@0: sl@0: #include "../SERVER/w32cmd.h" sl@0: #include "DEBLOGSR.H" sl@0: sl@0: /*#if defined(__WINS__) sl@0: #pragma data_seg(".E32_UID") sl@0: __WINS_UID(0, KWservLoggingDllUidValue, 0) sl@0: #pragma data_seg() sl@0: #endif*/ sl@0: sl@0: //#define DEBUGLOG_SHOW_TRACE sl@0: sl@0: #ifdef DEBUGLOG_SHOW_TRACE sl@0: void ShowTrace(TRefByValue aFmt,...) sl@0: { sl@0: RDebug::Print(aFmt); sl@0: } sl@0: #else sl@0: void ShowTrace(TRefByValue /*aFmt*/,...) sl@0: { sl@0: } sl@0: #endif sl@0: sl@0: sl@0: sl@0: EXPORT_C CDebugLogBase *CreateDebugLog(TBool aIsFirst, TDesC &aParams) sl@0: { sl@0: CDebugLogSerial *device=new(ELeave) CDebugLogSerial(); sl@0: CDebugLog *log=NULL; sl@0: ShowTrace(_L("!!$L Allocating Log")); sl@0: TRAPD(err,log=new(ELeave) CDebugLog(device)); sl@0: if (err!=KErrNone) sl@0: { sl@0: delete device; sl@0: User::Leave(err); sl@0: } sl@0: ShowTrace(_L("!!$L Initialising Log")); sl@0: TRAP(err,log->ConstructL(aIsFirst, aParams)); sl@0: if (err!=KErrNone) sl@0: { sl@0: delete log; sl@0: User::Leave(err); sl@0: } sl@0: return(log); sl@0: } sl@0: sl@0: sl@0: CDebugLogSerial::CDebugLogSerial() sl@0: { sl@0: __DECLARE_NAME(_S("CDebugLogSerial")); sl@0: } sl@0: sl@0: CDebugLogSerial::~CDebugLogSerial() sl@0: { sl@0: iSerialPort.Close(); sl@0: } sl@0: sl@0: void CDebugLogSerial::ConstructL(TBool , TDesC &) sl@0: { sl@0: #if defined(__EPOC32__) sl@0: ShowTrace(_L("!!$L Getting Dev1")); sl@0: User::LeaveIfError(User::LoadPhysicalDevice(_L("EUART1"))); sl@0: #else sl@0: User::LeaveIfError(User::LoadPhysicalDevice(_L("ECDRV"))); sl@0: #endif sl@0: ShowTrace(_L("!!$L Getting Dev2")); sl@0: User::LeaveIfError(User::LoadLogicalDevice(_L("ECOMM"))); sl@0: iSerialPort.Open(0); sl@0: // sl@0: TCommConfig cBuf; sl@0: TCommConfigV01& c=cBuf(); sl@0: iSerialPort.Config(cBuf); sl@0: // c.iRate=EBps19200; sl@0: c.iRate=EBps115200; sl@0: c.iHandshake=0; sl@0: ShowTrace(_L("!!$L Configering Port")); sl@0: User::LeaveIfError(iSerialPort.SetConfig(cBuf)); sl@0: } sl@0: sl@0: void CDebugLogSerial::WriteToLogL(const TDesC &aDes, const TDesC &aDes2) sl@0: { sl@0: TBuf buf(aDes); sl@0: buf.Append(TPtrC(_S("\r\n"))); sl@0: TRequestStatus stat; sl@0: iSerialPort.Write(stat,TPtrC8((TUint8 *)buf.Ptr(),buf.Size())); sl@0: User::WaitForRequest(stat); sl@0: User::LeaveIfError(stat.Int()); sl@0: // sl@0: iSerialPort.Write(stat,TPtrC8((TUint8 *)aDes2.Ptr(),aDes2.Size())); sl@0: User::WaitForRequest(stat); sl@0: User::LeaveIfError(stat.Int()); sl@0: } sl@0: sl@0: void CDebugLogSerial::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2) sl@0: { sl@0: TBuf8 buf(aDes); sl@0: buf.Append(TPtrC(_S("\r\n"))); sl@0: TRequestStatus stat; sl@0: iSerialPort.Write(stat,buf); sl@0: User::WaitForRequest(stat); sl@0: User::LeaveIfError(stat.Int()); sl@0: // sl@0: iSerialPort.Write(stat,aDes2); sl@0: User::WaitForRequest(stat); sl@0: User::LeaveIfError(stat.Int()); sl@0: } sl@0: