Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes

PSerialChannel Class Reference

#include <serchan.h>

Inheritance diagram for PSerialChannel:
Inheritance graph
Collaboration diagram for PSerialChannel:
Collaboration graph

List of all members.

Public Types

enum  PXBlockType { PXReadBlock, PXWriteBlock, PXAcceptBlock, PXConnectBlock }

Public Member Functions

BOOL Close ()
Configuration functions
BOOL SetSpeed (DWORD speed)
DWORD GetSpeed () const
BOOL SetDataBits (BYTE data)
BYTE GetDataBits () const
BOOL SetParity (Parity parity)
Parity GetParity () const
BOOL SetStopBits (BYTE stop)
BYTE GetStopBits () const
BOOL SetInputFlowControl (FlowControl flowControl)
FlowControl GetInputFlowControl () const
BOOL SetOutputFlowControl (FlowControl flowControl)
FlowControl GetOutputFlowControl () const
virtual void SaveSettings (PConfig &cfg)
Status functions
void SetDTR (BOOL state=TRUE)
void ClearDTR ()
void SetRTS (BOOL state=TRUE)
void ClearRTS ()
void SetBreak (BOOL state=TRUE)
void ClearBreak ()
BOOL GetRing ()
Overrides from class PObject
virtual Comparison Compare (const PObject &obj) const
virtual PINDEX HashFunction () const
Information functions
virtual BOOL IsOpen () const
virtual PString GetName () const
int GetHandle () const
virtual PChannelGetBaseReadChannel () const
virtual PChannelGetBaseWriteChannel () const
Reading functions
void SetReadTimeout (const PTimeInterval &time)
PTimeInterval GetReadTimeout () const
virtual BOOL Read (void *buf, PINDEX len)
virtual PINDEX GetLastReadCount () const
virtual int ReadChar ()
BOOL ReadBlock (void *buf, PINDEX len)
PString ReadString (PINDEX len)
virtual BOOL ReadAsync (void *buf, PINDEX len)
virtual void OnReadComplete (void *buf, PINDEX len)
Writing functions
void SetWriteTimeout (const PTimeInterval &time)
PTimeInterval GetWriteTimeout () const
virtual BOOL Write (const void *buf, PINDEX len)
virtual PINDEX GetLastWriteCount () const
BOOL WriteChar (int c)
BOOL WriteString (const PString &str)
virtual BOOL WriteAsync (const void *buf, PINDEX len)
virtual void OnWriteComplete (const void *buf, PINDEX len)
Miscellaneous functions
virtual PObjectClone () const

Static Public Member Functions

static BOOL ConvertOSError (int libcReturnValue, Errors &lastError, int &osError)

Protected Member Functions

virtual BOOL ConvertOSError (int libcReturnValue, ErrorGroup group=LastGeneralError)
int PXClose ()
BOOL PXSetIOBlock (PXBlockType type, const PTimeInterval &timeout)
int ReadCharWithTimeout (PTimeInterval &timeout)
BOOL ReceiveCommandString (int nextChar, const PString &reply, PINDEX &pos, PINDEX start)
BOOL SetErrorValues (Errors errorCode, int osError, ErrorGroup group=LastGeneralError)

Protected Attributes

PString channelName
Errors lastErrorCode [NumErrorGroups+1]
 The platform independant error code.
int lastErrorNumber [NumErrorGroups+1]
 The operating system error number (eg as returned by errno).
PINDEX lastReadCount
 Number of byte last read by the Read() function.
PINDEX lastWriteCount
 Number of byte last written by the Write() function.
int os_handle
 The operating system file handle return by standard open() function.
PXBlockType px_lastBlockType
PMutex px_selectMutex
PMutex px_threadMutex
PMutex px_writeMutex
PTimeInterval readTimeout
 Timeout for read operations.
PTimeInterval writeTimeout
 Timeout for write operations.

Private Member Functions

void Construct ()
 PCLASSINFO (PSerialChannel, PChannel)

Private Attributes

DWORD baudRate
BYTE dataBits
struct termios oldTermio
Parity parityBits
BYTE stopBits
struct termios Termio


enum  Parity {
  DefaultParity, NoParity, EvenParity, OddParity,
  MarkParity, SpaceParity

Configuration of serial port parity options.

enum  FlowControl { DefaultFlowControl, NoFlowControl, XonXoff, RtsCts }

Configuration of serial port flow control options.

 PSerialChannel ()
 Create a new serial channel object, but do not open it.
 PSerialChannel (const PString &port, DWORD speed=0, BYTE data=0, Parity parity=DefaultParity, BYTE stop=0, FlowControl inputFlow=DefaultFlowControl, FlowControl outputFlow=DefaultFlowControl)
 PSerialChannel (PConfig &cfg)
 ~PSerialChannel ()
 Close the serial channel on destruction.

Miscellaneous functions

enum  ShutdownValue { ShutdownRead = 0, ShutdownWrite = 1, ShutdownReadAndWrite = 2 }
virtual BOOL Shutdown (ShutdownValue option)
BOOL SetBufferSize (PINDEX newSize)
BOOL SendCommandString (const PString &command)
void AbortCommandString ()

Error functions

enum  Errors {
  NoError, NotFound, FileExists, DiskFull,
  AccessDenied, DeviceInUse, BadParameter, NoMemory,
  NotOpen, Timeout, Interrupted, BufferTooSmall,
  Miscellaneous, ProtocolFailure, NumNormalisedErrors
enum  ErrorGroup { LastReadError, LastWriteError, LastGeneralError, NumErrorGroups }
Errors GetErrorCode (ErrorGroup group=NumErrorGroups) const
int GetErrorNumber (ErrorGroup group=NumErrorGroups) const
virtual PString GetErrorText (ErrorGroup group=NumErrorGroups) const
static PString GetErrorText (Errors lastError, int osError=0)

Scattered read/write functions

typedef std::vector< SliceVectorOfSlice
virtual BOOL Read (const VectorOfSlice &slices)
virtual BOOL Write (const VectorOfSlice &slices)

Comparison functions

enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
bool operator== (const PObject &obj) const
bool operator!= (const PObject &obj) const
bool operator< (const PObject &obj) const
bool operator> (const PObject &obj) const
bool operator<= (const PObject &obj) const
bool operator>= (const PObject &obj) const

Open functions

virtual BOOL Open (const PString &port, DWORD speed=0, BYTE data=0, Parity parity=DefaultParity, BYTE stop=0, FlowControl inputFlow=DefaultFlowControl, FlowControl outputFlow=DefaultFlowControl)
virtual BOOL Open (PConfig &cfg)
static PStringList GetPortNames ()

Run Time Type functions

virtual const char * GetClass (unsigned=0) const
BOOL IsClass (const char *cls) const
virtual BOOL InternalIsDescendant (const char *clsName) const
static const char * Class ()

I/O functions

virtual void PrintOn (ostream &strm) const
virtual void ReadFrom (istream &strm)
ostream & operator<< (ostream &strm, const PObject &obj)
istream & operator>> (istream &strm, PObject &obj)

Detailed Description

This class defines an I/O channel that communicates via a serial port. This is usually an RS-232 port.

Definition at line 106 of file serchan.h.

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index