PWLib
1.10.10
|
#include <serchan.h>
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 | GetCTS () |
BOOL | GetDSR () |
BOOL | GetDCD () |
BOOL | GetRing () |
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 (PConfig &cfg) | |
~PSerialChannel () | |
Close the serial channel on destruction. | |
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 () |
This class defines an I/O channel that communicates via a serial port. This is usually an RS-232 port.
Configuration of serial port parity options.
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.
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 | ( | PConfig & | cfg | ) |
Create a serial channal. The channel is opened using attributes obtained from standard variables in the configuration file. Note that it assumed that the correct configuration file section is already set.
cfg | Configuration file to read serial port attributes from. |
Close the serial channel on destruction.
void PSerialChannel::ClearBreak | ( | ) |
Clear the break condition of the serial port. This is equivalent to #SetBreak(FALSE)#.
void PSerialChannel::ClearDTR | ( | ) |
Clear the Data Terminal Ready signal of the serial port. This is equivalent to #SetDTR(FALSE)#.
void PSerialChannel::ClearRTS | ( | ) |
Clear the Request To Send signal of the serial port. This is equivalent to #SetRTS(FALSE)#.
BOOL PSerialChannel::Close | ( | ) | [virtual] |
BOOL PSerialChannel::GetCTS | ( | ) |
Get the Clear To Send signal of the serial port.
BYTE PSerialChannel::GetDataBits | ( | ) | const |
Get the data bits (5, 6, 7 or 8) of the serial port.
BOOL PSerialChannel::GetDCD | ( | ) |
Get the Data Carrier Detect signal of the serial port.
BOOL PSerialChannel::GetDSR | ( | ) |
Get the Data Set Ready signal of the serial port.
Get the flow control (handshaking) protocol of the input to the serial port.
Get the flow control (handshaking) protocol of the output from the serial port.
Parity PSerialChannel::GetParity | ( | ) | const |
Get the parity of the serial port.
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".
BOOL PSerialChannel::GetRing | ( | ) |
Get the Ring Indicator signal of the serial port.
DWORD PSerialChannel::GetSpeed | ( | ) | const |
Get the speed (baud rate) of the serial channel.
BYTE PSerialChannel::GetStopBits | ( | ) | const |
Get the stop bits (1 or 2) of the serial port.
virtual BOOL 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.
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.
virtual BOOL PSerialChannel::Open | ( | PConfig & | cfg | ) | [virtual] |
Open a serial channal. The channel is opened using attributes obtained from standard variables in the configuration file. Note that it assumed that the correct configuration file section is already set.
cfg | Configuration file to read serial port attributes from. |
Reimplemented in PModem.
virtual void PSerialChannel::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.
cfg | Configuration file to save setting into. |
Reimplemented in PModem.
void PSerialChannel::SetBreak | ( | BOOL | state = TRUE | ) |
Set the break condition of the serial port.
state | New state of the serial port break condition. |
BOOL PSerialChannel::SetDataBits | ( | BYTE | data | ) |
Set the data bits (5, 6, 7 or 8) of the serial port.
data | New number of data bits for serial channel. |
void PSerialChannel::SetDTR | ( | BOOL | state = TRUE | ) |
Set the Data Terminal Ready signal of the serial port.
state | New state of the DTR signal. |
BOOL PSerialChannel::SetInputFlowControl | ( | FlowControl | flowControl | ) |
Set the flow control (handshaking) protocol of the input to the serial port.
flowControl | New flow control for serial channel input. |
BOOL PSerialChannel::SetOutputFlowControl | ( | FlowControl | flowControl | ) |
Set the flow control (handshaking) protocol of the output to the serial port.
flowControl | New flow control for serial channel output. |
BOOL PSerialChannel::SetParity | ( | Parity | parity | ) |
Set the parity of the serial port.
parity | New parity option for serial channel. |
void PSerialChannel::SetRTS | ( | BOOL | state = TRUE | ) |
Set the Request To Send signal of the serial port.
state | New state of the RTS signal. |
BOOL PSerialChannel::SetSpeed | ( | DWORD | speed | ) |
Set the speed (baud rate) of the serial channel.
speed | New speed for serial channel. |
BOOL PSerialChannel::SetStopBits | ( | BYTE | stop | ) |
Set the stop bits (1 or 2) of the serial port.
stop | New number of stop bits for serial channel. |