os/graphics/windowing/windowserver/debuglog/DEBLOGSR.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// code for the serial device derived class 
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "../SERVER/w32cmd.h"
sl@0
    19
#include "DEBLOGSR.H"
sl@0
    20
sl@0
    21
/*#if defined(__WINS__)
sl@0
    22
#pragma data_seg(".E32_UID")
sl@0
    23
__WINS_UID(0, KWservLoggingDllUidValue, 0)
sl@0
    24
#pragma data_seg()
sl@0
    25
#endif*/
sl@0
    26
sl@0
    27
//#define DEBUGLOG_SHOW_TRACE
sl@0
    28
sl@0
    29
#ifdef DEBUGLOG_SHOW_TRACE
sl@0
    30
void ShowTrace(TRefByValue<const TDesC> aFmt,...)
sl@0
    31
	{
sl@0
    32
	RDebug::Print(aFmt);
sl@0
    33
	}
sl@0
    34
#else
sl@0
    35
void ShowTrace(TRefByValue<const TDesC> /*aFmt*/,...)
sl@0
    36
	{
sl@0
    37
	}
sl@0
    38
#endif
sl@0
    39
sl@0
    40
sl@0
    41
sl@0
    42
EXPORT_C CDebugLogBase *CreateDebugLog(TBool aIsFirst, TDesC &aParams)
sl@0
    43
	{
sl@0
    44
	CDebugLogSerial *device=new(ELeave) CDebugLogSerial();
sl@0
    45
	CDebugLog *log=NULL;
sl@0
    46
	ShowTrace(_L("!!$L Allocating Log"));
sl@0
    47
	TRAPD(err,log=new(ELeave) CDebugLog(device));
sl@0
    48
	if (err!=KErrNone)
sl@0
    49
		{
sl@0
    50
		delete device;
sl@0
    51
		User::Leave(err);
sl@0
    52
		}
sl@0
    53
	ShowTrace(_L("!!$L Initialising Log"));
sl@0
    54
	TRAP(err,log->ConstructL(aIsFirst, aParams));
sl@0
    55
	if (err!=KErrNone)
sl@0
    56
		{
sl@0
    57
		delete log;
sl@0
    58
		User::Leave(err);
sl@0
    59
		}
sl@0
    60
	return(log);
sl@0
    61
	}
sl@0
    62
sl@0
    63
sl@0
    64
CDebugLogSerial::CDebugLogSerial()
sl@0
    65
	{
sl@0
    66
	__DECLARE_NAME(_S("CDebugLogSerial"));
sl@0
    67
	}
sl@0
    68
sl@0
    69
CDebugLogSerial::~CDebugLogSerial()
sl@0
    70
	{
sl@0
    71
	iSerialPort.Close();
sl@0
    72
	}
sl@0
    73
sl@0
    74
void CDebugLogSerial::ConstructL(TBool , TDesC &)
sl@0
    75
	{
sl@0
    76
#if defined(__EPOC32__)
sl@0
    77
	ShowTrace(_L("!!$L Getting Dev1"));
sl@0
    78
	User::LeaveIfError(User::LoadPhysicalDevice(_L("EUART1")));
sl@0
    79
#else
sl@0
    80
	User::LeaveIfError(User::LoadPhysicalDevice(_L("ECDRV")));
sl@0
    81
#endif
sl@0
    82
	ShowTrace(_L("!!$L Getting Dev2"));
sl@0
    83
	User::LeaveIfError(User::LoadLogicalDevice(_L("ECOMM")));
sl@0
    84
	iSerialPort.Open(0);
sl@0
    85
//
sl@0
    86
	TCommConfig cBuf;
sl@0
    87
	TCommConfigV01& c=cBuf();
sl@0
    88
	iSerialPort.Config(cBuf);
sl@0
    89
//	c.iRate=EBps19200;
sl@0
    90
	c.iRate=EBps115200;
sl@0
    91
	c.iHandshake=0;
sl@0
    92
	ShowTrace(_L("!!$L Configering Port"));
sl@0
    93
	User::LeaveIfError(iSerialPort.SetConfig(cBuf));
sl@0
    94
	}
sl@0
    95
sl@0
    96
void CDebugLogSerial::WriteToLogL(const TDesC &aDes, const TDesC &aDes2)
sl@0
    97
	{
sl@0
    98
	TBuf<LogTBufSize+2> buf(aDes);
sl@0
    99
	buf.Append(TPtrC(_S("\r\n")));
sl@0
   100
	TRequestStatus stat;
sl@0
   101
	iSerialPort.Write(stat,TPtrC8((TUint8 *)buf.Ptr(),buf.Size()));
sl@0
   102
	User::WaitForRequest(stat);
sl@0
   103
	User::LeaveIfError(stat.Int());
sl@0
   104
//
sl@0
   105
	iSerialPort.Write(stat,TPtrC8((TUint8 *)aDes2.Ptr(),aDes2.Size()));
sl@0
   106
	User::WaitForRequest(stat);
sl@0
   107
	User::LeaveIfError(stat.Int());
sl@0
   108
	}
sl@0
   109
sl@0
   110
void CDebugLogSerial::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)
sl@0
   111
	{
sl@0
   112
	TBuf8<LogTBufSize+2> buf(aDes);
sl@0
   113
	buf.Append(TPtrC(_S("\r\n")));
sl@0
   114
	TRequestStatus stat;
sl@0
   115
	iSerialPort.Write(stat,buf);
sl@0
   116
	User::WaitForRequest(stat);
sl@0
   117
	User::LeaveIfError(stat.Int());
sl@0
   118
//
sl@0
   119
	iSerialPort.Write(stat,aDes2);
sl@0
   120
	User::WaitForRequest(stat);
sl@0
   121
	User::LeaveIfError(stat.Int());
sl@0
   122
	}
sl@0
   123