Go to the documentation of this file.
74 int bufferSize = (int)raw.size();
75 if (bufferSize == 0)
return rv;
77 const unsigned char*
buffer = raw.data();
80 for (
int pre = 0; pre < bufferSize; ++pre)
84 JLTRACE(gJournal,
"Preamble found at " << pre);
93 JLTRACE(gJournal,
"Not enough header data read");
106 JLTRACE(gJournal,
"Not enough extended header data read");
124 gJournal,
"Bytes in buffer=" << remaining
125 <<
", full target = " << target);
129 JLALERT(gJournal,
"Invalid message length: " << target);
134 if (remaining < target)
138 gJournal,
"Not enough data read: " << remaining <<
" / "
148 if (rcv.loadFromString(msgStart, (
uint16_t)target))
152 "OK, size = " << (
int)rcv.getTotalMessageSize() << std::hex
153 << std::setfill(
'0') <<
" First bytes "
154 << std::setw(2) << (
int)msgStart[0] <<
" "
155 << std::setw(2) << (
int)msgStart[1] <<
" "
156 << std::setw(2) << (
int)msgStart[2] <<
" "
157 << std::setw(2) << (
int)msgStart[3] <<
" "
158 << std::setw(2) << (
int)msgStart[4]
159 << std::dec << std::setfill(
' '));
160 rv.
m_size = (int)rcv.getTotalMessageSize();
175 gJournal,
"Invalid checksum"
176 << std::hex << std::setfill(
'0')
177 <<
" First bytes " << std::setw(2)
178 << (
int)msgStart[0] <<
" " << std::setw(2)
179 << (
int)msgStart[1] <<
" " << std::setw(2)
180 << (
int)msgStart[2] <<
" " << std::setw(2)
181 << (
int)msgStart[3] <<
" " << std::setw(2)
182 << (
int)msgStart[4] << std::dec
183 << std::setfill(
' '));
213 if (msg.getTotalMessageSize() <
217 raw.assign(msg.getTotalMessageSize(), msg.getMessageStart());
218 return (
int)raw.size();
struct XsByteArray XsByteArray
unsigned __int16 uint16_t
int m_startPos
The offset of the first byte of the message or -1 if no message.
#define XS_LEN_MSGHEADERCS
int expectedMessageSize(const unsigned char *buffer, int sz)
Compute the expected message size given a possibly incomplete message.
virtual MessageLocation findMessage(XsMessage &rcv, const XsByteArray &raw) const
Find the first message in the raw byte stream.
virtual ~ProtocolHandler()
Destructor.
Stores the location of a message in a buffer using a start position and a size.
static int composeMessage(XsByteArray &raw, const XsMessage &msg)
Compose a message for transmission.
int m_size
The size of the message, when less than 0 it indicates the expected message size.
virtual int minimumMessageSize() const
Returns the minimum size of a valid message of this protocol including preambles and checksums.
virtual int maximumMessageSize() const
Returns the maximum size of a valid message of this protocol including preambles and checksums.
#define XS_LEN_MSGEXTHEADERCS
Structure for storing a single message.
ProtocolHandler()
Default constructor.
virtual int type() const
Returns the type of the protocol handler.
unsigned __int32 uint32_t
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |