Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

ArRobotPacketSender Class Reference

#include <ArRobotPacketSender.h>

List of all members.


Detailed Description

Given a device connection this sends commands through it to the robot.


Public Member Functions

 ArRobotPacketSender (ArDeviceConnection *deviceConnection, unsigned char sync1=0xfa, unsigned char sync2=0xfb)
 Constructor with assignment of a device connection.
 ArRobotPacketSender (unsigned char sync1=0xfa, unsigned char sync2=0xfb)
 Constructor without an already assigned device connection.
bool com (unsigned char command)
 Sends a command to the robot with no arguments.
bool com2Bytes (unsigned char command, char high, char low)
 Sends a command to the robot with two bytes for argument.
bool comDataN (unsigned char command, const char *data, int size)
 Sends a command containing exactly the data in the given buffer as argument.
bool comInt (unsigned char command, short int argument)
 Sends a command to the robot with an int for argument.
bool comStr (unsigned char command, const char *argument)
 Sends a command to the robot with a length-prefixed string for argument.
bool comStrN (unsigned char command, const char *str, int size)
 Sends a command to the robot with a length-prefixed string for argument.
ArDeviceConnectiongetDeviceConnection (void)
 Gets the device this instance sends commands to.
void setDeviceConnection (ArDeviceConnection *deviceConnection)
 Sets the device this instance sends commands to.
virtual ~ArRobotPacketSender ()
 Destructor.

Protected Types

enum  { INTARG = 0x3B, NINTARG = 0x1B, STRARG = 0x2B }

Protected Member Functions

bool connValid (void)

Protected Attributes

ArDeviceConnectionmyDeviceConn
ArRobotPacket myPacket


Constructor & Destructor Documentation

ArRobotPacketSender::ArRobotPacketSender unsigned char  sync1 = 0xfa,
unsigned char  sync2 = 0xfb
 

Constructor without an already assigned device connection.

Use setDeviceConnection() to set the device connection before use.

Parameters:
sync1 first byte of the header this sender will send, this should be left as the default in nearly all cases, or it won't work with any production robot. ie don't mess with it
sync2 second byte of the header this sender will send, this should be left as the default in nearly all cases, or it won't work with any production robot. ie don't mess with it

ArRobotPacketSender::ArRobotPacketSender ArDeviceConnection deviceConnection,
unsigned char  sync1 = 0xfa,
unsigned char  sync2 = 0xfb
 

Constructor with assignment of a device connection.

Parameters:
deviceConnection device connection to send packets to
sync1 first byte of the header this sender will send, this should be left as the default in nearly all cases, or it won't work with any production robot. ie don't mess with it
sync2 second byte of the header this sender will send, this should be left as the default in nearly all cases, or it won't work with any production robot. ie don't mess with it


Member Function Documentation

bool ArRobotPacketSender::com unsigned char  command  ) 
 

Sends a command to the robot with no arguments.

Parameters:
command the command number to send
Returns:
whether the command could be sent or not

bool ArRobotPacketSender::com2Bytes unsigned char  command,
char  high,
char  low
 

Sends a command to the robot with two bytes for argument.

Parameters:
command the command number to send
high the high byte to send with the command
low the low byte to send with the command
Returns:
whether the command could be sent or not

bool ArRobotPacketSender::comInt unsigned char  command,
short int  argument
 

Sends a command to the robot with an int for argument.

Parameters:
command the command number to send
argument the integer argument to send with the command
Returns:
whether the command could be sent or not

bool ArRobotPacketSender::comStr unsigned char  command,
const char *  argument
 

Sends a command to the robot with a length-prefixed string for argument.

Sends a length-prefixed string command.

Parameters:
command the command number to send
argument NULL-terminated string to send with the command
Returns:
whether the command could be sent or not

bool ArRobotPacketSender::comStrN unsigned char  command,
const char *  str,
int  size
 

Sends a command to the robot with a length-prefixed string for argument.

Sends a packet containing the given command, and a length-prefixed string containing the specified number of bytes copied from the given source string.

Parameters:
command the command number to send
str the character array containing data to send with the command
size number of bytes from the array to send; prefix the string with a byte containing this value as well. this size must be less than the maximum packet size of 200
Returns:
whether the command could be sent or not


The documentation for this class was generated from the following files:
Generated on Thu Jan 7 10:34:44 2010 for Aria by  doxygen 1.4.2