
On Thu, Sep 5, 2013 at 8:42 PM, Michael Powell <mwpowellhtx@gmail.com> wrote:
Oh yeah, and then I am adapting it into a struct:
BOOST_FUSION_ADAPT_STRUCT( dchem::drivers::nmea::basic_nmea_message_t, (std::string, m_message) (int, m_checksum) )
Or at least I'd like to. I've got the general framework understood from the employee-examples.
Thanks again.
I came up with something like this, but I may be completely off the mark: qi::rule<Iterator, std::string()> r_message; qi::rule<Iterator, int()> r_checksum; qi::rule<Iterator, basic_nmea_message_t(), ascii::space_type> r_start; using qi::char_; using qi::lit; using qi::hex; r_message %= +(char_); r_checksum %= hex >> hex; r_start %= lit('$') >> r_message >> lit('*') >> r_checksum >> lit('\r') >> lit('\n'); The I/O transport itself will handle wrapping/unwrapping when it sees '$' and the terminus "\r\n" and pass that along to the parser for handling. What I am uncertain about is how the rules consume the message and engage with the adaptation. Thank ye...
On Thu, Sep 5, 2013 at 8:39 PM, Michael Powell <mwpowellhtx@gmail.com> wrote:
Hello,
I'm digging into a qi rule for GPS NMEA and want to approach it as a kind of 2-pass parser. First pass to extract the message and hex-formatted checksum. Next pass to parse out the actual messages from the message.
I believe I comprehend how to go about the second pass. For the first pass, I want to parse $XYZ*HH\r\n.
That's the literal '$', and everything between there and the literal '*', followed by the two hex characters, as a complete field, followed by the terminal CR+LF.
How do I express the "all characters excluding '*'" for the NMEA message? Then the hex field?
Thanks...
Regards,
Michael Powell