pktparser
最終更新
最終更新
pktparser(parser_packet) performs content interpretation on the byte sequence converted by performs content interpretation on the byte sequence converted by .
Parses a sequence of bytes.
The T
specifies the packet type to be parsed. For example, TwePacketTwelite
is specified for 0x81 messages in standard applications.
p
and e
specify the next to the beginning and the end of the byte sequence.
The return value is of type E_PKT
. In case of an error, E_PKT::PKT_ERROR
is returned.
Returns a reference to an object corresponding to the packet type of the interpreted byte sequence. It can be called if parse<T>
was executed beforehand and there were no errors.
The T
can be the same type as the one executed with parse<T>
, or a TwePacket
from which only basic information can be obtained.
The above example interprets . parser_ser object converts the message input from Serial into a byte string. This byte string is first identified by to determine the type of the message . Once the message type is determined, the message is parsed by .parse<TwePacketTwelite>()
. The parsed result will be of type TwePacketTwelite
, and .use<TwePacketTwelite>()
is the procedure to extract this object. The TwePacketTwelite
type is a class, but it refers to its member variables directly as a structure.