?? serialtransport.cpp
字號:
// Copyright (c) 2004 - 2007, Symbian Software Ltd. All rights reserved.
#include "serialtransport.h"
CSerialTransport* CSerialTransport::NewIrCommTransportL(TAny* aTransportCreateInfo)
/**
This factory function creates an emulated RS232 connection which loads
the IRCOMM CSY and opens port IRCOMM::0.
@param aTransportCreateInfo Pointer to an instance of
TTransportCreateInfo, which contains the
data required to allocate the transport.
The address field is not used.
@return New, initialized IRCOMM connection.
*/
{
_LIT(KIrCommCsyName, "IRCOMM");
_LIT(KIrCommPortName, "IRCOMM::0");
const TTransportInterfaceCreateInfo& tci =
*reinterpret_cast<TTransportInterfaceCreateInfo*>(aTransportCreateInfo);
return New2L(tci.iObserver, KIrCommCsyName, KIrCommPortName, tci.iInitListen);
}
CSerialTransport* CSerialTransport::NewSerialCommTransportL(TAny* aTransportCreateInfo)
/**
This factory function creates an emulated RS232 connection which loads
the serial CSY and opens port which is supplied as the address..
@param aTransportCreateInfo Pointer to an instance of
TTransportCreateInfo, which contains the data required
to allocate the transport. The address field is the local
port, e.g. "COMM::0".
@return New, initialized COMM connection.
*/
{
_LIT(KSerialCommCsyName, "ECUART");
const TTransportInterfaceCreateInfo& tci =
*reinterpret_cast<TTransportInterfaceCreateInfo*>(aTransportCreateInfo);
return New2L(tci.iObserver, KSerialCommCsyName, *tci.iAddress, tci.iInitListen);
}
CSerialTransport* CSerialTransport::New2L(
MTransportObserver& aObserver, const TDesC& aCsyName, const TDesC& aPortName, TBool aInitListen)
/**
@param aObserver Observer to notify about transport events.
This is managed by the CTransport superclass.
@param aCsyName Comm (CSY) module which hosts the port.
@param aPortName Local serial port address, e.g. "COMM::0"
corresponding to COM1 on the PC.
@param aInitListen If true, this object should start by listening for
an incoming payload. Otherwise, it should wait for
its owner to send a payload to the remote device.
@return Transport that sends messages to a remote
email account. This is owned by the caller.
*/
{
TRAN_LOG3(">CSerialTransport::New2L,csy=\"%S\",pt=\"%S\",il=%d", &aCsyName, &aPortName, aInitListen);
CSerialTransport* self = new(ELeave) CSerialTransport(aObserver);
CleanupStack::PushL(self);
self->ConstructL(aCsyName, aPortName, aInitListen);
CleanupStack::Pop(self);
TRAN_LOG1("<CSerialTransport::New2L,self=0x%08x", self);
return self;
}
CSerialTransport::CSerialTransport(MTransportObserver& aObserver)
/**
This c'tor is defined to pass the supplied observer to the superclass.
@param aObserver Observer to notify about transport events.
This is managed by the CTransport superclass.
*/
: CRs232Transport(aObserver)
{
// empty.
}
void CSerialTransport::ConstructL(const TDesC& aCsyName, const TDesC& aPortName, TBool aInitListen)
/**
Performs additional initialization to establish an RS232 connection over a
serial cable or an emulated connection over infrared. This function loads
loads the logical and physical device drivers before calling CRs232Transport::ConstructL
which loads the comm module and opens the port.
@param aCsyName Comm module which hosts the port.
@param aPortName Which port to open, e.g. "COMM::0" corresponds
to PC port COM1.
@param aInitListen If true, this object should start by listening
for an incoming payload. Otherwise, it should
wait for its owner to send a payload to the remote
device.
*/
{
SerialUtils::LoadDeviceDriversL(iLoadedLdd, iLoadedPdd);
CRs232Transport::ConstructL(aCsyName, aPortName, aInitListen);
}
CSerialTransport::~CSerialTransport()
/**
Frees resources which are specific to the serial cable
implementation before unloading the LDD and PDD.
*/
{
TRAN_LOG0(">CSerialTransport::~CSerialTransport");
// call this before unloading device drivers.
CRs232Transport::FreeResources();
SerialUtils::FreeDeviceDrivers(iLoadedLdd, iLoadedPdd);
TRAN_LOG0("<CSerialTransport::~CSerialTransport");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -