Aria
2.8.0
|
Represents the packets sent to the LMS2xx as well as those received from it. More...
#include <ArLMS2xxPacket.h>
Inherits ArBasePacket.
Public Member Functions | |
ArLMS2xxPacket (unsigned char sendingAddress=0) | |
Constructor. | |
ArTypes::Byte2 | calcCRC (void) |
returns the crc, probably used only internally | |
virtual void | duplicatePacket (ArLMS2xxPacket *packet) |
Duplicates the packet. More... | |
virtual void | finalizePacket (void) |
ArTypes::UByte | getID (void) |
returns the ID of the packet (first byte of data) | |
unsigned char | getReceivedAddress (void) |
Gets the address this packet was sent from (only use for receiving) More... | |
unsigned char | getSendingAddress (void) |
Sets the address to send this packet to (only use for sending) More... | |
ArTime | getTimeReceived (void) |
Gets the time the packet was received at. | |
virtual void | resetRead (void) |
void | setSendingAddress (unsigned char address) |
Sets the address to send this packet to (only use for sending) More... | |
void | setTimeReceived (ArTime timeReceived) |
Sets the time the packet was received at. | |
bool | verifyCRC (void) |
returns true if the crc matches what it should be | |
virtual | ~ArLMS2xxPacket () |
Destructor. | |
Public Member Functions inherited from ArBasePacket | |
ArBasePacket (ArTypes::UByte2 bufferSize=0, ArTypes::UByte2 headerLength=0, char *buf=NULL, ArTypes::UByte2 footerLength=0) | |
Constructor. More... | |
ArBasePacket (const ArBasePacket &other) | |
Copy constructor. | |
virtual ArTypes::Byte | bufToByte (void) |
Gets a ArTypes::Byte from the buffer. | |
virtual ArTypes::Byte2 | bufToByte2 (void) |
Gets a ArTypes::Byte2 from the buffer. | |
virtual ArTypes::Byte4 | bufToByte4 (void) |
Gets a ArTypes::Byte4 from the buffer. | |
virtual void | bufToData (char *data, int length) |
Gets length bytes from buffer and puts them into data. More... | |
virtual void | bufToData (unsigned char *data, int length) |
Gets length bytes from buffer and puts them into data. More... | |
virtual void | bufToStr (char *buf, int len) |
Gets a string from the buffer. More... | |
virtual ArTypes::UByte | bufToUByte (void) |
Gets a ArTypes::UByte from the buffer. | |
virtual ArTypes::UByte2 | bufToUByte2 (void) |
Gets a ArTypes::UByte2 from the buffer. | |
virtual ArTypes::UByte4 | bufToUByte4 (void) |
Gets a ArTypes::UByte4 from the buffer. | |
virtual void | byte2ToBuf (ArTypes::Byte2 val) |
Puts ArTypes::Byte2 into packets buffer. | |
virtual void | byte4ToBuf (ArTypes::Byte4 val) |
Puts ArTypes::Byte4 into packets buffer. | |
virtual void | byteToBuf (ArTypes::Byte val) |
Puts ArTypes::Byte into packets buffer. | |
virtual void | dataToBuf (const char *data, int length) |
Copies length bytes from data into packet buffer. More... | |
virtual void | dataToBuf (const unsigned char *data, int length) |
Copies length bytes from data into packet buffer. More... | |
virtual void | duplicatePacket (ArBasePacket *packet) |
Makes this packet a duplicate of another packet. More... | |
virtual void | empty (void) |
resets the length for more data to be added More... | |
virtual const char * | getBuf (void) const |
Gets a const pointer to the buffer the packet uses. | |
virtual char * | getBuf (void) |
Gets a pointer to the buffer the packet uses. | |
virtual ArTypes::UByte2 | getDataLength (void) const |
Gets the length of the data in the packet. | |
virtual ArTypes::UByte2 | getDataReadLength (void) const |
Gets how far into the data of the packet that has been read. | |
virtual ArTypes::UByte2 | getFooterLength (void) const |
Gets the length of the header. | |
virtual ArTypes::UByte2 | getHeaderLength (void) const |
Gets the length of the header. | |
virtual ArTypes::UByte2 | getLength (void) const |
Gets the total length of the packet. | |
virtual ArTypes::UByte2 | getMaxLength (void) const |
Gets the maximum length packet. | |
virtual ArTypes::UByte2 | getReadLength (void) const |
Gets how far into the packet that has been read. | |
virtual bool | isValid (void) |
Returns whether the packet is valid, i.e. no error has occurred when reading/writing. More... | |
virtual void | log (void) |
ArLogs the hex and decimal values of each byte of the packet, and possibly extra metadata as well. | |
ArBasePacket & | operator= (const ArBasePacket &other) |
Assignment operator. | |
virtual void | printHex (void) |
ArLogs the hex value of each byte in the packet. | |
virtual void | resetValid () |
Resets the valid state of the packet. More... | |
virtual void | setBuf (char *buf, ArTypes::UByte2 bufferSize) |
Sets the buffer the packet is using. | |
virtual bool | setHeaderLength (ArTypes::UByte2 length) |
Sets the length of the header. | |
virtual bool | setLength (ArTypes::UByte2 length) |
Sets the length of the packet. | |
virtual void | setMaxLength (ArTypes::UByte2 bufferSize) |
Sets the maximum buffer size (if new size is <= current does nothing) | |
virtual void | setReadLength (ArTypes::UByte2 readLength) |
Sets the read length. | |
virtual void | strNToBuf (const char *str, int length) |
Copies the given number of bytes from str into packet buffer. More... | |
virtual void | strToBuf (const char *str) |
Puts a NULL-terminated string into packet buffer. More... | |
virtual void | strToBufPadded (const char *str, int length) |
Copies length bytes from str, if str ends before length, pads data with 0s. More... | |
virtual void | uByte2ToBuf (ArTypes::UByte2 val) |
Puts ArTypes::UByte2 into packet buffer. | |
virtual void | uByte4ToBuf (ArTypes::UByte4 val) |
Puts ArTypes::UByte 4 into packet buffer. | |
virtual void | uByteToBuf (ArTypes::UByte val) |
Puts ArTypes::UByte into packets buffer. | |
virtual | ~ArBasePacket () |
Destructor. | |
Protected Attributes | |
unsigned char | mySendingAddress |
ArTime | myTimeReceived |
Protected Attributes inherited from ArBasePacket | |
char * | myBuf |
ArTypes::UByte2 | myFooterLength |
ArTypes::UByte2 | myHeaderLength |
bool | myIsValid |
ArTypes::UByte2 | myLength |
ArTypes::UByte2 | myMaxLength |
bool | myOwnMyBuf |
ArTypes::UByte2 | myReadLength |
Additional Inherited Members | |
Protected Member Functions inherited from ArBasePacket | |
bool | hasWriteCapacity (int bytes) |
Returns true if there is enough room in the packet to add the specified number of bytes. | |
bool | isNextGood (int bytes) |
Represents the packets sent to the LMS2xx as well as those received from it.
This class reimplements some of the buf operations since the robot is little endian.
You can just look at the documentation for the ArBasePacket except for these functions here, setAddress, getAddress, verifyCheckSum, print, getID, and calcCheckSum.
|
virtual |
Duplicates the packet.
Copies the given packets buffer into the buffer of this packet, also sets this length and readlength to what the given packet has.
packet | the packet to duplicate |
unsigned char ArLMS2xxPacket::getReceivedAddress | ( | void | ) |
Gets the address this packet was sent from (only use for receiving)
This gets the address that this packet was received from.
Note that this is only valid if this packet was received from a laser, if you want to know where a packet was addressed to use getSendingAdress instead.
unsigned char ArLMS2xxPacket::getSendingAddress | ( | void | ) |
Sets the address to send this packet to (only use for sending)
This gets the address for use in sending packets, the address is what has been saved, then when a packet is finalizePacketd for sending, the address is put into the appropriate spot in the packet.
void ArLMS2xxPacket::setSendingAddress | ( | unsigned char | address | ) |
Sets the address to send this packet to (only use for sending)
This sets the address for use in sending packets, the address is saved, then when a packet is finalizePacketd for sending, the address is put into the appropriate spot in the packet.
address | the address of the laser to be addressed |