PSerialChannel Class Reference

#include <serchan.h>

Inheritance diagram for PSerialChannel:

PChannel PObject PModem List of all members.

Construction

enum  Parity {
  DefaultParity, NoParity, EvenParity, OddParity,
  MarkParity, SpaceParity
}
 Configuration of serial port parity options. More...
enum  FlowControl { DefaultFlowControl, NoFlowControl, XonXoff, RtsCts }
 Configuration of serial port flow control options. More...
 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 ()
 Close the serial channel on destruction.

Open functions

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

Public Member Functions

PBoolean Close ()
Configuration functions
PBoolean SetSpeed (DWORD speed)
DWORD GetSpeed () const
PBoolean SetDataBits (BYTE data)
BYTE GetDataBits () const
PBoolean SetParity (Parity parity)
Parity GetParity () const
PBoolean SetStopBits (BYTE stop)
BYTE GetStopBits () const
PBoolean SetInputFlowControl (FlowControl flowControl)
FlowControl GetInputFlowControl () const
PBoolean SetOutputFlowControl (FlowControl flowControl)
FlowControl GetOutputFlowControl () const
Status functions
void SetDTR (PBoolean state=PTrue)
void ClearDTR ()
void SetRTS (PBoolean state=PTrue)
void ClearRTS ()
void SetBreak (PBoolean state=PTrue)
void ClearBreak ()
PBoolean GetCTS ()
PBoolean GetDSR ()
PBoolean GetDCD ()
PBoolean GetRing ()

Detailed Description

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


Member Enumeration Documentation

enum PSerialChannel::Parity

Configuration of serial port parity options.

Enumerator:
DefaultParity  Use the default parity, ie do not change it.
NoParity  Set the port for no parity bit.
EvenParity  Set the port to generate parity and make it even.
OddParity  Set the port to generate parity and make it odd.
MarkParity  Set the port parity bit to mark only.
SpaceParity  Set the port parity bit to space only.

enum PSerialChannel::FlowControl

Configuration of serial port flow control options.

Enumerator:
DefaultFlowControl  Use the default flow control, ie do not change it.
NoFlowControl  Set the port for no flow control.
XonXoff  Set the port for software or XON/XOFF flow control.
RtsCts  Set the port for hardware or RTS/CTS flow control.


Constructor & Destructor Documentation

PSerialChannel::PSerialChannel (  ) 

Create a new serial channel object, but do not open it.

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

Create a serial channal. The channel is opened it on the specified port and with the specified attributes.

Parameters:
port  The name of the serial port to connect to. This is a platform dependent string and woiuld rarely be a literal. The static function GetPortNames()# can be used to find the platforms serial ports.
speed  Serial port speed or baud rate. The actual values possible here are platform dependent, but the standard value of 300, 1200, 2400, 4800, 9600, 19200, 38400 always be legal.
data  Number of data bits for serial port. The actual values possible here are platform dependent, but 7 and 8 should always be legal.
parity  Parity for serial port. The actual values possible here are platform dependent, but NoParity#, OddParity# and EvenParity# should always be legal.
stop  Number of stop bits for serial port. The actual values possible here are platform dependent, but 1 and 2 should always be legal.
inputFlow  Flow control for data from the remote system into this conputer.
outputFlow  Flow control for data from this conputer out to remote system.

PSerialChannel::~PSerialChannel (  ) 

Close the serial channel on destruction.


Member Function Documentation

virtual PBoolean PSerialChannel::Open ( const PString port,
DWORD  speed = 0,
BYTE  data = 0,
Parity  parity = DefaultParity,
BYTE  stop = 0,
FlowControl  inputFlow = DefaultFlowControl,
FlowControl  outputFlow = DefaultFlowControl 
) [virtual]

Open a serial channal. The channel is opened it on the specified port and with the specified attributes.

Parameters:
port  The name of the serial port to connect to. This is a platform dependent string and woiuld rarely be a literal. The static function GetPortNames()# can be used to find the platforms serial ports.
speed  Serial port speed or baud rate. The actual values possible here are platform dependent, but the standard value of 300, 1200, 2400, 4800, 9600, 19200, 38400 always be legal.
data  Number of data bits for serial port. The actual values possible here are platform dependent, but 7 and 8 should always be legal.
parity  Parity for serial port. The actual values possible here are platform dependent, but NoParity#, OddParity# and EvenParity# should always be legal.
stop  Number of stop bits for serial port. The actual values possible here are platform dependent, but 1 and 2 should always be legal.
inputFlow  Flow control for data from the remote system into this conputer.
outputFlow  Flow control for data from this conputer out to remote system.

