XPort Class Reference

#include <XPort.h>

List of all members.


Detailed Description

Encapsulates Lantronix XPort single port terminal server data and behavior.

These provide a serial port and up to 32 GPIO pins via separate TCP/IP socket connections. The GPIO pins are configurable as inputs or outputs, inverted or non-inverted outputs. There is another hardware configuration TCP/IP por that these classes do not currently support. An interactive configuration application is presented on this port, and is used to set a number of internal hardware and firmware options. Since it is menu driven, it is somewhat difficult to do programmatically in a flexible way, and the need to do this isn't clear -- for now, it is assumed that this configuration is static.

The XPort evaluation board implements 3 GPIO pins (some of the constants reflect this, though some masks are 32 bits to support all possible GPIO).

The three main classes are XPortConnection, XPortCommand, XPortResponse and XPort. The general pattern of use is:

See xportTest.cc for unit tests and examples of how the XPort is used.

TODO:


Public Member Functions

 XPort ()
 Default no argument constructor.
 XPort (char *host, unsigned int gpioPort, unsigned int serialPort, unsigned int dirMask, unsigned int dirValues, unsigned int levelMask, unsigned int levelValues)
 Initializing constructor.
XPortConnectiongetConnection ()
 
Returns:
pointer to XPortConnection member variable

int configure (char *host, unsigned int gpioIPPort, unsigned int serialIPPort, unsigned int dMask, unsigned int dValues, unsigned int lMask, unsigned int lValues)
 Configures XPortConnection member variable.
int connectxp (ConnectionID select, boolean doConfig)
 Establish socket connections to one or more XPort sockets.
int connectxp (ConnectionID select)
 Establish socket connections to one or more XPort sockets.
int disconnectxp (ConnectionID select)
 Disconnect socket connections to one or more XPort sockets.
int writeBytes (int sd, char *buf, int len)
 Write bytes to the specified socket descriptor.
int readBytes (int sd, char *buf, int len)
 Resd bytes from the specified socket descriptor into a buffer.
int writeCommand (XPortCommand *xpCommand)
 Send XPortCommand to XPort GPIO port.
int readResponse (XPortResponse *xpResponse)
 Read response to XPortCommand into XPortResponse.
int writeRead (XPortCommand *xpCommand, XPortResponse *xpResponse)
 Write XPCommand and get response in single operation.
int writeSerial (const char *msg, unsigned int len, unsigned int offset)
 Write bytes to XPort serial port.
char * getHost ()
 
Returns:
XPConnection host TCP/IP address/name.

unsigned int getpGPIO ()
 
Returns:
XPConnection GPIO TCP/IP port.

unsigned int getpSerial ()
 
Returns:
XPConnection serial port TCP/IP port.

int getsdGPIO ()
 
Returns:
XPConnection GPIO socket descriptor.

int getsdSerial ()
 
Returns:
XPConnection serial port socket descriptor.


Private Member Functions

int connectSocket (char *host, int port)
 Connect to specified XPort TCP/IP socket.

Private Attributes

XPortConnection xpConnection
 XPortConnection defining XPort TCP/IP and GPIO configuration.

Friends

ostream & operator<< (ostream &output, const XPort &n)
 output stream operator.

Constructor & Destructor Documentation

XPort::XPort ( char *  host,
unsigned int  gpioIPPort,
unsigned int  serialIPPort,
unsigned int  dMask,
unsigned int  dValues,
unsigned int  lMask,
unsigned int  lValues 
)

Initializing constructor.

Configures XPortConnection member variable.

Parameters:
host XPort host name
gpioIPPort TCP/IP port to use for GPIO
serialIPPort TCP/IP port to use for serial IO
dMask GPIO direction pin-select mask
dValues GPIO initial direction values mask
lMask GPIO level pin-select mask
lValues GPIO initial level (state) values mask


Member Function Documentation

int XPort::connectSocket ( char *  host,
int  port 
) [private]

Connect to specified XPort TCP/IP socket.

