Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: cs_port.h
Link against: c32.lib

Class CSerial

CSerial

Support

Supported from 5.0

Description

CSerial is the base class for implementations of serial port factories. A serial port factory is responsible for creating instances of CPort-derived classes for the protocol. It also provides query functions, which return general information about the capabilities of the serial protocol.

Writing derived classes:

The pure virtual NewPortL() and Info() functions must be implemented in derived classes. Serial protocol modules which can take differing action based on the version of the comms server should also override QueryVersionSupported().

Derivation

CBaseBase class for all classes to be instantiated on the heap
CObjectImplements reference counting to track concurrent references to itself
CSerialCSerial is the base class for implementations of serial port factories

Defined in CSerial:
CSerial(), Info(), NewPortL(), QueryVersionSupported(), iVersion, ~CSerial()

Inherited from CBase:
operator new()

Inherited from CObject:
AccessCount(), Close(), Dec(), FullName(), Inc(), Name(), Open(), Owner(), SetName(), SetNameL(), SetOwner(), UniqueID()


Construction and destruction

Description

The following functions are called by the comms server. They do not need to be overridden by the concrete CSerial-derived class.


CSerial()

CSerial();

Description

Default constructor. Derived classes can implement a NewL() function if they require two-phase construction.


~CSerial()

~CSerial();

Description

Destructor.

[Top]


Configuration


Info()

virtual void Info(TSerialInfo &aSerialInfo)=0;

Description

Specifies the protocol for getting the information about the serial protocol.

Implementations should fill in the TSerialInfo structure to reflect the protocol's capabilities.

Parameters

TSerialInfo& aSerialInfo

On return, set to indicate the capabilities of the serial protocol.


NewPortL()

virtual CPort* NewPortL(const TUint aUnit)=0;

Description

Specifies the protocol for creating a new serial port for the protocol. The comms server calls this function in response to a RComm:Open() call.

Typically, the implementation would call NewL() on the protocol's CPort-based class. Any resources required by the new port object should be done at this stage. If the serial port object cannot be created for any reason, NewPortL() should leave with an appropriate error code.

The interpretation of unit numbers is specific to the particular serial protocol module. However, unit numbers on EPOC should be zero-based. For the default built-in serial ports implemented by the serial protocol module ecuart.csy, the unit numbers refer to the hardware ports, with 0 being the first port on the machine. If a second request is made to create a port with a unit number that has already been created and not destroyed, NewPortL() should leave with KErrAlreadyExists.

Parameters

const TUint aUnit

The unit number to be created.


QueryVersionSupported()

virtual TBool QueryVersionSupported(TVersion const &aVersion) const;

Description

Specifies the protocol for checking the supplied TVersion against the protocol's module version. The default implementation calls User::QueryVersionSupported() to perform the check against the object's iVersion member.

Parameters

TVersion const &aVersion

The version to compare against

Return value

TBool

ETrue if the version is supported.

[Top]


Data members


iVersion

protected: TVersion iVersion;

Description

Module version number. The class should initialise this member with its version number from its constructor.