Aria  2.8.0
ArRobotPacketSender Class Reference

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

#include <ArRobotPacketSender.h>

Public Member Functions

 ArRobotPacketSender (unsigned char sync1=0xfa, unsigned char sync2=0xfb)
 Constructor without an already assigned device connection. More...
 
 ArRobotPacketSender (ArDeviceConnection *deviceConnection, unsigned char sync1=0xfa, unsigned char sync2=0xfb)
 Constructor with assignment of a device connection. More...
 
 ArRobotPacketSender (ArDeviceConnection *deviceConnection, unsigned char sync1, unsigned char sync2, bool tracking, const char *trackingLogName)
 Constructor with assignment of a device connection and tracking. More...
 
bool com (unsigned char command)
 Sends a command to the robot with no arguments. More...
 
bool com2Bytes (unsigned char command, char high, char low)
 Sends a command to the robot with two bytes for argument. More...
 
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. More...
 
bool comStr (unsigned char command, const char *argument)
 Sends a command to the robot with a length-prefixed string for argument. More...
 
bool comStrN (unsigned char command, const char *str, int size)
 Sends a command to the robot with a length-prefixed string for argument. More...
 
ArDeviceConnectiongetDeviceConnection (void)
 Gets the device this instance sends commands to.
 
bool sendPacket (ArRobotPacket *packet)
 Sends a ArRobotPacket. More...
 
void setDeviceConnection (ArDeviceConnection *deviceConnection)
 Sets the device this instance sends commands to.
 
void setPacketSentCallback (ArFunctor1< ArRobotPacket *> *functor)
 Sets the callback that gets called with the finalized version of every packet set... More...
 
virtual ~ArRobotPacketSender ()
 Destructor.
 

Protected Types

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

Protected Member Functions

bool connValid (void)
 

Protected Attributes

ArDeviceConnectionmyDeviceConn
 
ArRobotPacket myPacket
 
ArFunctor1< ArRobotPacket * > * myPacketSentCallback
 
ArMutex mySendingMutex
 
bool myTracking
 
std::string myTrackingLogName
 

Detailed Description

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

Constructor & Destructor Documentation

◆ ArRobotPacketSender() [1/3]

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
sync1first 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
sync2second 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() [2/3]

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

Constructor with assignment of a device connection.

Parameters
deviceConnectiondevice connection to send packets to
sync1first 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
sync2second 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() [3/3]

ArRobotPacketSender::ArRobotPacketSender ( ArDeviceConnection deviceConnection,
unsigned char  sync1,
unsigned char  sync2,
bool  tracking,
const char *  trackingLogName 
)

Constructor with assignment of a device connection and tracking.

Parameters
deviceConnectiondevice connection to send packets to
sync1first 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
sync2second 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
trackingif true write packet-tracking log messages for each packet sent.
trackingLogNamename (packet type) to include in packet-tracking log messages

Member Function Documentation

◆ com()

bool ArRobotPacketSender::com ( unsigned char  command)

Sends a command to the robot with no arguments.

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

◆ com2Bytes()

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

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

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

◆ comInt()

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

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

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

◆ comStr()

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
commandthe command number to send
argumentNULL-terminated string to send with the command
Returns
whether the command could be sent or not

◆ comStrN()

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
commandthe command number to send
strthe character array containing data to send with the command
sizenumber 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

◆ sendPacket()

bool ArRobotPacketSender::sendPacket ( ArRobotPacket packet)

Sends a ArRobotPacket.

Sends an ArRobotPacket.

Parameters
packetArRobotPacket
Returns
whether the command could be sent or not

◆ setPacketSentCallback()

void ArRobotPacketSender::setPacketSentCallback ( ArFunctor1< ArRobotPacket *> *  functor)

Sets the callback that gets called with the finalized version of every packet set...

this is ONLY for very internal very specialized use


The documentation for this class was generated from the following files: