Update contrib.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // code for the serial device derived class
18 #include "../SERVER/w32cmd.h"
21 /*#if defined(__WINS__)
22 #pragma data_seg(".E32_UID")
23 __WINS_UID(0, KWservLoggingDllUidValue, 0)
27 //#define DEBUGLOG_SHOW_TRACE
29 #ifdef DEBUGLOG_SHOW_TRACE
30 void ShowTrace(TRefByValue<const TDesC> aFmt,...)
35 void ShowTrace(TRefByValue<const TDesC> /*aFmt*/,...)
42 EXPORT_C CDebugLogBase *CreateDebugLog(TBool aIsFirst, TDesC &aParams)
44 CDebugLogSerial *device=new(ELeave) CDebugLogSerial();
46 ShowTrace(_L("!!$L Allocating Log"));
47 TRAPD(err,log=new(ELeave) CDebugLog(device));
53 ShowTrace(_L("!!$L Initialising Log"));
54 TRAP(err,log->ConstructL(aIsFirst, aParams));
64 CDebugLogSerial::CDebugLogSerial()
66 __DECLARE_NAME(_S("CDebugLogSerial"));
69 CDebugLogSerial::~CDebugLogSerial()
74 void CDebugLogSerial::ConstructL(TBool , TDesC &)
76 #if defined(__EPOC32__)
77 ShowTrace(_L("!!$L Getting Dev1"));
78 User::LeaveIfError(User::LoadPhysicalDevice(_L("EUART1")));
80 User::LeaveIfError(User::LoadPhysicalDevice(_L("ECDRV")));
82 ShowTrace(_L("!!$L Getting Dev2"));
83 User::LeaveIfError(User::LoadLogicalDevice(_L("ECOMM")));
87 TCommConfigV01& c=cBuf();
88 iSerialPort.Config(cBuf);
92 ShowTrace(_L("!!$L Configering Port"));
93 User::LeaveIfError(iSerialPort.SetConfig(cBuf));
96 void CDebugLogSerial::WriteToLogL(const TDesC &aDes, const TDesC &aDes2)
98 TBuf<LogTBufSize+2> buf(aDes);
99 buf.Append(TPtrC(_S("\r\n")));
101 iSerialPort.Write(stat,TPtrC8((TUint8 *)buf.Ptr(),buf.Size()));
102 User::WaitForRequest(stat);
103 User::LeaveIfError(stat.Int());
105 iSerialPort.Write(stat,TPtrC8((TUint8 *)aDes2.Ptr(),aDes2.Size()));
106 User::WaitForRequest(stat);
107 User::LeaveIfError(stat.Int());
110 void CDebugLogSerial::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)
112 TBuf8<LogTBufSize+2> buf(aDes);
113 buf.Append(TPtrC(_S("\r\n")));
115 iSerialPort.Write(stat,buf);
116 User::WaitForRequest(stat);
117 User::LeaveIfError(stat.Int());
119 iSerialPort.Write(stat,aDes2);
120 User::WaitForRequest(stat);
121 User::LeaveIfError(stat.Int());