A class to represent all messages sent to and from the Sick LMS 2xx. More...
#include <SickLMS2xxMessage.hh>
Public Member Functions | |
void | BuildMessage (uint8_t dest_address, const uint8_t *const payload_buffer, const unsigned int payload_length) |
Consructs a message object from given parameter values. More... | |
void | Clear () |
Reset all internal fields and buffers associated with the object. More... | |
uint16_t | GetChecksum () const |
uint8_t | GetCommandCode () const |
uint8_t | GetDestAddress () const |
uint8_t | GetStatusByte () const |
void | ParseMessage (const uint8_t *const message_buffer) |
Parses a sequence of bytes into a well-formed message. More... | |
void | Print () const |
Print the message contents. More... | |
SickLMS2xxMessage () | |
A default constructor. More... | |
SickLMS2xxMessage (const uint8_t dest_address, const uint8_t *const payload_buffer, const unsigned int payload_length) | |
A constructor for building a message from the given parameter values. More... | |
SickLMS2xxMessage (uint8_t *const message_buffer) | |
A constructor for parsing a byte sequence into a message object. More... | |
~SickLMS2xxMessage () | |
Public Member Functions inherited from SickToolbox::SickMessage< SICK_LMS_2XX_MSG_HEADER_LEN, SICK_LMS_2XX_MSG_PAYLOAD_MAX_LEN, SICK_LMS_2XX_MSG_TRAILER_LEN > | |
void | BuildMessage (const uint8_t *const payload_buffer, const unsigned int payload_length) |
Constructs a Sick message given the parameter values. More... | |
void | GetMessage (uint8_t *const message_buffer) const |
Get the message as a sequence of well-formed bytes. More... | |
unsigned int | GetMessageLength () const |
void | GetPayload (uint8_t *const payload_buffer) const |
Get the payload contents as a sequence of well-formed bytes. More... | |
void | GetPayloadAsCStr (char *const payload_str) const |
unsigned int | GetPayloadLength () const |
void | GetPayloadSubregion (uint8_t *const payload_sub_buffer, const unsigned int start_idx, const unsigned int stop_idx) const |
Get a specified sub-region of the payload buffer. More... | |
bool | IsPopulated () const |
SickMessage () | |
A default constructor. More... | |
virtual | ~SickMessage () |
A destructor. More... | |
Protected Attributes | |
uint16_t | _checksum |
Protected Attributes inherited from SickToolbox::SickMessage< SICK_LMS_2XX_MSG_HEADER_LEN, SICK_LMS_2XX_MSG_PAYLOAD_MAX_LEN, SICK_LMS_2XX_MSG_TRAILER_LEN > | |
uint8_t | _message_buffer [MESSAGE_MAX_LENGTH] |
unsigned int | _message_length |
unsigned int | _payload_length |
bool | _populated |
Private Member Functions | |
uint16_t | _computeCRC (uint8_t *data, unsigned int data_length) const |
Computes the CRC16 of the given data buffer. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from SickToolbox::SickMessage< SICK_LMS_2XX_MSG_HEADER_LEN, SICK_LMS_2XX_MSG_PAYLOAD_MAX_LEN, SICK_LMS_2XX_MSG_TRAILER_LEN > | |
static const unsigned int | MESSAGE_HEADER_LENGTH |
static const unsigned int | MESSAGE_MAX_LENGTH |
static const unsigned int | MESSAGE_PAYLOAD_MAX_LENGTH |
static const unsigned int | MESSAGE_TRAILER_LENGTH |
A class to represent all messages sent to and from the Sick LMS 2xx.
This class helps to construct messages to be sent to the Sick. It also provides a container for received messages to be parsed into.
Definition at line 43 of file SickLMS2xxMessage.hh.
SickToolbox::SickLMS2xxMessage::SickLMS2xxMessage | ( | ) |
A default constructor.
Default constructor. Constructs an empty message (not well-formed!).
Definition at line 32 of file SickLMS2xxMessage.cc.
SickToolbox::SickLMS2xxMessage::SickLMS2xxMessage | ( | const uint8_t | dest_address, |
const uint8_t *const | payload_buffer, | ||
const unsigned int | payload_length | ||
) |
A constructor for building a message from the given parameter values.
Constructs a frame by using BuildMessage().
dest_address | The source address of the message |
payload_buffer | The payload of the message as an array of bytes (including the command code) |
payload_length | The length of the payload array in bytes |
Definition at line 44 of file SickLMS2xxMessage.cc.
SickToolbox::SickLMS2xxMessage::SickLMS2xxMessage | ( | uint8_t *const | message_buffer | ) |
A constructor for parsing a byte sequence into a message object.
Constructs a frame using ParseMessage().
message_buffer | A well-formed message to be parsed into the class' fields |
Definition at line 55 of file SickLMS2xxMessage.cc.
SickToolbox::SickLMS2xxMessage::~SickLMS2xxMessage | ( | ) |
Destructor
Definition at line 179 of file SickLMS2xxMessage.cc.
|
private |
Computes the CRC16 of the given data buffer.
Computes the checksum of the frame.
data | An array of bytes whose checksum to compute |
len | The length of the data array |
Definition at line 159 of file SickLMS2xxMessage.cc.
void SickToolbox::SickLMS2xxMessage::BuildMessage | ( | uint8_t | dest_address, |
const uint8_t *const | payload_buffer, | ||
const unsigned int | payload_length | ||
) |
Consructs a message object from given parameter values.
Constructs a well-formed raw frame from input fields.
dest_address | The destination address of the frame |
*payload_buffer | The payload for the frame as an array of bytes (including the command code) |
payload_length | The length of the payload array in bytes |
Definition at line 68 of file SickLMS2xxMessage.cc.
|
virtual |
Reset all internal fields and buffers associated with the object.
Reset the data associated with this message (for initialization purposes)
Reimplemented from SickToolbox::SickMessage< SICK_LMS_2XX_MSG_HEADER_LEN, SICK_LMS_2XX_MSG_PAYLOAD_MAX_LEN, SICK_LMS_2XX_MSG_TRAILER_LEN >.
Definition at line 128 of file SickLMS2xxMessage.cc.
|
inline |
Gets the checksum for the message.
Definition at line 74 of file SickLMS2xxMessage.hh.
|
inline |
Gets the command code associated with the message
Definition at line 68 of file SickLMS2xxMessage.hh.
|
inline |
Gets the address of the frame.
Definition at line 65 of file SickLMS2xxMessage.hh.
|
inline |
Gets the status byte from an LMS response message (NOTE: only applies to Sick LMS response telegrams!)
Definition at line 71 of file SickLMS2xxMessage.hh.
|
virtual |
Parses a sequence of bytes into a well-formed message.
Populates fields from a (well-formed) raw frame.
*message_buffer | The buffer containing the source message |
Definition at line 100 of file SickLMS2xxMessage.cc.
|
virtual |
Print the message contents.
A debugging function that prints the contents of the message.
Reimplemented from SickToolbox::SickMessage< SICK_LMS_2XX_MSG_HEADER_LEN, SICK_LMS_2XX_MSG_PAYLOAD_MAX_LEN, SICK_LMS_2XX_MSG_TRAILER_LEN >.
Definition at line 141 of file SickLMS2xxMessage.cc.
|
protected |
The checksum (CRC16)
Definition at line 88 of file SickLMS2xxMessage.hh.