ADTF  v2.14.3
cSerialDevice Class Reference

Class for accessing serial devices. More...

Public Types

enum  {
  SER_EVENPARITY, SER_MARKPARITY, SER_NOPARITY, SER_ODDPARITY,
  SER_SPACEPARITY
}
 
enum  { SER_ONESTOPBIT, SER_ONE5STOPBITS, SER_TWOSTOPBITS }
 

Public Member Functions

 cSerialDevice ()
 Default constructor.
 
virtual ~cSerialDevice ()
 Destructor.
 
tResult Open (const tChar *strDeviceName, tInt nBaudRate=9600, tInt nParity=SER_NOPARITY, tInt nDataBits=8, tInt nStopBits=SER_ONESTOPBIT, tInt nRxQueue=4096, tInt nTxQueue=4096, tTimeStamp nReadTimeout=0)
 Opens a serial device. More...
 
tResult Close ()
 Closes a serial device. More...
 
tInt32 Read (tVoid *pBuffer, tInt32 nBufferSize)
 Read data from the serial device. More...
 
tInt32 Write (const tVoid *pBuffer, tInt32 nBufferSize)
 Write data to the serial device. More...
 
tResult WriteByteByByte (const cString &strCmd)
 Writes a string to the device by writing it byte after byte. More...
 
tBool IsConnected ()
 Checks if the serial device is opened. More...
 

Static Public Member Functions

static tResult CheckForDevice (const tChar *strDeviceName)
 Checks if the specified device is avaliable. More...
 
static tUInt32 GetDeviceMask ()
 Returns a bitmask of all avaliable serial devices. More...
 
static tUInt32 GetUnusedDeviceMask ()
 Returns a bitmask of all unavaliable serial devices. More...
 
static tResult FindUnusedDevice (cString &strDeviceName)
 Returns the name of the first unused serial device. More...
 

Protected Attributes

tInt m_nDev
 Device handle.
 

Detailed Description

Class for accessing serial devices.

Definition at line 24 of file serialdevice.h.

Member Function Documentation

static tResult CheckForDevice ( const tChar strDeviceName)
static

Checks if the specified device is avaliable.

Parameters
strDeviceName[in] The device name.
Returns
Standard result.
tResult Close ( )

Closes a serial device.

Returns
Standard result.
static tResult FindUnusedDevice ( cString strDeviceName)
static

Returns the name of the first unused serial device.

Parameters
strDeviceName[out] The name of the first unused serial device.
Returns
Standard result.
static tUInt32 GetDeviceMask ( )
static

Returns a bitmask of all avaliable serial devices.

Returns
A bitmask of all avaliable serial devices.
static tUInt32 GetUnusedDeviceMask ( )
static

Returns a bitmask of all unavaliable serial devices.

Returns
A bitmask of all unavaliable serial devices.
tBool IsConnected ( )

Checks if the serial device is opened.

Returns
tTrue if the serial device is opened, otherwise tFalse.
This method is real-time safe.
See The ADTF Real-Time Extension.
tResult Open ( const tChar strDeviceName,
tInt  nBaudRate = 9600,
tInt  nParity = SER_NOPARITY,
tInt  nDataBits = 8,
tInt  nStopBits = SER_ONESTOPBIT,
tInt  nRxQueue = 4096,
tInt  nTxQueue = 4096,
tTimeStamp  nReadTimeout = 0 
)

Opens a serial device.

Parameters
strDeviceName[in] The device name.
nBaudRate[in] The baud rate.
nParity[in] The parity.
nDataBits[in] The amount of data bits.
nStopBits[in] The amount of stop bits.
nRxQueue[in] The receive queue size.
nTxQueue[in] The transmission queue size.
nReadTimeout[in] The timeout for read operations in microseconds.
Returns
Standard result.
Remarks
only win32: the strDeviceName "COM1" through "COM9" can be used. A general way to specify the COM-ports (inclusive the numbering greather than 9) is the "\\\\.\\COMx". Further information can be found at http://support.microsoft.com/kb/115831/en-us
tInt32 Read ( tVoid pBuffer,
tInt32  nBufferSize 
)

Read data from the serial device.

Parameters
pBuffer[in] The buffer to fill.
nBufferSize[in] How many bytes should be read.
Returns
The actual amount of bytes read.
tInt32 Write ( const tVoid pBuffer,
tInt32  nBufferSize 
)

Write data to the serial device.

Parameters
pBuffer[in] The data to write.
nBufferSize[in] How many bytes should be written.
Returns
The actual amount of bytes written.
tResult WriteByteByByte ( const cString strCmd)

Writes a string to the device by writing it byte after byte.

Parameters
strCmd[in] The string to write
Returns
Standard result.

Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Fri Mar 22 2019 by doxygen 1.8.10)