ApparatusFramework::UDPDevice Class Reference

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

Inheritance diagram for ApparatusFramework::UDPDevice:
ApparatusFramework::CharDevice

List of all members.

Public Member Functions

 UDPDevice ()
 UDPDevice (const uint16 portSender, const uint16 portReceiver, char *senderAddress, char *receiverAddress)
 UDPDevice (const uint16 portSender, char *senderAddress)
virtual ~UDPDevice ()
virtual int32 open (void *arg)
virtual int32 close ()
virtual int32 read (uint8 *buffer, const int32 count)
int32 read (uint8 *buffer, const int32 count, sockaddr_in &senderAddress)
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

Implements a UDP server and client with a CharDevice interface. This enables the use of UDP sockets wherever a device is needed.

The UDPDevice can operate either in blocking or non-blocking mode. The Defaultmode is blocking.

Definition at line 81 of file UDPDevice.h.


Constructor & Destructor Documentation

ApparatusFramework::UDPDevice::UDPDevice (  ) 

Constructs a new UDPDevice object. Connections are not accepted yet, this will be done when the device is opened. Its importend to set the Memberpropertys (portSender, portReceiver, senderAdress and receiverAdress) by the ioCtl Methode.

ApparatusFramework::UDPDevice::UDPDevice ( const uint16  portSender,
const uint16  portReceiver,
char *  senderAddress,
char *  receiverAddress 
)

Constructs a new UDPDevice object. Connections are not accepted yet, this will be done when the device is opened.

Parameters:
portSender UDP port this Device write.
portReceiver UDP port this Device listens.
senderAdress IP-Address to which host you will send.
receiverAddress IP-Address form the host where this Device run.
ApparatusFramework::UDPDevice::UDPDevice ( const uint16  portSender,
char *  senderAddress 
)

Constructs a new UDPDevice object. Connections are not accepted yet, this will be done when the device is opened. This are only for send data.

Parameters:
portReceiver UDP port this Device listens.
receiverAddress IP-Address form the host where this Device run.
virtual ApparatusFramework::UDPDevice::~UDPDevice (  )  [virtual]

Destructs the object and releases all resources.


Member Function Documentation

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

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

Returns:
Returns status of the method.
  • >=0: successful
  • <0: ErrorCode, this value is device dependent.

Implements ApparatusFramework::CharDevice.

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

not implementet

Implements ApparatusFramework::CharDevice.

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

Universal method that may be used to configure the device and implement functionality not provided by the interface. The Blocking or NonBlocking mode can only set, when the Device is not open. Possible Options for cmd: UDP_DEVICE_PORT_RECEIVER = set the receiver port UDP_DEVICE_PORT_SENDER = set the sender port UDP_DEVICE_IPADDRESS_RECEIVER = set the Ip-Address from the receiver UDP_DEVICE_IPADDRESS_SENDER = set the Ip-Address from the sender CHAR_DEVICE_SET_BLOCKING = set the Blockingmode from the Device

Parameters:
cmd A command that specifies the function to be executed by the method Currently, are CHAR_DEVICE_SET_BLOCKING and UDPDeviceEnum members are supported.
arg A pointer to an argument passed to the function to be executed
Returns:
Returns status of the method.
  • >=0: Successful
  • <0: ErrorCode, this value is device dependent.

Implements ApparatusFramework::CharDevice.

virtual int32 ApparatusFramework::UDPDevice::open ( void *  arg  )  [virtual]

Opens a character device. First method to be called after the instantiation. If this method returns successfully, the device is ready to use. Its importend first set the Memberpropertys (portSender, portReceiver, senderAdress and receiverAdress) by the ioCtl Methode or by the Constructor.

Parameters:
arg A void pointer that can be used for whatever one one choses (default = null).
Returns:
Returns status of the method.
  • 0: Successful
  • >0: ErrorCode, this value is device dependent.

Implements ApparatusFramework::CharDevice.

int32 ApparatusFramework::UDPDevice::read ( uint8 buffer,
const int32  count,
sockaddr_in &  senderAddress 
)

Reads a specified number of characters from the device into a provided buffer. This read method for a device is usually implemented blocking.

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).
sockaddr_in to save the sender informations.
Returns:
Number of characters read, or error code if < 0.
virtual int32 ApparatusFramework::UDPDevice::read ( uint8 buffer,
const int32  count 
) [virtual]

Reads a specified number of characters from the device into a provided buffer. This read method for a device is usually implemented blocking.

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:
Number of characters read, or error code if < 0.

Implements ApparatusFramework::CharDevice.

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

not implementet

Implements ApparatusFramework::CharDevice.

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

Writes a specified number of characters from a buffer onto the 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:
Number of charaters written, or error code if < 0.

Implements ApparatusFramework::CharDevice.

© 2004-2010 bbv Software Services AG / Apparatus Services