ApparatusFramework::SerialDevice Class Reference
[Device Services]

#include <DeviceServices/Win32/current/include/SerialDevice.h>

Inheritance diagram for ApparatusFramework::SerialDevice:
ApparatusFramework::CharDevice

List of all members.

Public Member Functions

 SerialDevice ()
 SerialDevice (int32 comPortNumber)
virtual ~SerialDevice ()
virtual int32 open (void *arg=0)
virtual int32 close ()
virtual int32 read (uint8 *buffer, const int32 count)
virtual int32 write (uint8 *buffer, const int32 count)
virtual int32 ioCtl (uint32 cmd, void *arg)
virtual int32 seek (uint32 offset, SeekWhenceEnum whence)
virtual void flush ()

Detailed Description

The SerialDevice implements a CharDevice for a communication over a serial line.

Definition at line 65 of file SerialDevice.h.


Constructor & Destructor Documentation

ApparatusFramework::SerialDevice::SerialDevice (  ) 

Construction, destruction Constructs a new serial device. Nothing more (no opening, configuring etc.)

ApparatusFramework::SerialDevice::SerialDevice ( int32  comPortNumber  ) 

Constructs a new serial device. Nothing more (no opening, configuring etc.)

Parameters:
comPortNumber the port number this device works with (1..4). See SERIAL_DEVICE_DEFAULT_COM_PORT
virtual ApparatusFramework::SerialDevice::~SerialDevice (  )  [virtual]

Destructs a serial device. Closes it if needed.


Member Function Documentation

virtual int32 ApparatusFramework::SerialDevice::close (  )  [virtual]

Closes the serial device, releases resources used for the operation. After another open, the device is ready for communication again.

Returns:
Status of the method. See CharDeviceRetVal

Implements ApparatusFramework::CharDevice.

virtual void ApparatusFramework::SerialDevice::flush (  )  [virtual]

Writes all internally buffered data onto the device and clears the send and receive buffers.

Implements ApparatusFramework::CharDevice.

virtual int32 ApparatusFramework::SerialDevice::ioCtl ( uint32  cmd,
void *  arg 
) [virtual]

Universal method that may be used to configure the serial device and implement functionality not provided by the interface.

Parameters:
cmd A command that specifies the function to be executed by the method. Those are the command defined in SerialDeviceIoCtlCmdEnum
arg A pointer to an argument passed to the function to be executed
Returns:
Status of the method. See CharDeviceRetVal

Implements ApparatusFramework::CharDevice.

virtual int32 ApparatusFramework::SerialDevice::open ( void *  arg = 0  )  [virtual]

Inherited interface methods Opens the serial port device. First method to be called after the instantiation. If this method returns successfully, the device is ready to use.

Parameters:
arg A void pointer that can be used for whatever one choses (default = null).
Returns:
Status of the method. See CharDeviceRetVal

Implements ApparatusFramework::CharDevice.

virtual int32 ApparatusFramework::SerialDevice::read ( uint8 buffer,
const int32  count 
) [virtual]

Reads a specified number of characters from the serial device into a provided buffer. This read method for a device is usually implemented blocking (blocks the calling client).

Parameters:
buffer Pointer to a character buffer. Its the buffer that read will use to fill in the fetched data.
count Number of characters to be read (does not necessarily correspond with the return value).
Returns:
Status of the method.
  • >=0: Number of characters read
  • <0: error code. See CharDeviceRetVal

Implements ApparatusFramework::CharDevice.

virtual int32 ApparatusFramework::SerialDevice::seek ( uint32  offset,
SeekWhenceEnum  whence 
) [virtual]

Allows to jump onto a certain position. Seek uses an offset that specifies the location from a certain starting point. (e.g. used in files to write onto a specified position). seek may also be used to find the size of a file (return value of seek(0, SEEK_END)).

Parameters:
offset A number that specifies the amount of chars the wanted position is away from a given starting position (whence defines that).
whence Defines the starting position or how the given index should be interpreted. See SeekWhenceEnum
Returns:
Status of the method.
  • >=0: The new offset
  • <0: error code. See CharDeviceRetVal

Implements ApparatusFramework::CharDevice.

virtual int32 ApparatusFramework::SerialDevice::write ( uint8 buffer,
const int32  count 
) [virtual]

Writes a specified number of characters from a buffer onto the serial device.

Parameters:
buffer Pointer to a character buffer. Its the buffer that write takes as data source.
count Number of characters to be taken out of the buffer onto the device.
Returns:
Status of the method.
  • >=0: Number of characters written
  • <0: error code. See CharDeviceRetVal

Implements ApparatusFramework::CharDevice.

© 2004-2010 bbv Software Services AG / Apparatus Services