Reimplemented in PModem.

static PStringList PSerialChannel::GetPortNames (  )  [static]

Get a list of the available serial ports. This returns a set of platform dependent strings which describe the serial ports of the computer. For example under unix it may be "ttyS0", under MS-DOS or NT it would be "COM1" and for the Macintosh it could be "Modem".

Returns:
list of strings for possible serial ports.

PBoolean PSerialChannel::SetSpeed ( DWORD  speed  ) 

Set the speed (baud rate) of the serial channel.

Returns:
PTrue if the change was successfully made.
Parameters:
speed  New speed for serial channel.

DWORD PSerialChannel::GetSpeed (  )  const

Get the speed (baud rate) of the serial channel.

Returns:
current setting.

PBoolean PSerialChannel::SetDataBits ( BYTE  data  ) 

Set the data bits (5, 6, 7 or 8) of the serial port.

Returns:
PTrue if the change was successfully made.
Parameters:
data  New number of data bits for serial channel.

BYTE PSerialChannel::GetDataBits (  )  const

Get the data bits (5, 6, 7 or 8) of the serial port.

Returns:
current setting.

PBoolean PSerialChannel::SetParity ( Parity  parity  ) 

Set the parity of the serial port.

Returns:
PTrue if the change was successfully made.
Parameters:
parity  New parity option for serial channel.

Parity PSerialChannel::GetParity (  )  const

Get the parity of the serial port.

Returns:
current setting.

PBoolean PSerialChannel::SetStopBits ( BYTE  stop  ) 

Set the stop bits (1 or 2) of the serial port.

Returns:
PTrue if the change was successfully made.
Parameters:
stop  New number of stop bits for serial channel.

BYTE PSerialChannel::GetStopBits (  )  const

Get the stop bits (1 or 2) of the serial port.

Returns:
current setting.

PBoolean PSerialChannel::SetInputFlowControl ( FlowControl  flowControl  ) 

Set the flow control (handshaking) protocol of the input to the serial port.

Returns:
PTrue if the change was successfully made.
Parameters:
flowControl  New flow control for serial channel input.

FlowControl PSerialChannel::GetInputFlowControl (  )  const

Get the flow control (handshaking) protocol of the input to the serial port.

Returns:
current setting.

PBoolean PSerialChannel::SetOutputFlowControl ( FlowControl  flowControl  ) 

Set the flow control (handshaking) protocol of the output to the serial port.

Returns:
PTrue if the change was successfully made.
Parameters:
flowControl  New flow control for serial channel output.

FlowControl PSerialChannel::GetOutputFlowControl (  )  const

Get the flow control (handshaking) protocol of the output from the serial port.

Returns:
current setting.

void PSerialChannel::SetDTR ( PBoolean  state = PTrue  ) 

Set the Data Terminal Ready signal of the serial port.

Parameters:
state  New state of the DTR signal.

void PSerialChannel::ClearDTR (  ) 

Clear the Data Terminal Ready signal of the serial port. This is equivalent to SetDTR(PFalse)#.

void PSerialChannel::SetRTS ( PBoolean  state = PTrue  ) 

Set the Request To Send signal of the serial port.

Parameters:
state  New state of the RTS signal.

void PSerialChannel::ClearRTS (  ) 

Clear the Request To Send signal of the serial port. This is equivalent to SetRTS(PFalse)#.

void PSerialChannel::SetBreak ( PBoolean  state = PTrue  ) 

Set the break condition of the serial port.

Parameters:
state  New state of the serial port break condition.

void PSerialChannel::ClearBreak (  ) 

Clear the break condition of the serial port. This is equivalent to SetBreak(PFalse)#.

PBoolean PSerialChannel::GetCTS (  ) 

Get the Clear To Send signal of the serial port.

Returns:
PTrue if the CTS signal is asserted.

PBoolean PSerialChannel::GetDSR (  ) 

Get the Data Set Ready signal of the serial port.

Returns:
PTrue if the DSR signal is asserted.

PBoolean PSerialChannel::GetDCD (  ) 

Get the Data Carrier Detect signal of the serial port.

Returns:
PTrue if the DCD signal is asserted.

PBoolean PSerialChannel::GetRing (  ) 

Get the Ring Indicator signal of the serial port.

Returns:
PTrue if the RI signal is asserted.

PBoolean PSerialChannel::Close (  )  [virtual]

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

Returns:
PTrue if the channel successfully closed.

Reimplemented from PChannel.

Reimplemented in PModem.


The documentation for this class was generated from the following file:
Generated on Mon Feb 23 01:57:58 2009 for PTLib by  doxygen 1.5.1