XPortResponse Class Reference

#include <XPort.h>

List of all members.


Detailed Description

XPortResponse represents the 5-byte response returned by the XPort after writing a command to the GPIO port.

Response format:


Public Member Functions

 XPortResponse ()
 Default no argument constructor.
 XPortResponse (unsigned char cmd, unsigned int p1)
 Initializing constructor.
void set (unsigned char cmd, unsigned int param1)
 Set XPort GPIO response parameters.
int validate ()
 Validate response parameters.
int parse (char *response)
 Populate this XPResponse from a (binary) byte array.
void show ()
 Format XPort response and print to console.
unsigned char getCommand ()
 
Returns:
command member variable

unsigned int getP1 ()
 
Returns:
param1 member variable (control mask)

char * toBytes (char *buf)
 Writes XPort GPIO response bytes to specified buffer.

Private Attributes

unsigned char command
 GPIO command (see defined constants XPCMD_.
unsigned int param1
 GPIO return value.

Friends

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

Constructor & Destructor Documentation

XPortResponse::XPortResponse (  ) 

Default no argument constructor.

XPortResponse::XPortResponse ( unsigned char  cmd,
unsigned int  p1 
)

Initializing constructor.

Sets XPort GPIO response parameters.

Parameters:
cmd Command byte
p1 control mask


Member Function Documentation

void XPortResponse::set ( unsigned char  cmd,
unsigned int  p1 
)

Set XPort GPIO response parameters.

Note:
Does not perform range checking
Parameters:
cmd Command byte
p1 control mask

int XPortResponse::validate (  ) 

Validate response parameters.

Performs range checking on all parameters.

Returns:
OK if all parameters are valid, error code otherwise:
  • ERR_BADCMD: command parameter is invalid
  • ERR_BADPAR1: mask out of range
See also:
XPort.h

int XPortResponse::parse ( char *  response  ) 

Populate this XPResponse from a (binary) byte array.

Parameters:
response Byte buffer containing response bytes

void XPortResponse::show (  ) 

Format XPort response and print to console.

Note:
Requires that DEBUG be enabled

char * XPortResponse::toBytes ( char *  buf  ) 

Writes XPort GPIO response bytes to specified buffer.

Note:
Buffer should have length >= (XP_CMD_LEN+XP_PARAM_LEN)
Parameters:
buf Byte buffer
Returns:
pointer to buffer


Friends And Related Function Documentation

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

output stream operator.

Formats object for output stream insertion

Parameters:
output output stream handle
n XPortResponse object pointer


Member Data Documentation

unsigned char XPortResponse::command [private]

GPIO command (see defined constants XPCMD_.

..)


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