Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: cs_port.h
Link against: c32.lib

Class CPort

CPort

Support

Supported from 5.0

Description

Base class for implementations of serial protocol module ports. Its functions are called by the comms server in response to client calls to RComm.

The class implements CObject to obtain reference counting behaviour. The reference count is incremented when a port is first created, and, for ports in shared mode, on every later opening.

Writing derived classes:

CPort is an abstract class which defines many pure virtual functions which derived classes must implements. Most of these pure virtual functions correspond to the client interface of the RComm class.

Derivation

CBaseBase class for all classes to be instantiated on the heap
CObjectImplements reference counting to track concurrent references to itself
CPortBase class for implementations of serial protocol module ports

Defined in CPort:
Break(), BreakCancel(), BreakCompleted(), BreakNotifyCompleted(), CPort(), Close(), ConfigChangeCompleted(), Destruct(), FlowControlChangeCompleted(), FreeMemory(), GetCaps(), GetConfig(), GetFlowControlStatus(), GetReceiveBufferLength(), GetRole(), GetServerConfig(), GetSignals(), IPCRead(), IPCWrite(), NotifyBreak(), NotifyBreakCancel(), NotifyConfigChange(), NotifyConfigChangeCancel(), NotifyDataAvailable(), NotifyDataAvailableCancel(), NotifyDataAvailableCompleted(), NotifyFlowControlChange(), NotifyFlowControlChangeCancel(), NotifyOutputEmpty(), NotifyOutputEmptyCancel(), NotifyOutputEmptyCompleted(), NotifySignalChange(), NotifySignalChangeCancel(), QueryReceiveBuffer(), ReadCancel(), ReadCompleted(), ResetBuffers(), SetConfig(), SetReceiveBufferLength(), SetRole(), SetServerConfig(), SetSignalsToMark(), SetSignalsToSpace(), SignalChangeCompleted(), StartRead(), StartWrite(), WriteCancel(), WriteCompleted(), ~CPort()

Inherited from CBase:
operator new()

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


Construction and destruction


CPort()

CPort();

Description

Default constructor. Derived classes should implement a NewL() function to perform their two-phase construction.

See also:


~CPort()

~CPort();

Description

Destructor. This function is used to destroy a CPort. Derived classes can implement a destructor, but must only call synchronous functions within it. Any cleanup requiring asynchronous operations must be done in Destruct().


Destruct()

virtual void Destruct()=0;

Description

Specifies the protocol for port destruction. It is called by the comms server when the last client-side reference to a CPort object has been closed and the CPort must be deleted. The comms server will not delete a CPort other than by calling Destruct().

The implementation should perform any asynchronous shutdown operations on its own resources and, when these operations have completed, should delete this.

[Top]


Close port


Close()

void Close();

Description

Closes port. The base class implements CObject::Close() to handle reference counting on the port. It decrements the reference count, and calls Destruct() if the count is 0.

[Top]


Access client address space


IPCRead()

TInt IPCRead(const TAny *aPtr,TDes8 &aDes,TInt anOffset=0)const;

Description

Reads data from the client's (the user of the port's) address space. The client address space pointer is obtained from the aClientBuffer argument to StartRead().

See RThread::ReadL() for more information on reading data in other address spaces.

Parameters

const TAny *aPtr

Client address space pointer

TDes8 &aDes

A descriptor (8 bit variant) into which the result of the client address space read will be stored

TInt anOffset=0

The offset from aPtr at which to start reading

Return value

TInt

KErrNone: success; KErrNotReady: there is no read or write request outstanding


IPCWrite()

TInt IPCWrite(const TAny* aPtr,const TDesC8& aDes,TInt anOffset=0)const;

Description

Writes into the client's (the user of the port's) address space.

The client address space pointer is obtained from the aClientBuffer argument to StartWrite().

See RThread::WriteL() for more information on writing data to other address spaces.

Parameters

const TAny* aPtr

Client address space pointer

const TDesC8& aDes

A descriptor (8 bit variant) into which the result of the client address space read will be stored

TInt anOffset=0

The offset from aPtr at which to start writing

Return value

TInt

KErrNone: success; KErrNotReady: there is no read or write request outstanding

[Top]


Read requests


ReadCancel()

virtual void ReadCancel()=0;

Description

Specifies the protocol for cancelling reading from the port. It is called by the comms server in response to a RComm::ReadCancel() request from the client.

The implementation should abort any processing which was taking place as a result of the read request. Do not call ReadCompleted().


ReadCompleted()

void ReadCompleted(TInt anError);    

Description

Tells the comms server that a read request initiated throughStartRead() is complete. The comms server will then notify the client that its read request is complete.

Parameters

TInt anError

Return code to be passed back to the client through itsTRequestStatus argument.


StartRead()

virtual void StartRead(const TAny* aClientBuffer,TInt aLength)=0;

Description

Specifies the protocol for reading from the port. It is called by the comms server in response to a RComm::Read()orRComm::ReadOneOrMore() request from the client.

A negative value for aLength is used to flag that the read request was from RComm::ReadOneOrMore() rather than fromRComm::Read(). The maximum length of data to be read is the absolute value of aLength.

The implementation should use IPCWrite() to write the data to the client's buffer. When all the data has been read, the function should call ReadCompleted().

Parameters

const TAny* aClientBuffer

Pointer into client address space to the descriptor containing the client’s buffer

TInt aLength

The amount of data to be read

[Top]


Write requests


WriteCancel()

virtual void WriteCancel()=0;

Description

Specifies the protocol for cancelling writing to the port. It is called by the comms server in response to a RComm::WriteCancel() request from the client.

The implementation should abort any processing which was taking place as a result of the write request. Do not callWriteCompleted().


WriteCompleted()

void WriteCompleted(TInt anError);    

Description

Tells the comms server that a write request initiated throughStartWrite() is complete. The comms server will then notify the client that its write request is complete.

Parameters

TInt anError

Return code to be passed back to the client through itsTRequestStatus argument.


StartWrite()

virtual void StartWrite(const TAny* aClientBuffer,TInt aLength)=0;

Description

Specifies the protocol for writing to the port. It is called by the comms server in response to a RComm::Write() request from the client.

The implementation should use IPCRead() to get the data to write from the client's buffer. When all the data has been written, the function should call WriteCompleted().

Parameters

const TAny* aClientBuffer

Pointer into client address space to the descriptor containing the client’s buffer

TInt aLength

The amount of data to be written

[Top]


Break requests


Break()

virtual void Break(TInt aTime)=0;

Description

Specifies the protocol for setting a break condition at the port. It is called by the comms server in response to a RComm::Break() request from the client.

When the break is complete, the function should callBreakCompleted().

Parameters

TInt aTime

Time period to break for in microseconds


BreakCancel()

virtual void BreakCancel()=0;

Description

Specifies the protocol for cancelling a break request. It is called by the comms server in response to a RComm::BreakCancel() request from the client.

The implementation should abort any processing which was taking place as a result of the break request. Do not callBreakCompleted().


BreakCompleted()

void BreakCompleted(TInt anError);    

Description

Tells the comms server that a break request initiated throughBreak() is complete. The comms server will then notify the client that its break request is complete.

Parameters

TInt anError

Return code to be passed back to the client through itsTRequestStatus argument.

[Top]


Notification requests


NotifySignalChange()

virtual void NotifySignalChange(TUint aSignalMask)=0;

Description

Specifies the protocol for setting a signal change notification. It is called by the comms server in response to aRComm::NotifySignalChange() request from the client.

Parameters

TUint aSignalMask

Signal mask passed by client


NotifySignalChangeCancel()

virtual void NotifySignalChangeCancel()=0;

Description

Specifies the protocol for cancelling a signal change notification. It is called by the comms server in response to aRComm::NotifySignalChangeCancel() request from the client.


NotifyConfigChange()

virtual void NotifyConfigChange()=0;

Description

Specifies the protocol for setting a configuration change notification. It is called by the comms server in response to aRComm::NotifyConfigChange() request from the client.


NotifyConfigChangeCancel()

virtual void NotifyConfigChangeCancel()=0;

Description

Specifies the protocol for cancelling a configuration change notification. It is called by the comms server in response to aRComm::NotifyConfigChangeCancel() request from the client.


NotifyFlowControlChange()

virtual void NotifyFlowControlChange()=0;

Description

Specifies the protocol for setting a flow control change notification. It is called by the comms server in response to aRComm::NotifyFlowControlChange() request from the client.


NotifyFlowControlChangeCancel()

virtual void NotifyFlowControlChangeCancel()=0;

Description

Specifies the protocol for cancelling a flow control change notification. It is called by the comms server in response to aRComm::NotifyFlowControlChangeCancel() request from the client.


NotifyBreak()

virtual void NotifyBreak()=0;

Description

Specifies the protocol for setting a break notification. It is called by the comms server in response to a RComm::NotifyBreak() request from the client.


NotifyBreakCancel()

virtual void NotifyBreakCancel()=0;

Description

Specifies the protocol for cancelling a break notification. It is called by the comms server in response to aRComm::NotifyBreakCancel()request from the client.


NotifyDataAvailable()

virtual void NotifyDataAvailable()=0;

Description

Specifies the protocol for setting a data available notification. It is called by the comms server in response to aRComm::NotifyDataAvailable() request from the client.


NotifyDataAvailableCancel()

virtual void NotifyDataAvailableCancel()=0;

Description

Specifies the protocol for cancelling a data available notification. It is called by the comms server in response to aRComm::NotifyDataAvailableCancel() request from the client.


NotifyOutputEmpty()

virtual void NotifyOutputEmpty()=0;

Description

Specifies the protocol for setting a transmit buffer empty notification. It is called by the comms server in response to aRComm::NotifyOutputEmpty() request from the client.


NotifyOutputEmptyCancel()

virtual void NotifyOutputEmptyCancel()=0;

Description

Specifies the protocol for cancelling a transmit buffer empty notification. It is called by the comms server in response to aRComm::NotifyOutputEmptyCancel() request from the client.

[Top]


Notification requests complete


SignalChangeCompleted()

void SignalChangeCompleted(const TUint& aSignals, TInt anError);

Support

Supported from 6.0

Description

Tells the comms server that a request initiated throughNotifySignalChange() is complete. The comms server will then notify the client that its request is complete.

Parameters

const TUint& aSignals

Signals value to pass to client

TInt anError

Error code


ConfigChangeCompleted()

void ConfigChangeCompleted(const TDesC8& aNewConfig, TInt anError);    

Support

Supported from 6.0

Description

Tells the comms server that a request initiated throughNotifyConfigChange() is complete. The comms server will then notify the client that its request is complete.

Parameters

const TDesC8& aNewConfig

Configuration value to pass to client

TInt anError

Error code


FlowControlChangeCompleted()

void FlowControlChangeCompleted(const TFlowControl& aFlowControl, TInt anError);

Support

Supported from 6.0

Description

Tells the comms server that a request initiated throughNotifyFlowControlChange() is complete. The comms server will then notify the client that its request is complete.

Parameters

const TFlowControl& aFlowControl

Flow control to pass to client

TInt anError

Error code


BreakNotifyCompleted()

void BreakNotifyCompleted(TInt anError);    

Support

Supported from 6.0

Description

Tells the comms server that a request initiated throughBreakNotifyCompleted() is complete. The comms server will then notify the client that its request is complete.

Parameters

TInt anError

Error code


NotifyDataAvailableCompleted()

void NotifyDataAvailableCompleted(TInt anError);    

Support

Supported from 6.0

Description

Tells the comms server that a request initiated throughNotifyDataAvailable() is complete. The comms server will then notify the client that its request is complete.

Parameters

TInt anError

Error code


NotifyOutputEmptyCompleted()

void NotifyOutputEmptyCompleted(TInt anError);

Support

Supported from 6.0

Description

Tells the comms server that a request initiated throughNotifyOutputEmpty() is complete. The comms server will then notify the client that its request is complete.

Parameters

TInt anError

Error code

[Top]


Buffer management


FreeMemory()

virtual void FreeMemory();

Description

Specifies a protocol by which the comms server can request the protocol to release memory. Typically, an implementation may be able to do this by reducing internal buffers.

The default behaviour is to do nothing.


GetReceiveBufferLength()

virtual TInt GetReceiveBufferLength(TInt& aLength) const=0;

Description

Specifies a protocol for requesting the size of the serial port buffers. It is called by the comms server in response to aRComm::ReceiveBufferLength() request from the client.

Parameters

TInt& aLength

The current size of the serial port buffers in bytes

Return value

TInt

A system error code


QueryReceiveBuffer()

virtual TInt QueryReceiveBuffer(TInt& aLength) const=0;

Description

Specifies a protocol for requesting the number of bytes that are currently waiting in the port’s receive buffer. It is called by the comms server in response to a RComm::QueryReceiveBuffer() request from the client.

Parameters

TInt& aLength

On return, the number of bytes currently waiting to be read from the receive buffer.

Return value

TInt

A system error code


ResetBuffers()

virtual void ResetBuffers(TUint aFlags)=0;

