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

PModem Class Reference

#include <modem.h>

Inheritance diagram for PModem:

PSerialChannel PChannel PObject

List of all members.


Detailed Description

A class representing a modem attached to a serial port. This adds the usual modem operations to the basic serial port.

A modem object is always in a particular state. This state determines what operations are allowed which then move the object to other states. The operations are the exchange of strings in "chat" script.

The following defaults are used for command strings: initialise ATZ deinitialise +++ pre-dial ATDT post-dial busy reply BUSY no carrier reply NO CARRIER connect reply CONNECT hang up +++

Definition at line 110 of file modem.h.


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

Error functions

enum  ErrorGroup { LastReadError, LastWriteError, LastGeneralError, NumErrorGroups }
enum  Errors {
  NoError, NotFound, FileExists, DiskFull,
  AccessDenied, DeviceInUse, BadParameter, NoMemory,
  NotOpen, Timeout, Interrupted, BufferTooSmall,
  Miscellaneous, ProtocolFailure, NumNormalisedErrors
}
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)

Miscellaneous functions

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

Scattered read/write functions

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

Run Time Type functions

virtual const char * GetClass (unsigned=0) const
virtual BOOL InternalIsDescendant (const char *clsName) const
BOOL IsClass (const char *cls) 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)

Public Types

enum  PXBlockType { PXReadBlock, PXWriteBlock, PXAcceptBlock, PXConnectBlock }
enum  Status {
  Unopened, Uninitialised, Initialising, Initialised,
  InitialiseFailed, Dialling, DialFailed, AwaitingResponse,
  LineBusy, NoCarrier, Connected, HangingUp,
  HangUpFailed, Deinitialising, DeinitialiseFailed, SendingUserCommand,
  NumStatuses
}
Construction
enum  FlowControl { DefaultFlowControl, NoFlowControl, XonXoff, RtsCts }
 Configuration of serial port flow control options. More...
enum  Parity {
  DefaultParity, NoParity, EvenParity, OddParity,
  MarkParity, SpaceParity
}
 Configuration of serial port parity options. More...

Public Member Functions

void Abort ()
BOOL CanDeinitialise () const
BOOL CanDial () const
BOOL CanHangUp () const
BOOL CanInitialise () const
BOOL CanRead () const
BOOL CanSendUser () const
virtual BOOL Close ()
BOOL Deinitialise ()
BOOL Dial (const PString &number)
PString GetBusyString () const
PString GetConnectString () const
PString GetDeinitString () const
PString GetHangUpString () const
PString GetInitString () const
PString GetNoCarrierString () const
PString GetPostDialString () const
PString GetPreDialString () const
Status GetStatus () const
BOOL HangUp ()
BOOL Initialise ()
virtual BOOL Open (PConfig &cfg)
virtual BOOL Open (const PString &port, DWORD speed=0, BYTE data=0, Parity parity=DefaultParity, BYTE stop=0, FlowControl inputFlow=DefaultFlowControl, FlowControl outputFlow=DefaultFlowControl)
 PModem (PConfig &cfg)
 PModem (const PString &port, DWORD speed=0, BYTE data=0, Parity parity=DefaultParity, BYTE stop=0, FlowControl inputFlow=DefaultFlowControl, FlowControl outputFlow=DefaultFlowControl)
 PModem ()
virtual void SaveSettings (PConfig &cfg)
BOOL SendUser (const PString &str)
void SetBusyString (const PString &str)
void SetConnectString (const PString &str)
void SetDeinitString (const PString &str)
void SetHangUpString (const PString &str)
void SetInitString (const PString &str)
void SetNoCarrierString (const PString &str)
void SetPostDialString (const PString &str)
void SetPreDialString (const PString &str)
Status functions
void ClearBreak ()
void ClearDTR ()
void ClearRTS ()
BOOL GetCTS ()
BOOL GetDCD ()
BOOL GetDSR ()
BOOL GetRing ()
void SetBreak (BOOL state=TRUE)
void SetDTR (BOOL state=TRUE)
void SetRTS (BOOL state=TRUE)
Miscellaneous functions
virtual PObjectClone () const
Overrides from class PObject
virtual Comparison Compare (const PObject &obj) const
virtual PINDEX HashFunction () const
Information functions
virtual PChannelGetBaseReadChannel () const
virtual PChannelGetBaseWriteChannel () const
int GetHandle () const
virtual PString GetName () const
virtual BOOL IsOpen () const
Configuration functions
BYTE GetDataBits () const
FlowControl GetInputFlowControl () const
FlowControl GetOutputFlowControl () const
Parity GetParity () const
DWORD GetSpeed () const
BYTE GetStopBits () const
BOOL SetDataBits (BYTE data)
BOOL SetInputFlowControl (FlowControl flowControl)
BOOL SetOutputFlowControl (FlowControl flowControl)
BOOL SetParity (Parity parity)
BOOL SetSpeed (DWORD speed)
BOOL SetStopBits (BYTE stop)
Reading functions
virtual PINDEX GetLastReadCount () const
PTimeInterval GetReadTimeout () const
virtual void OnReadComplete (void *buf, PINDEX len)
virtual BOOL Read (void *buf, PINDEX len)
virtual BOOL ReadAsync (void *buf, PINDEX len)
BOOL ReadBlock (void *buf, PINDEX len)
virtual int ReadChar ()
PString ReadString (PINDEX len)
void SetReadTimeout (const PTimeInterval &time)
Writing functions
virtual PINDEX GetLastWriteCount () const
PTimeInterval GetWriteTimeout () const
virtual void OnWriteComplete (const void *buf, PINDEX len)
void SetWriteTimeout (const PTimeInterval &time)
virtual BOOL Write (const void *buf, PINDEX len)
virtual BOOL WriteAsync (const void *buf, PINDEX len)
BOOL WriteChar (int c)
BOOL WriteString (const PString &str)

Static Public Member Functions

static BOOL ConvertOSError (int libcReturnValue, Errors &lastError, int &osError)
Open functions
static PStringList GetPortNames ()

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 busyReply
PString channelName
PString connectReply
PString deinitCmd
PString hangUpCmd
PString initCmd
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.
PString noCarrierReply
int os_handle
 The operating system file handle return by standard open() function.
PString postDialCmd
PString preDialCmd
PXBlockType px_lastBlockType
PThreadpx_readThread
PMutex px_selectMutex
PThreadpx_selectThread
PMutex px_threadMutex
PMutex px_writeMutex
PThreadpx_writeThread
PTimeInterval readTimeout
 Timeout for read operations.
Status status
PTimeInterval writeTimeout
 Timeout for write operations.

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

Generated by  Doxygen 1.6.0   Back to index