pktparser
pktparser(parser_packet) performs content interpretation on the byte sequence converted by serparser performs content interpretation on the byte sequence converted by serparser.
The above example interprets standard application 0x81 message. parser_ser object converts the message input from Serial into a byte string. This byte string is first identified by identify_packet_type()
to determine the type of the message E_PKT
. 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.
parse<T>
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.
user<T>
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.
最終更新