Description

Specifies a protocol for resetting the receive and/or transmit buffers to zero length. It is called by the comms server in response to aRComm::ResetBuffers() request from the client.

Parameters

TUint aFlags

Bitmask of the following flags: KCommResetRx to reset the receive buffer KCommResetTx to reset the transmit buffer


SetReceiveBufferLength()

virtual TInt SetReceiveBufferLength(TInt aLength)=0;

Description

Specifies a protocol for setting the size of the serial port buffers. It is called by the comms server in response to aRComm::SetReceiveBufferLength() request from the client.

Parameters

TInt aLength

Requested size of the serial port buffers in bytes

Return value

TInt

A system error code

[Top]


Configuration


GetConfig()

virtual TInt GetConfig(TDes8& aPackage) const=0;

Description

Specifies a protocol for getting the current configuration of the serial port. It is called by the comms server in response to aRComm::GetConfig() request from the client.

Parameters

TDes8& aPackage

A packaged TCommConfig buffer, set on return to the current configuration of the serial port

Return value

TInt

A system error code


GetServerConfig()

virtual TInt GetServerConfig(TDes8& aPackage)=0;

Description

Specifies a protocol for getting the buffer mode. It is called by the comms server in response to a RComm::Mode() request from the client.

Parameters

TDes8& aPackage

A TCommServerConfig package buffer that, on return, holds the current buffer mode settings

Return value

TInt

A system error code


SetConfig()

virtual TInt SetConfig(const TDesC8& aPackage)=0;

Description

Specifies a protocol for setting the configuration of the port. It is called by the comms server in response to aRComm::SetConfig()request from the client.

Parameters

const TDesC8& aPackage

A packaged TCommConfig buffer holding the new configuration values

Return value

TInt

A system error code


SetServerConfig()

virtual TInt SetServerConfig(const TDesC8& aPackage)=0;

Description

Specifies a protocol for setting the buffer mode. It is called by the comms server in response to a RComm::SetMode() request from the client.

Parameters

const TDesC8& aPackage

A TCommServerConfig package buffer holding the mode settings

Return value

TInt

A system-wide error code


GetFlowControlStatus()

virtual TInt GetFlowControlStatus(TFlowControl& aFlowControl)=0;

Description

Gets flow control status. It is called by the comms server in response to a RComm::SetMode() request from the client.

Parameters

TFlowControl& aFlowControl

Flow control status to return to the client

Return value

TInt

A system-wide error code


GetRole()

virtual TInt GetRole(TCommRole& aRole)=0;

Description

Gets DCE/DTE role. It is called by the comms server in response to aRComm::GetRole() request from the client.

Parameters

TCommRole& aRole

On return, DCE/DTE role to return to the client

Return value

TInt

A system-wide error code


SetRole()

virtual TInt SetRole(TCommRole aRole)=0;

Description

Sets DCE/DTE role. It is called by the comms server in response to aRComm::Open() request from the client.

Parameters

TCommRole aRole

DCE/DTE role

Return value

TInt

A system-wide error code

[Top]


Capabilities


GetCaps()

virtual TInt GetCaps(TDes8& aPackage)=0;

Description

Specifies a protocol for getting the port capabilities. It is called by the comms server in response to a RComm::Caps() request from the client.

Parameters

TDes8& aPackage

A TCommCaps package buffer that, on return, holds the port capabilities

Return value

TInt

A system error code

[Top]


Signals


GetSignals()

virtual TInt GetSignals(TUint& aSignals)=0;    

Description

Specifies a protocol for getting the status of the serial port control lines. It is called by the comms server in response to aRComm::GetSignals() request from the client.

Parameters

TUint& aSignals

An integer with the bits set to reflect the status of the handshaking lines.

Return value

TInt

A system error code

See also:


SetSignalsToMark()

virtual TInt SetSignalsToMark(TUint aSignals)=0;

Description

Specifies a protocol for setting serial port control lines. It is called by the comms server in response to a RComm::SetSignals() request from the client.

Parameters

TUint aSignals

A bitmask of the handshaking lines to set

Return value

TInt

A system error code

See also:


SetSignalsToSpace()

virtual TInt SetSignalsToSpace(TUint aSignals)=0;

Description

Specifies a protocol for clearing serial port control lines. It is called by the comms server in response to a RComm::SetSignals() request from the client.

Parameters

TUint aSignals

A bitmask of the handshaking lines to clear

Return value

TInt

A system error code

See also: