|
Boost Users : |
Subject: Re: [Boost-users] [spirit] Qi rule for GPS NMEA
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2013-09-05 22:29:10
On Thu, Sep 5, 2013 at 9:27 PM, Michael Caisse <mcaisse-lists_at_[hidden]> wrote:
> On 09/05/2013 07:00 PM, Michael Powell wrote:
>> On Thu, Sep 5, 2013 at 8:54 PM, Michael Caisse <mcaisse-lists_at_[hidden]> wrote:
>
>>>
>>> Hi Michael -
>>>
>>> Parsing NMEA is about as easy as you have described in english.
>>>
>>> rule = lit('$') >> ~char_('*') >> lit('$') >> hex >> lit("\r\n");
>>
>> Pretty straightforward. How about the wrinkle of enforcing the NMEA
>> 2-hex-digit checksum?
>>
>
> It ends up that the Spirit numeric parser is customizable. Simply create
> the parser you want. For example:
>
> qi::uint_parser< unsigned, 16, 2, 2 > nmea_hex_p;
>
> creates a parser that will synthesize unsigned values that are parsed as
> base 16 and must have exactly 2 digits.
>
>
> rule >> lit('$') >> ~char_('*') >> '*' >> nmea_hex_p >> "\r\n";
Well, whaddaya know. Poifect! Thanks!
> michael
>
> --
> Michael Caisse
> ciere consulting
> ciere.com
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
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