Aria  2.8.0
ArRobotPacketReceiver Class Reference

Given a device connection it receives packets from the robot through it. More...

#include <ArRobotPacketReceiver.h>

Public Member Functions

 ArRobotPacketReceiver (bool allocatePackets=false, unsigned char sync1=0xfa, unsigned char sync2=0xfb)
 Constructor without an already assigned device connection. More...
 
 ArRobotPacketReceiver (ArDeviceConnection *deviceConnection, bool allocatePackets=false, unsigned char sync1=0xfa, unsigned char sync2=0xfb)
 Constructor with assignment of a device connection. More...
 
 ArRobotPacketReceiver (ArDeviceConnection *deviceConnection, bool allocatePackets, unsigned char sync1, unsigned char sync2, bool tracking, const char *trackingLogName)
 Constructor with assignment of a device connection and tracking. More...
 
ArDeviceConnectiongetDeviceConnection (void)
 Gets the device this instance receives packets from.
 
bool isAllocatingPackets (void)
 Gets whether or not the receiver is allocating packets.
 
ArRobotPacketreceivePacket (unsigned int msWait=0)
 Receives a packet from the robot if there is one available. More...
 
void setAllocatingPackets (bool allocatePackets)
 Sets whether or not the receiver is allocating packets.
 
void setDeviceConnection (ArDeviceConnection *deviceConnection)
 Sets the device this instance receives packets from.
 
void setPacketReceivedCallback (ArFunctor1< ArRobotPacket *> *functor)
 Sets the callback that gets called with the finalized version of every packet set... More...
 
void setTracking (bool tracking)
 
void setTrackingLogName (const char *trackingLogName)
 
virtual ~ArRobotPacketReceiver ()
 Destructor.
 

Protected Types

enum  { STATE_SYNC1, STATE_SYNC2, STATE_ACQUIRE_DATA }
 

Protected Attributes

bool myAllocatePackets
 
ArDeviceConnectionmyDeviceConn
 
ArRobotPacket myPacket
 
ArFunctor1< ArRobotPacket * > * myPacketReceivedCallback
 
unsigned char mySync1
 
unsigned char mySync2
 
bool myTracking
 
std::string myTrackingLogName
 

Detailed Description

Given a device connection it receives packets from the robot through it.

Constructor & Destructor Documentation

◆ ArRobotPacketReceiver() [1/3]

ArRobotPacketReceiver::ArRobotPacketReceiver ( bool  allocatePackets = false,
unsigned char  sync1 = 0xfa,
unsigned char  sync2 = 0xfb 
)

Constructor without an already assigned device connection.

Parameters
allocatePacketswhether to allocate memory for the packets before returning them (true) or to just return a pointer to an internal packet (false)... most everything should use false as this will help prevent many memory leaks or corruptions
sync1first byte of the header this receiver will receive, this should be left as the default in nearly all cases, ie don't mess with it
sync2second byte of the header this receiver will receive, this should be left as the default in nearly all cases, ie don't mess with it

◆ ArRobotPacketReceiver() [2/3]

ArRobotPacketReceiver::ArRobotPacketReceiver ( ArDeviceConnection deviceConnection,
bool  allocatePackets = false,
unsigned char  sync1 = 0xfa,
unsigned char  sync2 = 0xfb 
)

Constructor with assignment of a device connection.

Parameters
deviceConnectionthe connection which the receiver will use
allocatePacketswhether to allocate memory for the packets before returning them (true) or to just return a pointer to an internal packet (false)... most everything should use false as this will help prevent many memory leaks or corruptions
sync1first byte of the header this receiver will receive, this should be left as the default in nearly all cases, ie don't mess with it
sync2second byte of the header this receiver will receive, this should be left as the default in nearly all cases, ie don't mess with it

◆ ArRobotPacketReceiver() [3/3]

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

Constructor with assignment of a device connection and tracking.

Parameters
deviceConnectionthe connection which the receiver will use
allocatePacketswhether to allocate memory for the packets before returning them (true) or to just return a pointer to an internal packet (false)... most everything should use false as this will help prevent many memory leaks or corruptions
sync1first byte of the header this receiver will receive, this should be left as the default in nearly all cases, ie don't mess with it
sync2second byte of the header this receiver will receive, this should be left as the default in nearly all cases, ie don't mess with it
trackingif true write log messages for packets received
trackingLogNamename to include for packets with tracking log messages

Member Function Documentation

◆ receivePacket()

ArRobotPacket * ArRobotPacketReceiver::receivePacket ( unsigned int  msWait = 0)

Receives a packet from the robot if there is one available.

Parameters
msWaithow long to block for the start of a packet, nonblocking if 0
Returns
NULL if there are no packets in alloted time, otherwise a pointer to the packet received, if allocatePackets is true than the place that called this function owns the packet and should delete the packet when done... if allocatePackets is false then nothing must store a pointer to this packet, the packet must be used and done with by the time this method is called again

this case can't happen since c can't be over that so taking it out if (c > 255) { ArLog::log(ArLog::Normal, "ArRobotPacketReceiver::receivePacket: bad packet, more than 255 bytes"); state = STATE_SYNC1; break; }

◆ setPacketReceivedCallback()

void ArRobotPacketReceiver::setPacketReceivedCallback ( 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: