Boost logo

Boost Users :

Subject: Re: [Boost-users] [spirit] Qi rule for GPS NMEA
From: Michael Caisse (mcaisse-lists_at_[hidden])
Date: 2013-09-05 21:54:12


On 09/05/2013 06:42 PM, Michael Powell 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.
>
> On Thu, Sep 5, 2013 at 8:39 PM, Michael Powell <mwpowellhtx_at_[hidden]> 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?
>>

Hi Michael -

Parsing NMEA is about as easy as you have described in english.

rule = lit('$') >> ~char_('*') >> lit('$') >> hex >> lit("\r\n");

That should parse into the fusion adapted sequence you have described.

hth -
michael

-- 
Michael Caisse
ciere consulting
ciere.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net