Parser of a STDBIN IXblue message. This is the entry point of the library. Usage of this class is as follow : More...
#include <stdbin_decoder.h>
Public Member Functions | |
void | addNewData (const uint8_t *data, std::size_t length) |
Add new binary data to the parser internal buffer The new data can only be a part of a frame, the parser will manage to assemble the several parts in order to decode it. More... | |
void | addNewData (const std::vector< uint8_t > &data) |
Add new binary data to the parser internal buffer The new data can only be a part of a frame, the parser will manage to assemble the several parts in order to decode it. More... | |
const std::vector< uint8_t > & | getLastAnswerData (void) const |
Data::NavHeader | getLastHeaderData (void) const |
Data::BinaryNav | getLastNavData (void) const |
bool | parseNextFrame () |
Try to parse a frame from the parser internal buffer. Some binary data must have been added with the addNewData() method beforehand. This method is able to handle buffer with header at the middle of the frame as found on connection-less communication like serial port (RS-232). More... | |
StdBinDecoder () | |
Protected Member Functions | |||
void | compareChecksum () | ||
Compute current frame checksum and compare with the frame checksum. If mismatch, throw std::runtime_error exception.
| |||
Data::NavHeader::MessageType | getHeaderType (boost::asio::const_buffer &buffer) const | ||
bool | haveEnoughBytesToParseHeader () | ||
Data::NavHeader | parseHeader (boost::asio::const_buffer &buffer) const | ||
Protected Attributes | |
const tParsersSet | extendedNavigationParsers |
const tParsersSet | externalDataParsers |
boost::circular_buffer< uint8_t > | internalBuffer |
std::vector< uint8_t > | lastAnswer |
Data::NavHeader | lastHeader |
Data::BinaryNav | lastParsed |
const tParsersSet | navigationParsers |
Private Types | |
typedef std::set< MemoryBlockParserPtr, std::function< bool(const MemoryBlockParserPtr &, const MemoryBlockParserPtr &)> > | tParsersSet |
Static Private Attributes | |
static constexpr size_t | ANSWER_HEADER_SIZE = 5 |
static constexpr size_t | CHECKSUM_SIZE = 4 |
static constexpr size_t | HEADER_SIZE_V2 = 21 |
static constexpr size_t | HEADER_SIZE_V3 = 25 |
static constexpr size_t | HEADER_SIZE_V4 = 27 |
static constexpr size_t | HEADER_SIZE_V5 = 27 |
Parser of a STDBIN IXblue message. This is the entry point of the library. Usage of this class is as follow :
parse method can be called with a partial buffer. Data will be agglomerated until the full frame have been received.
Definition at line 33 of file stdbin_decoder.h.
|
private |
Definition at line 40 of file stdbin_decoder.h.
ixblue_stdbin_decoder::StdBinDecoder::StdBinDecoder | ( | ) |
Definition at line 72 of file stdbin_decoder.cpp.
void ixblue_stdbin_decoder::StdBinDecoder::addNewData | ( | const uint8_t * | data, |
std::size_t | length | ||
) |
Add new binary data to the parser internal buffer The new data can only be a part of a frame, the parser will manage to assemble the several parts in order to decode it.
data | a pointer to a contiguous memory buffer |
length | the amount of bytes to read from the buffer |
Definition at line 158 of file stdbin_decoder.cpp.
void ixblue_stdbin_decoder::StdBinDecoder::addNewData | ( | const std::vector< uint8_t > & | data | ) |
Add new binary data to the parser internal buffer The new data can only be a part of a frame, the parser will manage to assemble the several parts in order to decode it.
data | a std::vector containing data to copy into the internal buffer |
Definition at line 153 of file stdbin_decoder.cpp.
|
protected |
Compute current frame checksum and compare with the frame checksum. If mismatch, throw std::runtime_error
exception.
runtime_error | if bad checksum. |
Definition at line 259 of file stdbin_decoder.cpp.
|
protected |
Definition at line 333 of file stdbin_decoder.cpp.
|
inline |
Definition at line 91 of file stdbin_decoder.h.
|
inline |
Definition at line 90 of file stdbin_decoder.h.
|
inline |
Definition at line 89 of file stdbin_decoder.h.
|
protected |
Definition at line 222 of file stdbin_decoder.cpp.
|
protected |
runtime_error | if a parse error occurs. |
Definition at line 281 of file stdbin_decoder.cpp.
bool ixblue_stdbin_decoder::StdBinDecoder::parseNextFrame | ( | ) |
Try to parse a frame from the parser internal buffer. Some binary data must have been added with the addNewData()
method beforehand. This method is able to handle buffer with header at the middle of the frame as found on connection-less communication like serial port (RS-232).
getLastNavData()
; runtime_error | if a parse error occurs. |
Definition at line 163 of file stdbin_decoder.cpp.
|
staticprivate |
Definition at line 46 of file stdbin_decoder.h.
|
staticprivate |
Definition at line 47 of file stdbin_decoder.h.
|
protected |
Definition at line 110 of file stdbin_decoder.h.
|
protected |
Definition at line 111 of file stdbin_decoder.h.
|
staticprivate |
Definition at line 42 of file stdbin_decoder.h.
|
staticprivate |
Definition at line 43 of file stdbin_decoder.h.
|
staticprivate |
Definition at line 44 of file stdbin_decoder.h.
|
staticprivate |
Definition at line 45 of file stdbin_decoder.h.
|
protected |
Definition at line 119 of file stdbin_decoder.h.
|
protected |
Definition at line 115 of file stdbin_decoder.h.
|
protected |
Definition at line 114 of file stdbin_decoder.h.
|
protected |
Definition at line 113 of file stdbin_decoder.h.
|
protected |
Definition at line 109 of file stdbin_decoder.h.