Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

PModem Class Reference

#include <modem.h>

Inheritance diagram for PModem:

PSerialChannel PChannel PObject List of all members.

Public Types

enum  Status {
  Unopened, Uninitialised, Initialising, Initialised,
  InitialiseFailed, Dialling, DialFailed, AwaitingResponse,
  LineBusy, NoCarrier, Connected, HangingUp,
  HangUpFailed, Deinitialising, DeinitialiseFailed, SendingUserCommand,
  NumStatuses
}

Public Member Functions

 PModem ()
 PModem (const PString &port, DWORD speed=0, BYTE data=0, Parity parity=DefaultParity, BYTE stop=0, FlowControl inputFlow=DefaultFlowControl, FlowControl outputFlow=DefaultFlowControl)
 PModem (PConfig &cfg)
virtual BOOL Close ()
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)
virtual void SaveSettings (PConfig &cfg)
void SetInitString (const PString &str)
PString GetInitString () const
BOOL CanInitialise () const
BOOL Initialise ()
void SetDeinitString (const PString &str)
PString GetDeinitString () const
BOOL CanDeinitialise () const
BOOL Deinitialise ()
void SetPreDialString (const PString &str)
PString GetPreDialString () const
void SetPostDialString (const PString &str)
PString GetPostDialString () const
void SetBusyString (const PString &str)
PString GetBusyString () const
void SetNoCarrierString (const PString &str)
PString GetNoCarrierString () const
void SetConnectString (const PString &str)
PString GetConnectString () const
BOOL CanDial () const
BOOL Dial (const PString &number)
void SetHangUpString (const PString &str)
PString GetHangUpString () const
BOOL CanHangUp () const
BOOL HangUp ()
BOOL CanSendUser () const
BOOL SendUser (const PString &str)
void Abort ()
BOOL CanRead () const
Status GetStatus () const

Protected Attributes

PString initCmd
PString deinitCmd
PString preDialCmd
PString postDialCmd
PString busyReply
PString noCarrierReply
PString connectReply
PString hangUpCmd
Status status

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 +++


Member Enumeration Documentation

enum PModem::Status
 

Enumeration values:
Unopened 
Uninitialised 
Initialising 
Initialised 
InitialiseFailed 
Dialling 
DialFailed 
AwaitingResponse 
LineBusy 
NoCarrier 
Connected 
HangingUp 
HangUpFailed 
Deinitialising 
DeinitialiseFailed 
SendingUserCommand 
NumStatuses 


Constructor & Destructor Documentation

PModem::PModem  ) 
 

Create a modem object on the serial port specified. If no port was specified do not open it. It does not initially have a valid port name.

See the PSerialChannel class for more information on the parameters.

PModem::PModem const PString port,
DWORD  speed = 0,
BYTE  data = 0,
Parity  parity = DefaultParity,
BYTE  stop = 0,
FlowControl  inputFlow = DefaultFlowControl,
FlowControl  outputFlow = DefaultFlowControl
 

PModem::PModem PConfig cfg  ) 
 

Open the modem serial channel obtaining the parameters from standard variables in the configuration file. Note that it assumed that the correct configuration file section is already set.


Member Function Documentation

void PModem::Abort  ) 
 

BOOL PModem::CanDeinitialise  )  const
 

The modem is in a state that allows the de-initialise to start.

Returns:
TRUE if the Deinitialise() function may proceeed.

BOOL PModem::CanDial  )  const
 

The modem is in a state that allows the dial to start.

Returns:
TRUE if the Dial() function may proceeed.

BOOL PModem::CanHangUp  )  const
 

The modem is in a state that allows the hang up to start.

Returns:
TRUE if the HangUp() function may proceeed.

BOOL PModem::CanInitialise  )  const
 

The modem is in a state that allows the initialise to start.

Returns:
TRUE if the Initialise() function may proceeed.

BOOL PModem::CanRead  )  const
 

The modem is in a state that allows the user application to read from the channel. Reading while this is TRUE can interfere with the operation of the meta-string processing. This function is only usefull when multi-threading is used.

Returns:
TRUE if Read() operations are "safe".

BOOL PModem::CanSendUser  )  const
 

The modem is in a state that allows the user command to start.

Returns:
TRUE if the SendUser() function may proceeed.

virtual BOOL PModem::Close  )  [virtual]
 

Close the channel, shutting down the link to the data source.

Returns:
TRUE if the channel successfully closed.

Reimplemented from PSerialChannel.

BOOL PModem::Deinitialise  ) 
 

Send the de-initialisation meta-command string to the modem. The return value indicates that the conditions for the operation to start were met, ie the serial port was open etc and the command was successfully sent with all replies met.

Returns:
TRUE if command string sent successfully and the objects state has changed.

BOOL PModem::Dial const PString number  ) 
 