Parameters:
host XPort TCP/IP host name or address
port TCP/IP port to connect to
Returns:
Socket file handle

int XPort::configure ( char *  host,
unsigned int  gpioIPPort,
unsigned int  serialIPPort,
unsigned int  dMask,
unsigned int  dValues,
unsigned int  lMask,
unsigned int  lValues 
)

Configures XPortConnection member variable.

Parameters:
host XPort host name
gpioIPPort TCP/IP port to use for GPIO
serialIPPort TCP/IP port to use for serial IO
dMask GPIO direction pin-select mask
dValues GPIO initial direction values mask
lMask GPIO level pin-select mask
lValues GPIO initial level (state) values mask

int XPort::connectxp ( ConnectionID  select,
boolean  doConfig 
)

Establish socket connections to one or more XPort sockets.

Parameters:
select Mnemonic indicating which connection to establish
doConfig Enable XPort configuration when connecting if TRUE
Returns:
OK on success, ERROR otherwise
See also:
XPort.h

BicamConsts.h

int XPort::connectxp ( ConnectionID  select  ) 

Establish socket connections to one or more XPort sockets.

Parameters:
select Mnemonic indicating which connection to establish
Returns:
OK on success, ERROR otherwise
See also:
XPort.h

BicamConsts.h

int XPort::disconnectxp ( ConnectionID  select  ) 

Disconnect socket connections to one or more XPort sockets.

Parameters:
select Mnemonic indicating which connection to disconnect
Returns:
OK on success, ERROR otherwise
See also:
XPort.h

BicamConsts.h

int XPort::writeBytes ( int  sd,
char *  buf,
int  len 
)

Write bytes to the specified socket descriptor.

Parameters:
sd Socket descriptor
buf pointer to character buffer
len number of bytes to write
Returns:
Number of bytes written if successful, -1 otherwise

int XPort::readBytes ( int  sd,
char *  buf,
int  len 
)

Resd bytes from the specified socket descriptor into a buffer.

Parameters:
sd Socket descriptor
buf pointer to character buffer
len number of bytes to write
Returns:
Number of bytes read if successful, ERROR otherwise

int XPort::writeCommand ( XPortCommand xpCommand  ) 

Send XPortCommand to XPort GPIO port.

Parameters:
xpCommand Command to send
Returns:
number of bytes written, -1 otherwise

int XPort::readResponse ( XPortResponse xpResponse  ) 

Read response to XPortCommand into XPortResponse.

Parameters:
xpResponse pointer to XPResponse to store results in
Returns:
number of bytes read, ERROR otherwise

int XPort::writeRead ( XPortCommand xpCommand,
XPortResponse xpResponse 
)

Write XPCommand and get response in single operation.

Parameters:
xpCommand Command to send
xpResponse pointer to XPResponse to store results in
Returns:
number of bytes read, ERROR otherwise

int XPort::writeSerial ( const char *  msg,
unsigned int  len,
unsigned int  offset 
)

Write bytes to XPort serial port.

Parameters:
msg pointer to character buffer
len number of bytes to send
offset offset from start of buffer
Returns:
number of bytes sent, value <0 otherwise

char * XPort::getHost (  ) 

Returns:
XPConnection host TCP/IP address/name.

unsigned int XPort::getpGPIO (  ) 

Returns:
XPConnection GPIO TCP/IP port.

unsigned int XPort::getpSerial (  ) 

Returns:
XPConnection serial port TCP/IP port.

int XPort::getsdGPIO (  ) 

Returns:
XPConnection GPIO socket descriptor.

int XPort::getsdSerial (  ) 

Returns:
XPConnection serial port socket descriptor.


Friends And Related Function Documentation

ostream& operator<< ( ostream &  output,
const XPort n 
) [friend]

output stream operator.


The documentation for this class was generated from the following files:
Generated on Tue Jul 15 13:10:26 2008 for Benthic Imaging AUV by  doxygen 1.5.4