1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/debuglog/DEBLOGSR.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,123 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// code for the serial device derived class
1.18 +//
1.19 +//
1.20 +
1.21 +#include "../SERVER/w32cmd.h"
1.22 +#include "DEBLOGSR.H"
1.23 +
1.24 +/*#if defined(__WINS__)
1.25 +#pragma data_seg(".E32_UID")
1.26 +__WINS_UID(0, KWservLoggingDllUidValue, 0)
1.27 +#pragma data_seg()
1.28 +#endif*/
1.29 +
1.30 +//#define DEBUGLOG_SHOW_TRACE
1.31 +
1.32 +#ifdef DEBUGLOG_SHOW_TRACE
1.33 +void ShowTrace(TRefByValue<const TDesC> aFmt,...)
1.34 + {
1.35 + RDebug::Print(aFmt);
1.36 + }
1.37 +#else
1.38 +void ShowTrace(TRefByValue<const TDesC> /*aFmt*/,...)
1.39 + {
1.40 + }
1.41 +#endif
1.42 +
1.43 +
1.44 +
1.45 +EXPORT_C CDebugLogBase *CreateDebugLog(TBool aIsFirst, TDesC &aParams)
1.46 + {
1.47 + CDebugLogSerial *device=new(ELeave) CDebugLogSerial();
1.48 + CDebugLog *log=NULL;
1.49 + ShowTrace(_L("!!$L Allocating Log"));
1.50 + TRAPD(err,log=new(ELeave) CDebugLog(device));
1.51 + if (err!=KErrNone)
1.52 + {
1.53 + delete device;
1.54 + User::Leave(err);
1.55 + }
1.56 + ShowTrace(_L("!!$L Initialising Log"));
1.57 + TRAP(err,log->ConstructL(aIsFirst, aParams));
1.58 + if (err!=KErrNone)
1.59 + {
1.60 + delete log;
1.61 + User::Leave(err);
1.62 + }
1.63 + return(log);
1.64 + }
1.65 +
1.66 +
1.67 +CDebugLogSerial::CDebugLogSerial()
1.68 + {
1.69 + __DECLARE_NAME(_S("CDebugLogSerial"));
1.70 + }
1.71 +
1.72 +CDebugLogSerial::~CDebugLogSerial()
1.73 + {
1.74 + iSerialPort.Close();
1.75 + }
1.76 +
1.77 +void CDebugLogSerial::ConstructL(TBool , TDesC &)
1.78 + {
1.79 +#if defined(__EPOC32__)
1.80 + ShowTrace(_L("!!$L Getting Dev1"));
1.81 + User::LeaveIfError(User::LoadPhysicalDevice(_L("EUART1")));
1.82 +#else
1.83 + User::LeaveIfError(User::LoadPhysicalDevice(_L("ECDRV")));
1.84 +#endif
1.85 + ShowTrace(_L("!!$L Getting Dev2"));
1.86 + User::LeaveIfError(User::LoadLogicalDevice(_L("ECOMM")));
1.87 + iSerialPort.Open(0);
1.88 +//
1.89 + TCommConfig cBuf;
1.90 + TCommConfigV01& c=cBuf();
1.91 + iSerialPort.Config(cBuf);
1.92 +// c.iRate=EBps19200;
1.93 + c.iRate=EBps115200;
1.94 + c.iHandshake=0;
1.95 + ShowTrace(_L("!!$L Configering Port"));
1.96 + User::LeaveIfError(iSerialPort.SetConfig(cBuf));
1.97 + }
1.98 +
1.99 +void CDebugLogSerial::WriteToLogL(const TDesC &aDes, const TDesC &aDes2)
1.100 + {
1.101 + TBuf<LogTBufSize+2> buf(aDes);
1.102 + buf.Append(TPtrC(_S("\r\n")));
1.103 + TRequestStatus stat;
1.104 + iSerialPort.Write(stat,TPtrC8((TUint8 *)buf.Ptr(),buf.Size()));
1.105 + User::WaitForRequest(stat);
1.106 + User::LeaveIfError(stat.Int());
1.107 +//
1.108 + iSerialPort.Write(stat,TPtrC8((TUint8 *)aDes2.Ptr(),aDes2.Size()));
1.109 + User::WaitForRequest(stat);
1.110 + User::LeaveIfError(stat.Int());
1.111 + }
1.112 +
1.113 +void CDebugLogSerial::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)
1.114 + {
1.115 + TBuf8<LogTBufSize+2> buf(aDes);
1.116 + buf.Append(TPtrC(_S("\r\n")));
1.117 + TRequestStatus stat;
1.118 + iSerialPort.Write(stat,buf);
1.119 + User::WaitForRequest(stat);
1.120 + User::LeaveIfError(stat.Int());
1.121 +//
1.122 + iSerialPort.Write(stat,aDes2);
1.123 + User::WaitForRequest(stat);
1.124 + User::LeaveIfError(stat.Int());
1.125 + }
1.126 +