class PSerialChannel: public PChannel

This class defines an I/O channel that communicates via a serial port.

Inheritance:


Public

[more] Construction
[more] Open functions
[more] Configuration functions
[more] Status functions


Inherited from PChannel:

Public Methods

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

Public

Overrides from class PObject

Information functions

Reading functions

Writing functions

Miscellaneous functions

Error functions

Protected Fields

oint os_handle
oErrors lastErrorCode[NumErrorGroups+1]
oint lastErrorNumber[NumErrorGroups+1]
oPINDEX lastReadCount
oPINDEX lastWriteCount
oPTimeInterval readTimeout
oPTimeInterval writeTimeout

Protected Methods

ovirtual BOOL ConvertOSError( int libcReturnValue, ErrorGroup group = LastGeneralError )
oBOOL SetErrorValues( Errors errorCode, int osError, ErrorGroup group = LastGeneralError )
oint ReadCharWithTimeout( PTimeInterval & timeout )


Inherited from PObject:

Public

Run Time Type functions

Comparison functions

I/O functions


Documentation

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

o PSerialChannel()
Create a new serial channel object, but do not open it.

oenum Parity
Configuration of serial port parity options.

o DefaultParity
Use the default parity, ie do not change it.

o NoParity
Set the port for no parity bit.

o EvenParity
Set the port to generate parity and make it even.

o OddParity
Set the port to generate parity and make it odd.

o MarkParity
Set the port parity bit to mark only.

o SpaceParity
Set the port parity bit to space only.

oenum FlowControl
Configuration of serial port flow control options.

o DefaultFlowControl
Use the default flow control, ie do not change it.

o NoFlowControl
Set the port for no flow control.

o XonXoff
Set the port for software or XON/XOFF flow control.

o RtsCts
Set the port for hardware or RTS/CTS flow control.

o 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.

o 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.
Parameters:
cfg - Configuration file to read serial port attributes from.

o ~PSerialChannel()
Close the serial channel on destruction.

o Open functions

ovirtual BOOL Open( const PString & port, DWORD speed = 0, BYTE data = 0, Parity parity = DefaultParity, BYTE stop = 0, FlowControl inputFlow = DefaultFlowControl, FlowControl outputFlow = DefaultFlowControl )
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.

ovirtual BOOL Open( PConfig & cfg )
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.
Parameters:
cfg - Configuration file to read serial port attributes from.

ostatic PStringList GetPortNames()
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.

o Configuration functions

oBOOL SetSpeed( DWORD speed )
Set the speed (baud rate) of the serial channel.

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

oDWORD GetSpeed() const
Get the speed (baud rate) of the serial channel.

Returns:
current setting.

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

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

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

Returns:
current setting.

oBOOL SetParity( Parity parity )
Set the parity of the serial port.

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

oParity GetParity() const
Get the parity of the serial port.

Returns:
current setting.

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

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

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

Returns:
current setting.

oBOOL SetInputFlowControl( FlowControl flowControl )
Set the flow control (handshaking) protocol of the input to the serial port.

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

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

Returns:
current setting.

oBOOL SetOutputFlowControl( FlowControl flowControl )
Set the flow control (handshaking) protocol of the output to the serial port.

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

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

Returns:
current setting.

ovirtual void SaveSettings( PConfig & cfg )
Save the current port settings into the configuration file. Note that it assumed that the correct configuration file section is already set.
Parameters:
cfg - Configuration file to save setting into.

o Status functions

ovoid SetDTR( BOOL state = TRUE )
Set the Data Terminal Ready signal of the serial port.
Parameters:
state - New state of the DTR signal.

ovoid ClearDTR()
Clear the Data Terminal Ready signal of the serial port. This is equivalent to SetDTR(FALSE).

ovoid SetRTS( BOOL state = TRUE )
Set the Request To Send signal of the serial port.
Parameters:
state - New state of the RTS signal.

ovoid ClearRTS()
Clear the Request To Send signal of the serial port. This is equivalent to SetRTS(FALSE).

ovoid SetBreak( BOOL state = TRUE )
Set the break condition of the serial port.
Parameters:
state - New state of the serial port break condition.

ovoid ClearBreak()
Clear the break condition of the serial port. This is equivalent to SetBreak(FALSE).

oBOOL GetCTS()
Get the Clear To Send signal of the serial port.

Returns:
TRUE if the CTS signal is asserted.

oBOOL GetDSR()
Get the Data Set Ready signal of the serial port.

Returns:
TRUE if the DSR signal is asserted.

oBOOL GetDCD()
Get the Data Carrier Detect signal of the serial port.

Returns:
TRUE if the DCD signal is asserted.

oBOOL GetRing()
Get the Ring Indicator signal of the serial port.

Returns:
TRUE if the RI signal is asserted.


Direct child classes:
PModem

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.