Send the dial meta-command strings to the modem. The return value indicates that the conditions for the operation to start were met, ie the serial port was open etc and the command was successfully sent with all replies met.

The string sent to the modem is the concatenation of the pre-dial string, a , the number parameter and the post-dial string.

Returns:
TRUE if command string sent successfully and the objects state has changed.

PString PModem::GetBusyString  )  const
 

Get the modem busy response meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Returns:
string for busy response command.

PString PModem::GetConnectString  )  const
 

Get the modem connect response meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Returns:
string for connect response command.

PString PModem::GetDeinitString  )  const
 

Get the modem de-initialisation meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Returns:
string for de-initialisation command.

PString PModem::GetHangUpString  )  const
 

Get the modem hang up meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Returns:
string for hang up command.

PString PModem::GetInitString  )  const
 

Get the modem initialisation meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Returns:
string for initialisation command.

PString PModem::GetNoCarrierString  )  const
 

Get the modem no carrier response meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Returns:
string for no carrier response command.

PString PModem::GetPostDialString  )  const
 

Get the modem post-dial meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Returns:
string for post-dial command.

PString PModem::GetPreDialString  )  const
 

Get the modem pre-dial meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Returns:
string for pre-dial command.

Status PModem::GetStatus  )  const
 

Get the modem objects current state.

Returns:
modem status.

BOOL PModem::HangUp  ) 
 

Send the hang up meta-command string to the modem. The return value indicates that the conditions for the operation to start were met, ie the serial port was open etc and the command was successfully sent with all replies met.

Returns:
TRUE if command string sent successfully and the objects state has changed.

BOOL PModem::Initialise  ) 
 

Send the initialisation meta-command string to the modem. The return value indicates that the conditions for the operation to start were met, ie the serial port was open etc and the command was successfully sent with all replies met.

Returns:
TRUE if command string sent successfully and the objects state has changed.

virtual BOOL PModem::Open PConfig cfg  )  [virtual]
 

Open the modem serial port obtaining the parameters from standard variables in the configuration file. Note that it assumed that the correct configuration file section is already set.

Returns:
TRUE if the modem serial port was successfully opened.

Reimplemented from PSerialChannel.

virtual BOOL PModem::Open const PString port,
DWORD  speed = 0,
BYTE  data = 0,
Parity  parity = DefaultParity,
BYTE  stop = 0,
FlowControl  inputFlow = DefaultFlowControl,
FlowControl  outputFlow = DefaultFlowControl
[virtual]
 

Open the modem serial channel on the specified port.

See the PSerialChannel class for more information on the parameters.

Returns:
TRUE if the modem serial port was successfully opened.

Reimplemented from PSerialChannel.

virtual void PModem::SaveSettings PConfig cfg  )  [virtual]
 

Save the current port settings into the configuration file. Note that it assumed that the correct configuration file section is already set.

Reimplemented from PSerialChannel.

BOOL PModem::SendUser const PString str  ) 
 

Send an arbitrary user meta-command string to the modem. The return value indicates that the conditions for the operation to start were met, ie the serial port was open etc and the command was successfully sent with all replies met.

Returns:
TRUE if command string sent successfully.

void PModem::SetBusyString const PString str  ) 
 

Set the modem busy response meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Note there is an implied before the string. Also the and commands do not operate and will simply terminate the string match.

void PModem::SetConnectString const PString str  ) 
 

Set the modem connect response meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Note there is an implied before the string. Also the and commands do not operate and will simply terminate the string match.

void PModem::SetDeinitString const PString str  ) 
 

Set the modem de-initialisation meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Note there is an implied before the string.

void PModem::SetHangUpString const PString str  ) 
 

Set the modem hang up meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Note there is an implied before the string.

void PModem::SetInitString const PString str  ) 
 

Set the modem initialisation meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Note there is an implied before the string.

void PModem::SetNoCarrierString const PString str  ) 
 

Set the modem no carrier response meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Note there is an implied before the string. Also the and commands do not operate and will simply terminate the string match.

void PModem::SetPostDialString const PString str  ) 
 

Set the modem post-dial meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Note there is not an implied before the string, unlike the pre-dial string.

void PModem::SetPreDialString const PString str  ) 
 

Set the modem pre-dial meta-command string.

See the PChannel::SendCommandString() function for more information on the format of the command string.

Note there is an implied before the string.


Member Data Documentation

PString PModem::busyReply [protected]
 

PString PModem::connectReply [protected]
 

PString PModem::deinitCmd [protected]
 

PString PModem::hangUpCmd [protected]
 

PString PModem::initCmd [protected]
 

PString PModem::noCarrierReply [protected]
 

PString PModem::postDialCmd [protected]
 

PString PModem::preDialCmd [protected]
 

Status PModem::status [protected]
 


The documentation for this class was generated from the following file:
Generated on Mon Feb 21 20:43:14 2005 for PWLib by  doxygen 1.4.1