XPortCommand Class Reference

#include <XPort.h>

List of all members.


Detailed Description

XPortCommand represents the 9-byte commands used to control the XPort GPIO pins.

Command format: byte 0 : command byte 1-4 : control mask indicating which GPIO pins to affect byte 5-8 : value mask indicating value to set

Public Member Functions

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

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

unsigned int getP2 ()
 
Returns:
param2 member variable (value mask)

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

Private Attributes

unsigned char command
 GPIO command.
unsigned int param1
 GPIO control mask.
unsigned int param2
 GPIO value mask.

Friends

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


Constructor & Destructor Documentation

XPortCommand::XPortCommand (  ) 

Default no argument constructor.

XPortCommand::XPortCommand ( unsigned char  cmd,
unsigned int  p1,
unsigned int  p2 
)

Initializing constructor.

Sets XPort GPIO command parameters.

Parameters:
cmd Command byte
p1 control mask
p2 value mask


Member Function Documentation

void XPortCommand::set ( unsigned char  cmd,
unsigned int  p1,
unsigned int  p2 
)

Set XPort GPIO command parameters.

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

int XPortCommand::validate (  ) 

Validate command 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
  • ERR_BADPAR2: mask out of range
See also:
XPort.h

int XPortCommand::parse ( const char *  cmd  ) 

Populate this XPCommand from a (binary) byte array.

Parameters:
cmd Byte buffer containing command bytes

void XPortCommand::show (  ) 

Format XPort command and print to console.

Note:
Requires that DEBUG be enabled

char * XPortCommand::toBytes ( char *  buf  ) 

Writes XPort GPIO command bytes to specified buffer.

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


Friends And Related Function Documentation

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

output stream operator.

Formats object for output stream insertion

Parameters:
output output stream handle
n XPortCommand object pointer


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