gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ✘nmea.lasttag


From: Gary E. Miller
Subject: Re: ✘nmea.lasttag
Date: Wed, 8 Apr 2020 16:34:45 -0700

Yo Hal!

On Tue, 07 Apr 2020 19:10:29 -0700
Hal Murray <address@hidden> wrote:

> address@hidden said:
> > Ugh.  Fooled myself.  nmea.cycle_enders needs to be a bitmask.
> > Sometime 8 bits are set.  No idea how.   
> 
> Can you rearrange the bit assignments so that all the ones that get
> used fit into a byte/word?

I could, but then when new NMEA messages get added, we return to
the same problem.  The nmea_phrase[] is already sufficently hard to
understand, without requiring a certain data order.

The discussion did point me to the importpant parts:
    Initialization:
        gps_device_t.nmea is already memset() to zero

    Test:
        Only one bit per cycle is tested.

    Set:
        At most, two bits per cycle are changed.

    Scanning:
        The entire list is never scanned.

I decided to go with a simple array of booleans.
    The trade off: use array of bools instead of a bitmask.
    An index takes the place of the mask bit for each flag.

    Pros:
        Mapping the old code to the new is easy.  So "obviously"
        correct:

        Bit test goes from:
            0 == (session->nmea.cycle_enders & lasttag_mask) &&
        To:
            false == (session->nmea.cycle_enders[lasttag_index]) &&

        Bit set goes from:
            session->nmea.cycle_enders |= lasttag_mask;
        To:
            session->nmea.cycle_enders[lasttag_index] = true;

        The new code is smaller.  No more bit shifing.

    Cons:
        Size goes from 4 bytes to 80 bytes.  Sadly each bool takes
        an entire byte with gcc.

Changes pushed to git head.  That should fix issue #63.

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        address@hidden  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can't measure it, you can't improve it." - Lord Kelvin

Attachment: pgpxyMC1YMNut.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]